thumbnail quality

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

thumbnail quality

Bilal Ahmed-2
Hello:

 

I am using ImageJ Java API to create thumbnails.  It seems like the quality
gets worse as the image gets smaller.  Is there a way to enhance the image
quality?

 

I am using the ImageProcessor.resize() method to resize the image to
100x100.

 

I also tried to change the DEFAULT_QUALITY in JpegWriter to 100.  That
helped a little, but not too much.  It just seems like some of the white
pixels become more evident.

 

I would really appreciate any help.  The rest of the ImageJ works great!

 

Thanks in advance,

Bilal

 

 
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Wayne Rasband
> I am using ImageJ Java API to create thumbnails.  It seems like the
> quality gets worse as the image gets smaller.  Is there a way to  
> enhance
> the image quality?

Try the Averaging Reducer plugin at "http://rsb.info.nih.gov/ij/ 
plugins/reducer.html". If you can't use a plugin, try smoothing the  
image, reducing it and then enhancing the contrast. Here is a macro  
that does this:

    run("Duplicate...", "title=Thumbnail");
    run("Gaussian Blur...", "radius=2");
    run("Size...", "width=100 height=100 constrain interpolate");
    run("Enhance Contrast", "saturated=0.1");

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Bilal Ahmed-2
Hi Wayne,

Thanks for your help.  Since I am using the API only to generate thumbnails,
I wouldn't have access to the plugin.  I did however saw your code at
http://rsb.info.nih.gov/ij/plugins/download/Averaging_Reducer.java.  Is
there a way I can just call the methods to clear the images?  I believe
macros need to be run via the cmd shell, not java source.  Is that the right
assumption?

Thanks,
Bilal

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Rasband Wayne
Sent: Tuesday, December 06, 2005 6:59 PM
To: [hidden email]
Subject: Re: thumbnail quality

> I am using ImageJ Java API to create thumbnails.  It seems like the
> quality gets worse as the image gets smaller.  Is there a way to  
> enhance
> the image quality?

Try the Averaging Reducer plugin at "http://rsb.info.nih.gov/ij/ 
plugins/reducer.html". If you can't use a plugin, try smoothing the  
image, reducing it and then enhancing the contrast. Here is a macro  
that does this:

    run("Duplicate...", "title=Thumbnail");
    run("Gaussian Blur...", "radius=2");
    run("Size...", "width=100 height=100 constrain interpolate");
    run("Enhance Contrast", "saturated=0.1");

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Wayne Rasband
> Thanks for your help.? Since I am using the API only to
> generate thumbnails, I wouldn't have access to the plugin.?
> I did however saw your code at
> http://rsb.info.nih.gov/ij/plugins/download/
> Averaging_Reducer.java.? Is there a way I can just
> call the methods to clear the images?

You can copy the methods from Averaging_Reducer.java and paste them
into your program.

> ? I believe
> macros need to be run via the cmd shell, not java source.?
> Is that the right assumption?

Java programs can execute ImageJ commands, which is what this macro is
doing, by calling IJ.run(). Here is an example:

   IJ.run("Duplicate...", "title=Thumbnail");
   IJ.run("Gaussian Blur...", "radius=2");
   IJ.run("Size...", "width=100 height=100 constrain interpolate");
   IJ.run("Enhance Contrast", "saturated=0.1");

Java programs can also run macros using the IJ.runMacro() method, for
example:

   String macro = "run('Duplicate...', 'title=Thumbnail')"
     +"run('Gaussian Blur...', 'radius=2')"
     +"run('Size...', 'width=100 height=100 constrain interpolate')"
     +"run('Enhance Contrast', 'saturated=0.1')";
   IJ.runMacro(macro);

-wayne

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Rasband Wayne
> Sent: Tuesday, December 06, 2005 6:59 PM
> To: [hidden email]
> Subject: Re: thumbnail quality
>
> > I am using ImageJ Java API to create thumbnails.? It seems
> > like the quality gets worse as the image gets smaller.? Is
> > there a way to? enhance
> > the image quality?
>
> Try the Averaging Reducer plugin at "http://rsb.info.nih.gov/ij/
> plugins/reducer.html". If you can't use a plugin, try smoothing
> the?image, reducing it and then enhancing the contrast.
> Here is a macro?that does this:
>
> ??? run("Duplicate...", "title=Thumbnail");
> ??? run("Gaussian Blur...", "radius=2");
> ??? run("Size...", "width=100 height=100 constrain interpolate");
> ??? run("Enhance Contrast", "saturated=0.1");
>
> -wayne
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Bilal Ahmed-2
Hi Wayne,

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.  

