final static private void processFloatNaN(final FloatProcessor ip, final double min, final double max) { final double scale = max - min; final Random rnd = new Random(); final int n = ip.getWidth() * ip.getHeight(); for (int i =0; i < n; ++i) { final float v = ip.getf(i); if (Float.isNaN(v)) ip.setf(i, (float)(rnd.nextDouble() * scale + min)); } }
public FloatProcessorChunk(FloatProcessor fp) { processor = fp; width = processor.getWidth(); height = processor.getHeight(); pixels = (float[])processor.getPixels(); }
/** Constructs a FloatBlitter from a FloatProcessor. */ public FloatBlitter(FloatProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (float[])ip.getPixels(); }
final static private void processFloat(final FloatProcessor ip, final float value, final double min, final double max) { final double scale = max - min; final Random rnd = new Random(); final int n = ip.getWidth() * ip.getHeight(); for (int i =0; i < n; ++i) { final float v = ip.getf(i); if (v == value) ip.setf(i, (float)(rnd.nextDouble() * scale + min)); } }
/** Constructs a FloatBlitter from a FloatProcessor. */ public FloatBlitter(FloatProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (float[])ip.getPixels(); }
public FloatAccessor(FloatProcessor ip) { w = ip.getWidth(); h = ip.getHeight(); pixels = (float[])ip.getPixels(); }
private boolean isCloseToBorder(FloatProcessor image, Point pos) { double x = pos.getX().doubleValue(), y = pos.getY().doubleValue(); return x < (double)subimageSize || x > (double)(image.getWidth() - subimageSize) || y < (double)subimageSize || y > (double)(image.getHeight() - subimageSize); }
public DoubleIntegralImage( final FloatProcessor fp ) { this( ( float[] )fp.getPixels(), fp.getWidth(), fp.getHeight() ); }
public static FloatProcessor relGt(Double val, FloatProcessor mat) { float v = val.floatValue(); FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight()); for(int x = 0; x < mat.getWidth(); x++) { for(int y = 0; y < mat.getHeight(); y++) { res.setf(x, y, ((v > mat.getf(x, y)) ? 1.0f : 0.0f)); } } return res; }
public static FloatProcessor relGt(FloatProcessor a, FloatProcessor b) { if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) { throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!"); } FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight()); res.setMask(a.getMask() != null ? a.getMask(): b.getMask()); for(int x = 0; x < a.getWidth(); x++) { for(int y = 0; y < a.getHeight(); y++) { res.setf(x, y, ((a.getf(x, y) > b.getf(x, y)) ? 1.0f : 0.0f)); } } return res; }
private PSFSeparator.Position transformPos(Homography.TransformationMatrix transform, double x, double y) { mPos.setX(x); mPos.setY(y); return Homography.transformPositions(transform, mPositions, plane1.getWidth(), plane1.getHeight()).get(0); }
public static FloatProcessor relLt(FloatProcessor mat, Double val) { float v = val.floatValue(); FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight()); res.setMask(mat.getMask()); for(int x = 0; x < mat.getWidth(); x++) { for(int y = 0; y < mat.getHeight(); y++) { res.setf(x, y, ((mat.getf(x, y) < v) ? 1.0f : 0.0f)); } } return res; }
public static FloatProcessor relNeq(Double val, FloatProcessor mat) { float v = val.floatValue(); FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight()); res.setMask(mat.getMask()); for(int x = 0; x < mat.getWidth(); x++) { for(int y = 0; y < mat.getHeight(); y++) { res.setf(x, y, ((mat.getf(x, y) != v) ? 1.0f : 0.0f)); } } return res; }
public static FloatProcessor modulo(float val, FloatProcessor mat) { FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight()); res.setMask(mat.getMask()); float tmp; for (int i = 0, im = mat.getWidth(); i < im; i++) { for (int j = 0, jm = mat.getHeight(); j < jm; j++) { tmp = val / mat.getf(i, j); res.setf(i, j, val - (((float)((int)tmp)) * mat.getf(i, j))); } } return res; }
public static FloatProcessor modulo(FloatProcessor mat, float val) { FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight()); res.setMask(mat.getMask()); float tmp; for (int i = 0, im = mat.getWidth(); i < im; i++) { for (int j = 0, jm = mat.getHeight(); j < jm; j++) { tmp = mat.getf(i, j) / val; res.setf(i, j, mat.getf(i, j) - (((float)((int)tmp)) * val)); } } return res; }
public FloatProcessorT2(final FloatProcessor fp) { this(fp.getWidth(), fp.getHeight(), (float[])fp.getPixels(), fp.getColorModel(), fp.getMin(), fp.getMax()); } public FloatProcessorT2(final ByteProcessor bp) {
public FloatProcessor generateBackground(int width, int height, Drift drift, Range bkg) { // padd the background image; crop the center of the image later, after the drift is applied FloatProcessor img = new FloatProcessor(width + 2*(int)ceil(drift.dist), height + 2*(int)ceil(drift.dist)); for(int x = 0, w = img.getWidth(); x < w; x++) for(int y = 0, h = img.getHeight(); y < h; y++) img.setf(x, y, (float)getNextUniform(bkg.from, bkg.to)); IFilter filter = new BoxFilter(1+2*(int)(((double)Math.min(width, width))/8.0)); return filter.filterImage(img); }
public static FloatProcessor convertToFloatProcessor(GrayScaleImage img) { FloatProcessor fp = new FloatProcessor(img.getWidth(), img.getHeight()); for (int r = 0; r < fp.getHeight(); r++) { for (int c = 0; c < fp.getWidth(); c++) { fp.putPixelValue(c, r, img.getValue(r, c)); } } return fp; } }
public static FloatProcessor abs(FloatProcessor mat) { FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight(), (float [])mat.getPixelsCopy(), null); res.abs(); res.setMask(mat.getMask()); return res; }
private static void multiplyImageByGaussianMask(Point2D.Double gaussianCenter, double gaussianSigma, FloatProcessor image) { for(int y = 0; y < image.getHeight(); y++) { for(int x = 0; x < image.getWidth(); x++) { double maskValue = MathProxy.exp(-(MathProxy.sqr(x - gaussianCenter.x) + MathProxy.sqr(y - gaussianCenter.y)) / (2 * gaussianSigma * gaussianSigma)); float newValue = (float) (image.getf(x, y) * maskValue); image.setf(x, y, newValue); } } }