PixelMath.divide((GrayU8) input, denominator, (int) lower, (int) upper, (GrayU8) output); } else if (GrayS8.class == input.getClass()) { PixelMath.divide((GrayS8) input, denominator, (int) lower, (int) upper, (GrayS8) output); } else if (GrayU16.class == input.getClass()) { PixelMath.divide((GrayU16) input, denominator, (int) lower, (int) upper, (GrayU16) output); } else if (GrayS16.class == input.getClass()) { PixelMath.divide((GrayS16) input, denominator, (int) lower, (int) upper, (GrayS16) output); } else if (GrayS32.class == input.getClass()) { PixelMath.divide((GrayS32) input, denominator, (int) lower, (int) upper, (GrayS32) output); } else if (GrayS64.class == input.getClass()) { PixelMath.divide((GrayS64) input, denominator, (long) lower, (long) upper, (GrayS64) output); } else if (GrayF32.class == input.getClass()) { PixelMath.divide((GrayF32) input, (float) denominator, (float) lower, (float) upper, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.divide((GrayF64) input, denominator, lower, upper, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); PixelMath.divide((InterleavedU8) input, denominator, (int) lower, (int) upper, (InterleavedU8) output); } else if (InterleavedS8.class == input.getClass()) { PixelMath.divide((InterleavedS8) input, denominator, (int) lower, (int) upper, (InterleavedS8) output); } else if (InterleavedU16.class == input.getClass()) { PixelMath.divide((InterleavedU16) input, denominator, (int) lower, (int) upper, (InterleavedU16) output); } else if (InterleavedS16.class == input.getClass()) { PixelMath.divide((InterleavedS16) input, denominator, (int) lower, (int) upper, (InterleavedS16) output); } else if (InterleavedS32.class == input.getClass()) { PixelMath.divide((InterleavedS32) input, denominator, (int) lower, (int) upper, (InterleavedS32) output); } else if (InterleavedS64.class == input.getClass()) { PixelMath.divide((InterleavedS64) input, denominator, (long) lower, (long) upper, (InterleavedS64) output);
PixelMath.divide((GrayU8) input, denominator, (GrayU8) output); } else if (GrayS8.class == input.getClass()) { PixelMath.divide((GrayS8) input, denominator, (GrayS8) output); } else if (GrayU16.class == input.getClass()) { PixelMath.divide((GrayU16) input, denominator, (GrayU16) output); } else if (GrayS16.class == input.getClass()) { PixelMath.divide((GrayS16) input, denominator, (GrayS16) output); } else if (GrayS32.class == input.getClass()) { PixelMath.divide((GrayS32) input, denominator, (GrayS32) output); } else if (GrayS64.class == input.getClass()) { PixelMath.divide((GrayS64) input, denominator, (GrayS64) output); } else if (GrayF32.class == input.getClass()) { PixelMath.divide((GrayF32) input, (float) denominator, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.divide((GrayF64) input, denominator, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); PixelMath.divide((InterleavedU8) input, denominator, (InterleavedU8) output); } else if (InterleavedS8.class == input.getClass()) { PixelMath.divide((InterleavedS8) input, denominator, (InterleavedS8) output); } else if (InterleavedU16.class == input.getClass()) { PixelMath.divide((InterleavedU16) input, denominator, (InterleavedU16) output); } else if (InterleavedS16.class == input.getClass()) { PixelMath.divide((InterleavedS16) input, denominator, (InterleavedS16) output); } else if (InterleavedS32.class == input.getClass()) { PixelMath.divide((InterleavedS32) input, denominator, (InterleavedS32) output); } else if (InterleavedS64.class == input.getClass()) { PixelMath.divide((InterleavedS64) input, denominator, (InterleavedS64) output);
PixelMath.divide((GrayF32) imgA, (GrayF32) imgB, (GrayF32) output); } else if (GrayF64.class == imgA.getClass()) { PixelMath.divide((GrayF64) imgA, (GrayF64) imgB, (GrayF64) output); PixelMath.divide((GrayF32) in.getBand(i), (GrayF32) imgB, (GrayF32) out.getBand(i)); } else if (GrayF64.class == imgB.getClass()) { PixelMath.divide((GrayF64) in.getBand(i), (GrayF64) imgB, (GrayF64) out.getBand(i));
/** * Copies the target into the output image and applies the cosine window to it. */ protected void get_subwindow( T image , GrayF64 output ) { // copy the target region interp.setImage(image); int index = 0; for( int y = 0; y < workRegionSize; y++ ) { float yy = regionTrack.y0 + y*stepY; for( int x = 0; x < workRegionSize; x++ ) { float xx = regionTrack.x0 + x*stepX; if( interp.isInFastBounds(xx,yy)) output.data[index++] = interp.get_fast(xx,yy); else if( BoofMiscOps.checkInside(image, xx, yy)) output.data[index++] = interp.get(xx, yy); else { // randomize to make pixels outside the image poorly correlate. It will then focus on matching // what's inside the image since it has structure output.data[index++] = rand.nextFloat()*maxPixelValue; } } } // normalize values to be from -0.5 to 0.5 PixelMath.divide(output, maxPixelValue, output); PixelMath.plus(output, -0.5f, output); // apply the cosine window to it PixelMath.multiply(output,cosine,output); }
@Override public void process(GrayU8 input) { ConvertImage.convert(input, grayF); PixelMath.divide(grayF,255.0f,grayF); dft.forward(grayF, transform); DiscreteFourierTransformOps.shiftZeroFrequency(transform, true); DiscreteFourierTransformOps.magnitude(transform, grayF); PixelMath.log(grayF,grayF); float max = ImageStatistics.maxAbs(grayF); PixelMath.multiply(grayF, 255f / max, grayF); ConvertBitmap.grayToBitmap(grayF, bitmap, bitmapTmp); } }
private double computeEdgeMSE(GrayF32 imageInv) { GrayF32 edge = new GrayF32(imageInv.width,imageInv.height); LaplacianEdge.process(image,edge); PixelMath.abs(edge,edge); float max = ImageStatistics.maxAbs(edge); PixelMath.divide(edge,max,edge); float total = ImageStatistics.sum(edge); double error = 0; for( int y = 0; y < image.height; y++ ) { for( int x = 0; x < image.width; x++ ) { double w = edge.get(x,y)/total; double e = (image.get(x,y)-imageInv.get(x,y)); error += (e*e)*w; } } return error; }
@Override public void setInputImage(GrayF32 image) { enlargedTemplate.reshape(image.width,image.height); fftImage.reshape(image.width,image.height); fftTemplate.reshape(image.width,image.height); fftMult.reshape(image.width,image.height); correlation.reshape(image.width,image.height); normalizedImage.reshape(image.width,image.height); maxValue = ImageStatistics.max(image)+0.0001f;// avoid divide by zero errors mean = ImageStatistics.mean(image); PixelMath.divide(image,maxValue,normalizedImage); PixelMath.minus(normalizedImage,mean/maxValue,normalizedImage); dft.forward(normalizedImage, fftImage); }
PixelMath.divide(template,maxValue,normalizedTemplate); PixelMath.minus(normalizedTemplate,mean/maxValue,normalizedTemplate);