IJ.run("Duplicate...", "title=Thumbnail");
   IJ.run("Gaussian Blur...", "radius=2");
   IJ.run("Size...", "width=100 height=100 constrain interpolate");
   IJ.run("Enhance Contrast", "saturated=0.1");

Thank you.
Bilal

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne
Rasband
Sent: Wednesday, December 07, 2005 2:02 PM
To: [hidden email]
Subject: Re: thumbnail quality

> Thanks for your help.? Since I am using the API only to
> generate thumbnails, I wouldn't have access to the plugin.?
> I did however saw your code at
> http://rsb.info.nih.gov/ij/plugins/download/
> Averaging_Reducer.java.? Is there a way I can just
> call the methods to clear the images?

You can copy the methods from Averaging_Reducer.java and paste them
into your program.

> ? I believe
> macros need to be run via the cmd shell, not java source.?
> Is that the right assumption?

Java programs can execute ImageJ commands, which is what this macro is
doing, by calling IJ.run(). Here is an example:

   IJ.run("Duplicate...", "title=Thumbnail");
   IJ.run("Gaussian Blur...", "radius=2");
   IJ.run("Size...", "width=100 height=100 constrain interpolate");
   IJ.run("Enhance Contrast", "saturated=0.1");

Java programs can also run macros using the IJ.runMacro() method, for
example:

   String macro = "run('Duplicate...', 'title=Thumbnail')"
     +"run('Gaussian Blur...', 'radius=2')"
     +"run('Size...', 'width=100 height=100 constrain interpolate')"
     +"run('Enhance Contrast', 'saturated=0.1')";
   IJ.runMacro(macro);

-wayne

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Rasband Wayne
> Sent: Tuesday, December 06, 2005 6:59 PM
> To: [hidden email]
> Subject: Re: thumbnail quality
>
> > I am using ImageJ Java API to create thumbnails.? It seems
> > like the quality gets worse as the image gets smaller.? Is
> > there a way to? enhance
> > the image quality?
>
> Try the Averaging Reducer plugin at "http://rsb.info.nih.gov/ij/
> plugins/reducer.html". If you can't use a plugin, try smoothing
> the?image, reducing it and then enhancing the contrast.
> Here is a macro?that does this:
>
> ??? run("Duplicate...", "title=Thumbnail");
> ??? run("Gaussian Blur...", "radius=2");
> ??? run("Size...", "width=100 height=100 constrain interpolate");
> ??? run("Enhance Contrast", "saturated=0.1");
>
> -wayne
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Bilal Ahmed-2
In reply to this post by Wayne Rasband
Thanks Wayne.  Really appreciate your help.  I got it to work.

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne
Rasband
Sent: Wednesday, December 07, 2005 2:02 PM
To: [hidden email]
Subject: Re: thumbnail quality

> Thanks for your help.? Since I am using the API only to
> generate thumbnails, I wouldn't have access to the plugin.?
> I did however saw your code at
> http://rsb.info.nih.gov/ij/plugins/download/
> Averaging_Reducer.java.? Is there a way I can just
> call the methods to clear the images?

You can copy the methods from Averaging_Reducer.java and paste them
into your program.

> ? I believe
> macros need to be run via the cmd shell, not java source.?
> Is that the right assumption?

Java programs can execute ImageJ commands, which is what this macro is
doing, by calling IJ.run(). Here is an example:

   IJ.run("Duplicate...", "title=Thumbnail");
   IJ.run("Gaussian Blur...", "radius=2");
   IJ.run("Size...", "width=100 height=100 constrain interpolate");
   IJ.run("Enhance Contrast", "saturated=0.1");

Java programs can also run macros using the IJ.runMacro() method, for
example:

   String macro = "run('Duplicate...', 'title=Thumbnail')"
     +"run('Gaussian Blur...', 'radius=2')"
     +"run('Size...', 'width=100 height=100 constrain interpolate')"
     +"run('Enhance Contrast', 'saturated=0.1')";
   IJ.runMacro(macro);

