/** Convolves the image <code>ip</code> with a kernel of width <code>kw</code> and height <code>kh</code>. */ public void convolveFloat1D(FloatProcessor ip, float[] kernel, int kw, int kh) { convolveFloat1D(ip, kernel, kw, kh, normalize?getScale(kernel):1.0); }
/** Convolves the image <code>ip</code> with a kernel of width <code>kw</code> and height <code>kh</code>. */ public void convolveFloat1D(FloatProcessor ip, float[] kernel, int kw, int kh) { convolveFloat1D(ip, kernel, kw, kh, normalize?getScale(kernel):1.0); }
/** Convolves <code>ip</code> with a kernel of width <code>kw</code> and height <code>kh</code>. Returns false if the user cancels the operation. */ public boolean convolve(ImageProcessor ip, float[] kernel, int kw, int kh) { if (canceled || kw*kh!=kernel.length) return false; if ((kw&1)!=1 || (kh&1)!=1) throw new IllegalArgumentException("Kernel width or height not odd ("+kw+"x"+kh+")"); boolean notFloat = !(ip instanceof FloatProcessor); ImageProcessor ip2 = ip; if (notFloat) { if (ip2 instanceof ColorProcessor) throw new IllegalArgumentException("RGB images not supported"); ip2 = ip2.convertToFloat(); } if (kw==1 || kh==1) convolveFloat1D((FloatProcessor)ip2, kernel, kw, kh, normalize?getScale(kernel):1.0); else convolveFloat(ip2, kernel, kw, kh); if (notFloat) { if (ip instanceof ByteProcessor) ip2 = ip2.convertToByte(false); else ip2 = ip2.convertToShort(false); ip.setPixels(ip2.getPixels()); } return !canceled; }
/** Convolves <code>ip</code> with a kernel of width <code>kw</code> and height <code>kh</code>. Returns false if the user cancels the operation. */ public boolean convolve(ImageProcessor ip, float[] kernel, int kw, int kh) { if (canceled || kw*kh!=kernel.length) return false; if ((kw&1)!=1 || (kh&1)!=1) throw new IllegalArgumentException("Kernel width or height not odd ("+kw+"x"+kh+")"); boolean notFloat = !(ip instanceof FloatProcessor); ImageProcessor ip2 = ip; if (notFloat) { if (ip2 instanceof ColorProcessor) throw new IllegalArgumentException("RGB images not supported"); ip2 = ip2.convertToFloat(); } if (kw==1 || kh==1) convolveFloat1D((FloatProcessor)ip2, kernel, kw, kh, normalize?getScale(kernel):1.0); else convolveFloat(ip2, kernel, kw, kh); if (notFloat) { if (ip instanceof ByteProcessor) ip2 = ip2.convertToByte(false); else ip2 = ip2.convertToShort(false); ip.setPixels(ip2.getPixels()); } return !canceled; }