/** * Create a kernel image with given kernel size and variance. * @param width image width. * @param height image height. * @param sigma variance. * @return new kernel image. */ public static FImage createKernelImage(int width, int height, float sigma) { FImage f = new FImage(width, height); int hw = (width-1)/2; int hh = (height-1)/2; float sigmasq = sigma * sigma; float sigma4 = sigmasq*sigmasq; for (int y=-hh, j=0; y<hh; y++, j++) { for (int x=-hw, i=0; x<hw; x++, i++) { int radsqrd = x*x + y*y; f.pixels[j][i] = (float) (-1 / (PI*sigma4)*(1-radsqrd/(2*sigmasq))*exp(-radsqrd/(2*sigmasq))); } } return f.subtractInplace(FloatArrayStatsUtils.mean(f.pixels)); } }
/** * Create a kernel image with given kernel size and variance. * @param width image width. * @param height image height. * @param sigma variance. * @return new kernel image. */ public static FImage createKernelImage(int width, int height, float sigma) { FImage f = new FImage(width, height); int hw = (width-1)/2; int hh = (height-1)/2; float sigmasq = sigma * sigma; float sigma4 = sigmasq*sigmasq; for (int y=-hh, j=0; y<hh; y++, j++) { for (int x=-hw, i=0; x<hw; x++, i++) { int radsqrd = x*x + y*y; f.pixels[j][i] = (float) (-1 / (PI*sigma4)*(1-radsqrd/(2*sigmasq))*exp(-radsqrd/(2*sigmasq))); } } return f.subtractInplace(FloatArrayStatsUtils.mean(f.pixels)); } }
protected static FImage normalise(FImage f) { final float mean = FloatArrayStatsUtils.mean(f.pixels); f.subtractInplace(mean); final float sumabs = FloatArrayStatsUtils.sumAbs(f.pixels); return f.divideInplace(sumabs); } }
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
public void printStructureTensorStats() { System.out.format("Structure tensor stats for sd/si = %4.2f/%4.2f\n", detectionScale, integrationScale); System.out.format( "\tlxmx mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lxmxblur.pixels), FloatArrayStatsUtils.std(lxmxblur.pixels), lxmx.max(), lxmx.min()); System.out.format( "\tlxmy mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lxmyblur.pixels), FloatArrayStatsUtils.std(lxmyblur.pixels), lxmy.max(), lxmy.min()); System.out.format( "\tlymy mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lymyblur.pixels), FloatArrayStatsUtils.std(lymyblur.pixels), lymy.max(), lymy.min()); }
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
protected static FImage normalise(FImage f) { final float mean = FloatArrayStatsUtils.mean(f.pixels); f.subtractInplace(mean); final float sumabs = FloatArrayStatsUtils.sumAbs(f.pixels); return f.divideInplace(sumabs); } }
public void printStructureTensorStats() { System.out.format("Structure tensor stats for sd/si = %4.2f/%4.2f\n", detectionScale, integrationScale); System.out.format( "\tlxmx mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lxmxblur.pixels), FloatArrayStatsUtils.std(lxmxblur.pixels), lxmx.max(), lxmx.min()); System.out.format( "\tlxmy mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lxmyblur.pixels), FloatArrayStatsUtils.std(lxmyblur.pixels), lxmy.max(), lxmy.min()); System.out.format( "\tlymy mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(lymyblur.pixels), FloatArrayStatsUtils.std(lymyblur.pixels), lymy.max(), lymy.min()); }
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
@Override public void processCorrelationMap(FImage img, FImage template, FImage corr) { SummedAreaTable sum = new SummedAreaTable(); img.analyseWith(sum); final float templateMean = FloatArrayStatsUtils.mean(template.pixels); //TODO: cache this final float[][] pix = corr.pixels; for( int y = 0; y < corr.height; y++ ) { for( int x = 0; x < corr.width; x++ ) { double num = pix[y][x]; double t = sum.calculateArea(x, y, x+template.width, y+template.height); num -= t * templateMean; pix[y][x] = (float)num; } } } },
@Override public void processCorrelationMap(FImage img, FImage template, FImage corr) { SummedAreaTable sum = new SummedAreaTable(); img.analyseWith(sum); final float templateMean = FloatArrayStatsUtils.mean(template.pixels); //TODO: cache this final float[][] pix = corr.pixels; for( int y = 0; y < corr.height; y++ ) { for( int x = 0; x < corr.width; x++ ) { double num = pix[y][x]; double t = sum.calculateArea(x, y, x+template.width, y+template.height); num -= t * templateMean; pix[y][x] = (float)num; } } } },
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
@Override public void findInterestPoints(FImage image, Rectangle window) { this.prepareInterestPoints(image); final FImage cornerImage = createInterestPointMap(); System.out.format( "corner image mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(cornerImage.pixels), FloatArrayStatsUtils.std(cornerImage.pixels), cornerImage.max(), cornerImage.min()); detectMaxima(cornerImage, window); }
@Override public void findInterestPoints(FImage image, Rectangle window) { this.prepareInterestPoints(image); final FImage cornerImage = createInterestPointMap(); System.out.format( "corner image mean/std = %4.2e/%4.2e max/min = %4.2e/%4.2e\n", FloatArrayStatsUtils.mean(cornerImage.pixels), FloatArrayStatsUtils.std(cornerImage.pixels), cornerImage.max(), cornerImage.min()); detectMaxima(cornerImage, window); }
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);
img.analyseWith(sum); float templateMean = FloatArrayStatsUtils.mean(template.pixels); float templateStdDev = FloatArrayStatsUtils.std(template.pixels);