-wayne

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Rasband Wayne
> Sent: Tuesday, December 06, 2005 6:59 PM
> To: [hidden email]
> Subject: Re: thumbnail quality
>
> > I am using ImageJ Java API to create thumbnails.? It seems
> > like the quality gets worse as the image gets smaller.? Is
> > there a way to? enhance
> > the image quality?
>
> Try the Averaging Reducer plugin at "http://rsb.info.nih.gov/ij/
> plugins/reducer.html". If you can't use a plugin, try smoothing
> the?image, reducing it and then enhancing the contrast.
> Here is a macro?that does this:
>
> ??? run("Duplicate...", "title=Thumbnail");
> ??? run("Gaussian Blur...", "radius=2");
> ??? run("Size...", "width=100 height=100 constrain interpolate");
> ??? run("Enhance Contrast", "saturated=0.1");
>
> -wayne
Reply | Threaded
Open this post in threaded view
|

Crop

Bilal Ahmed-2
Hi all,

What is the macro to crop an image?  For example, I have a 250x400 image.  I
want to crop from the top and bottom to make it 250x250.

Thanks,
Bilal
Reply | Threaded
Open this post in threaded view
|

Re: Crop

Tony Collins-2
Hi Bilal,

Specify the ROI via the menu command Edit/Selection/Specify

Then crop, with the menu command Image/Crop

You can record this to a macro using the recorder (Plugins/Macro/record)
if you need to do this  a lot.

Regards,

Tony

Bilal Ahmed wrote:

>Hi all,
>
>What is the macro to crop an image?  For example, I have a 250x400 image.  I
>want to crop from the top and bottom to make it 250x250.
>
>Thanks,
>Bilal
>  
>

--
Tony Collins, Ph.D.
Facility Manager
Wright Cell Imaging Facility
Toronto Western Research Institute
13-407 McLaughlin Pavilion
399 Bathurst Street
Toronto, ON. M5T 2S8
tel. (416) 603 5367 fax: (416) 603 5745
http://www.uhnresearch.ca/wcif
Reply | Threaded
Open this post in threaded view
|

Re: Crop

Wayne Rasband
In reply to this post by Bilal Ahmed-2
> What is the macro to crop an image?? For example, I have a 250x400
> image.? I
> want to crop from the top and bottom to make it 250x250.

The command recorder will generate the code for you. Start the recorder
(Plugins>Macros>Record), open the image, create a 250x250 rectangular
selection, then use the Image>Crop command.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Wayne Rasband
In reply to this post by Bilal Ahmed-2
> 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
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Bilal Ahmed-2
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
Reply | Threaded
Open this post in threaded view
|

Re: thumbnail quality

Bilal Ahmed-2
My apology, I was referring to Wayne.

>>>>>>>>>>>>>>>>>>>>>
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 Bilal
Ahmed
Sent: Thursday, December 08, 2005 3:51 PM
To: [hidden email]
Subject: Re: thumbnail quality

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
Reply | Threaded
Open this post in threaded view
|

Re: Crop

Bill Mohler
In reply to this post by Bilal Ahmed-2
We use ImageJ a lot in my lab at UCHC.  You could probably drop by some time and pick up a few tips.

Bill
-----Original Message-----

From:  Adrienne J Betz <[hidden email]>
Subj:  Re: Crop
Date:  Fri Dec 9, 2005 12:05 am
Size:  833 bytes
To:  [hidden email]

Is there by chance anyone in the Connecticut (NYC,MA,NJ etc.) area willing to give a tutorial? Only and hour or so of your time...
worth a shot!
-Adrienne

Adrienne J. Betz
University of Connecticut
Department of Psychology
Behavioral Neuroscience Division
406 Babbidge Road, U-1020
Storrs, CT 06269-1020
860.486.4768 tel
860.486.2760 fax

----- Original Message -----
From: Wayne Rasband <[hidden email]>
Date: Thursday, December 8, 2005 3:19 pm
Subject: Re: Crop

> > What is the macro to crop an image?  For example, I have a
> 250x400
> > image.  I
> > want to crop from the top and bottom to make it 250x250.
>
> The command recorder will generate the code for you. Start the
> recorder
> (Plugins>Macros>Record), open the image, create a 250x250
> rectangular
> selection, then use the Image>Crop command.
>
> -wayne
>


William Mohler
Dept. of Genetics & Dev. Biol
UConn Health Ctr.
P: 860-679-1833
M: 860-985-2719