void convolve(ImageProcessor ip1, ImageProcessor ip2, float[] pixelsKernel) { final Convolver c = new Convolver(); //ImagePlus imp = new ImagePlus("ip", ip1); //imp.show(); //(new ImagePlus("pixelKernel", new FloatProcessor(size, size, pixelsKernel, null))).show(); boolean b = c.convolveFloat(ip1, pixelsKernel, size, size); if(!b) { IJ.error("Error while convolving first image with kernel!"); return; } //(new ImagePlus("convoluted ip1", ip1)).show(); final Convolver c2 = new Convolver(); b = c2.convolveFloat(ip2, pixelsKernel, size, size); if(!b) { IJ.error("Error while convolving second image with kernel!"); return; } }
/** 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; }
void convolve(ImageProcessor ip1, ImageProcessor ip2, float[] pixelsKernel) { final Convolver c = new Convolver(); //ImagePlus imp = new ImagePlus("ip", ip1); //imp.show(); //(new ImagePlus("pixelKernel", new FloatProcessor(size, size, pixelsKernel, null))).show(); boolean b = c.convolveFloat(ip1, pixelsKernel, size, size); if(!b) { IJ.error("Error while convolving first image with kernel!"); return; } //(new ImagePlus("convoluted ip1", ip1)).show(); final Convolver c2 = new Convolver(); b = c2.convolveFloat(ip2, pixelsKernel, size, size); if(!b) { IJ.error("Error while convolving second image with kernel!"); return; } }
/** 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; }
public ImagePlus call(){ final int patchSize = filter.getWidth(); Convolver c = new Convolver(); float[] kernel = (float[]) filter.getPixels(); ImageProcessor ip = originalImage.getProcessor().duplicate(); c.convolveFloat(ip, kernel, patchSize, patchSize); return new ImagePlus (title, ip); } };
public ImagePlus call(){ final int patchSize = filter.getWidth(); Convolver c = new Convolver(); float[] kernel = (float[]) filter.getPixels(); ImageProcessor ip = originalImage.getProcessor().duplicate(); c.convolveFloat(ip, kernel, patchSize, patchSize); return new ImagePlus (title, ip); } };
c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c.convolveFloat(ip_y, sobelFilter_y, 3, 3); c.convolveFloat(ip_xx, sobelFilter_x, 3, 3); c.convolveFloat(ip_xy, sobelFilter_y, 3, 3); c.convolveFloat(ip_yy, sobelFilter_y, 3, 3);
c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c.convolveFloat(ip_y, sobelFilter_y, 3, 3); c.convolveFloat(ip_xx, sobelFilter_x, 3, 3); c.convolveFloat(ip_xy, sobelFilter_y, 3, 3); c.convolveFloat(ip_yy, sobelFilter_y, 3, 3);
Convolver c = new Convolver(); float[] sobelFilter_x = {1f,2f,1f,0f,0f,0f,-1f,-2f,-1f}; c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c = new Convolver(); float[] sobelFilter_y = {1f,0f,-1f,2f,0f,-2f,1f,0f,-1f}; c.convolveFloat(ip_y, sobelFilter_y, 3, 3);
Convolver c = new Convolver(); float[] sobelFilter_x = {1f,2f,1f,0f,0f,0f,-1f,-2f,-1f}; c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c = new Convolver(); float[] sobelFilter_y = {1f,0f,-1f,2f,0f,-2f,1f,0f,-1f}; c.convolveFloat(ip_y, sobelFilter_y, 3, 3);
Convolver c = new Convolver(); float[] sobelFilter_x = {1f,2f,1f,0f,0f,0f,-1f,-2f,-1f}; c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c = new Convolver(); float[] sobelFilter_y = {1f,0f,-1f,2f,0f,-2f,1f,0f,-1f}; c.convolveFloat(ip_y, sobelFilter_y, 3, 3);
Convolver c = new Convolver(); float[] sobelFilter_x = {1f,2f,1f,0f,0f,0f,-1f,-2f,-1f}; c.convolveFloat(ip_x, sobelFilter_x, 3, 3); c = new Convolver(); float[] sobelFilter_y = {1f,0f,-1f,2f,0f,-2f,1f,0f,-1f}; c.convolveFloat(ip_y, sobelFilter_y, 3, 3);
c.convolveFloat(ip, kernel, patchSize, patchSize);
c.convolveFloat(ip, kernel, patchSize, patchSize);
c.convolveFloat(ip, kernel, patchSize, patchSize);
c.convolveFloat(ip, kernel, patchSize, patchSize);