Login  Register

Re: Changing amount of sharpen and smooth

Posted by dashko on Apr 13, 2010; 2:06pm
URL: http://imagej.273.s1.nabble.com/Changing-amount-of-sharpen-and-smooth-tp3688605p3688609.html

Thanks for response. I think unsharp mask will be good compromise :)

But how can i apply Unsharp Mask. I tried
 IJ.run(imp, "Unsharp Mask...", "radius=3 mask=0.6");
But it returns Unrecognized command: Unsharp Mask...

And i tried:
UnsharpMask um = new UnsharpMask();
um.setup("radius=3 mask=0.6", imp);
ColorProcessor cp = (ColorProcessor) imp.getProcessor();
        cp.getHistogram();
        width = cp.getWidth();
        height = cp.getHeight();
        int[] pixels = (int[]) cp.getPixels();

FloatProcessor fp = new FloatProcessor(imp.getWidth(),imp.getHeight(), pixels);

fp.setSnapshotPixels(fp.getPixels());
um.sharpenFloat(fp, 3, (float)0.6);

bimg=fp.getBufferedImage();
imp = new ImagePlus("image", bimg);

But i can't cast or convert int[] to float[] pixels. How can i apply Unsharp Mask on my ImageProcessor?