Login  Register

Re: Changing amount of sharpen and smooth

Posted by Michael Schmid on Apr 13, 2010; 4:52pm
URL: http://imagej.273.s1.nabble.com/Changing-amount-of-sharpen-and-smooth-tp3688605p3688610.html

Hi Dashko,

your first version
    IJ.run(imp, "Unsharp Mask...", "radius=3 mask=0.6");
should work. Maybe you have mistyped the command or you have a hidden  
character in the string?
Does it work in a macro?
   run("Unsharp Mask...", "radius=3 mask=0.6");
If this does not work, your installation of ImageJ might be corrupted.

For an ImageProcessor ip of arbitrary type, I'd use something like  
the following:

    FloatProcessor fp = null;
    UnsharpMask us = new UnsharpMask();
    for (int i=0; i<ip.getNChannels(); i++) {
       fp = ip.toFloat(i, fp);
       fp.snapshot();
       us.sharpenFloat(fp, 3.0, (float)0.6);
       ip.setPixels(i, fp);
    }

For an RGB image, it loops over the R, G, B channels. For grayscale,  
the loop is executed only once. For a FloatProcessor, the ip.toFloat  
and p.setPixels only pass the reference to fp; no conversion is done.

Michael
________________________________________________________________

On 13 Apr 2010, at 16:06, dashko wrote:

> 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 cast or convert int[] to float[] pixels. How can i apply  
> Unsharp
> Mask on my ImageProcessor?
> --
> View this message in context: http://n2.nabble.com/Changing-amount- 
> of-sharpen-and-smooth-tp4884651p4896256.html
> Sent from the ImageJ mailing list archive at Nabble.com.