public static BufferedImage renderOrientation4(GrayS8 direction , GrayF32 intensity , float threshold , BufferedImage out ) { out = new BufferedImage(direction.getWidth(),direction.getHeight(),BufferedImage.TYPE_INT_RGB); int data[] = raster.getDataStorage(); int w = direction.getWidth(); int h = direction.getHeight();
public static BufferedImage renderOrientation4(GrayS8 direction , GrayF32 intensity , float threshold , BufferedImage out ) { out = new BufferedImage(direction.getWidth(),direction.getHeight(),BufferedImage.TYPE_INT_RGB); int offsetDst = ConvertRaster.getOffset(raster); int w = direction.getWidth(); int h = direction.getHeight();
/** * Bounds image pixels to be between these two values * * @param img Image * @param min minimum value. * @param max maximum value. */ public static void boundImage(GrayS8 img , int min , int max ) { final int h = img.getHeight(); final int w = img.getWidth(); byte[] data = img.data; for (int y = 0; y < h; y++) { int index = img.getStartIndex() + y * img.getStride(); int indexEnd = index+w; // for(int x = 0; x < w; x++ ) { for (; index < indexEnd; index++) { int value = data[index]; if( value < min ) data[index] = (byte)min; else if( value > max ) data[index] = (byte)max; } } }
/** * <p> * Computes the absolute value of the difference between each pixel in the two images.<br> * d(x,y) = |img1(x,y) - img2(x,y)| * </p> * @param imgA Input image. Not modified. * @param imgB Input image. Not modified. * @param diff Absolute value of difference image. Modified. */ public static void diffAbs(GrayS8 imgA , GrayS8 imgB , GrayS8 diff ) { InputSanityCheck.checkSameShape(imgA,imgB,diff); final int h = imgA.getHeight(); final int w = imgA.getWidth(); for (int y = 0; y < h; y++) { int indexA = imgA.getStartIndex() + y * imgA.getStride(); int indexB = imgB.getStartIndex() + y * imgB.getStride(); int indexDiff = diff.getStartIndex() + y * diff.getStride(); int indexEnd = indexA+w; // for(int x = 0; x < w; x++ ) { for (; indexA < indexEnd; indexA++, indexB++, indexDiff++ ) { diff.data[indexDiff] = (byte)Math.abs((imgA.data[indexA] ) - (imgB.data[indexB] )); } } }
/** * <p> * Performs pixel-wise addition<br> * output(x,y) = imgA(x,y) + imgB(x,y) * </p> * @param imgA Input image. Not modified. * @param imgB Input image. Not modified. * @param output Output image. Modified. */ public static void add(GrayS8 imgA , GrayS8 imgB , GrayS16 output ) { InputSanityCheck.checkSameShape(imgA,imgB,output); final int h = imgA.getHeight(); final int w = imgA.getWidth(); for (int y = 0; y < h; y++) { int indexA = imgA.getStartIndex() + y * imgA.getStride(); int indexB = imgB.getStartIndex() + y * imgB.getStride(); int indexOut = output.getStartIndex() + y * output.getStride(); int indexEnd = indexA+w; // for(int x = 0; x < w; x++ ) { for (; indexA < indexEnd; indexA++, indexB++, indexOut++ ) { output.data[indexOut] = (short)((imgA.data[indexA] ) + (imgB.data[indexB] )); } } }
/** * <p> * Performs pixel-wise subtraction.<br> * output(x,y) = imgA(x,y) - imgB(x,y) * </p> * @param imgA Input image. Not modified. * @param imgB Input image. Not modified. * @param output Output image. Modified. */ public static void subtract(GrayS8 imgA , GrayS8 imgB , GrayS16 output ) { InputSanityCheck.checkSameShape(imgA,imgB,output); final int h = imgA.getHeight(); final int w = imgA.getWidth(); for (int y = 0; y < h; y++) { int indexA = imgA.getStartIndex() + y * imgA.getStride(); int indexB = imgB.getStartIndex() + y * imgB.getStride(); int indexOut = output.getStartIndex() + y * output.getStride(); int indexEnd = indexA+w; // for(int x = 0; x < w; x++ ) { for (; indexA < indexEnd; indexA++, indexB++, indexOut++ ) { output.data[indexOut] = (short)((imgA.data[indexA] ) - (imgB.data[indexB] )); } } }