Login  Register

Re: thumbnail quality

Posted by Bilal Ahmed-2 on Dec 08, 2005; 11:50pm
URL: http://imagej.273.s1.nabble.com/thumbnail-quality-tp3704288p3704299.html

Hi Dwayne,

One thing I noticed, if I have an image that is say 1280x1050, and I resize
to 650x650.  The result is fuzzy running the following macro.

IJ.open("MyImage.jpg");
     IJ.run("Gaussian Blur...", "radius=2");
     IJ.run("Size...", "width=100 height=100 constrain interpolate");
     IJ.run("Enhance Contrast", "saturated=0.1");
     IJ.saveAs("jpg", "thumbnail.jpg");

I tried to sharpen the image, but didn't do much help because it tends to
sharpen too much.  Is there any other option?  I also tried the enhance
Contrast value to 0.5.  That didn't help either.

Thank you.
Bilal

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne
Rasband
Sent: Thursday, December 08, 2005 12:41 PM
To: [hidden email]
Subject: Re: thumbnail quality

> Sounds like macros are the way to go.? I am still new to
> imageJ so I need a little jump start.? I can incorporate
> these macros in my java program.? One more question, I need
> to open the image in order to run the macros, right? Is that
> the open(image) command?? I don't want to actually open the
> file in GUI, rather in memory so I can do the conversion.?

Use the IJ.open() method to open the image. It will not be displayed if
there is no "ImageJ" window. Here is Java code that opens an image and
generates a thumbnail:

     IJ.open("MyImage.jpg");
     IJ.run("Gaussian Blur...", "radius=2");
     IJ.run("Size...", "width=100 height=100 constrain interpolate");
     IJ.run("Enhance Contrast", "saturated=0.1");
     IJ.saveAs("jpg", "thumbnail.jpg");

As a macro it looks like this:

    open(getArgument);
?? run("Gaussian Blur...", "radius=2");
?? run("Size...", "width=100 height=100 constrain interpolate");
?? run("Enhance Contrast", "saturated=0.1");
    saveAs("jpg", "thumbnail.jpg");

Save this macro as a file named "thumbnail.txt" and you can run it from
the command line using:

     java -jar ij.jar -batch thumbnail MyImage.jpg

You will need to be running ImageJ 1.35j or later, which adds the
-batch command line option.

-wayne