public static < T extends ImageGray < T > > boolean isInside ( T ii , double X , double Y , int radiusRegions , int kernelSize , double scale , double c , double s ) { int c_x = ( int ) Math . round ( X ) ; int c_y = ( int ) Math . round ( Y ) ; kernelSize = ( int ) Math . ceil ( kernelSize * scale ) ; int kernelRadius = kernelSize / 2 + ( kernelSize % 2 ) ; // find the radius of the whole area being sampled int radius = ( int ) Math . ceil ( radiusRegions * scale ) ; // integral image convolutions sample the pixel before the region starts // which is why the extra minus one is there int kernelPaddingMinus = radius + kernelRadius + 1 ; int kernelPaddingPlus = radius + kernelRadius ; // take in account the rotation if ( c != 0 || s != 0 ) { double xx = Math . abs ( c * kernelPaddingMinus - s * kernelPaddingMinus ) ; double yy = Math . abs ( s * kernelPaddingMinus + c * kernelPaddingMinus ) ; double delta = xx > yy ? xx - kernelPaddingMinus : yy - kernelPaddingMinus ; kernelPaddingMinus += ( int ) Math . ceil ( delta ) ; kernelPaddingPlus += ( int ) Math . ceil ( delta ) ; } // compute the new bounds and see if its inside int x0 = c_x - kernelPaddingMinus ; if ( x0 < 0 ) return false ; int x1 = c_x + kernelPaddingPlus ; if ( x1 >= ii . width ) return false ; int y0 = c_y - kernelPaddingMinus ; if ( y0 < 0 ) return false ; int y1 = c_y + kernelPaddingPlus ; if ( y1 >= ii . height ) return false ; return true ; }
Checks to see if the region is contained inside the image . This includes convolution kernel . Take in account the orientation of the region .