Basic question

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

Basic question

Thomas Delnoij-3
I recently switched from using javax.imageio to ImageJ and I am
running into several basic issues. I hope some of you can help me out.

The requirements are a multi threaded webcrawler that is generating
thumbnails from URL's to Image files (jpg, png and gif). The
thumbnails are written to a predefined directory on the file system.
Thumbnails should be 100px*100px; we need the best possible quality.
File size of the generated thumbails is not so important. Performance
is crucial though. Processing should be done in the backgroung (no
gui).

I started with this code.

ImagePlus ip = new ImagePlus(imageUrl);
ImageProcessor imp = ip.getProcessor();
ImageProcessor imp2 = imp.resize(THUMB_WIDTH, THUMB_HEIGHT);
imp2.setInterpolate(true);
ImagePlus ip2 = new ImagePlus("Resized Image", imp2);
FileSaver fs = new FileSaver(ip2);
JpegWriter.setQuality(100);
fs.saveAsJpeg();

Performance is OK, but the quality of the generated thumbnails is not so good.

Then I read this thread that has some info on improving the quality of
the generated thumbnails:
https://list.nih.gov/cgi-bin/wa?A2=ind0512&L=IMAGEJ&P=R2440&I=-3

I tried both IJ.run("","") and IJ.runMacro(String macro) style syntax.

Both give me different types of errors:

- Image locked errors
- A window pops up and no thumbnail is generated
- Runtime exceptions

Some thumbs are generated though and they are much better quality than
before, reason I like to ge this code working.

Now, I think my problems are related to threading issues. I am very
new to ImageJ and probably my question shows my basic ignorance. Still
I hope some of you read so far and can give me some hints or pointers
to some examples.

Rgrds. Thomas Delnoij
Reply | Threaded
Open this post in threaded view
|

Re: Basic question (generating thumbnails)

Wayne Rasband
Try upgrading to ImageJ 1.37b or later. It averages source pixels when
RGB images are reduced by more than 4:1, resulting in better looking
thumbnails. It also helps to enhance the contrast, which you can do
using something like

     (new ContrastEnhancer()).stretchHistogram(imp2, 0.05);

or like this in a macro

    run("Enhance Contrast", "saturated=0.05");

-wayne


On May 30, 2006, at 11:04 AM, TDLN wrote:

> I recently switched from using javax.imageio to ImageJ and I am
> running into several basic issues. I hope some of you can help me out.
>
> The requirements are a multi threaded webcrawler that is generating
> thumbnails from URL's to Image files (jpg, png and gif). The
> thumbnails are written to a predefined directory on the file system.
> Thumbnails should be 100px*100px; we need the best possible quality.
> File size of the generated thumbails is not so important. Performance
> is crucial though. Processing should be done in the backgroung (no
> gui).
>
> I started with this code.
>
> ImagePlus ip = new ImagePlus(imageUrl);
> ImageProcessor imp = ip.getProcessor();
> ImageProcessor imp2 = imp.resize(THUMB_WIDTH, THUMB_HEIGHT);
> imp2.setInterpolate(true);
> ImagePlus ip2 = new ImagePlus("Resized Image", imp2);
> FileSaver fs = new FileSaver(ip2);
> JpegWriter.setQuality(100);
> fs.saveAsJpeg();
>
> Performance is OK, but the quality of the generated thumbnails is not
> so good.
>
> Then I read this thread that has some info on improving the quality of
> the generated thumbnails:
> https://list.nih.gov/cgi-bin/wa?A2=ind0512&L=IMAGEJ&P=R2440&I=-3
>
> I tried both IJ.run("","") and IJ.runMacro(String macro) style syntax.
>
> Both give me different types of errors:
>
> - Image locked errors
> - A window pops up and no thumbnail is generated
> - Runtime exceptions
>
> Some thumbs are generated though and they are much better quality than
> before, reason I like to ge this code working.
>
> Now, I think my problems are related to threading issues. I am very
> new to ImageJ and probably my question shows my basic ignorance. Still
> I hope some of you read so far and can give me some hints or pointers
> to some examples.
>
> Rgrds. Thomas Delnoij
>
Reply | Threaded
Open this post in threaded view
|

Re: Basic question (generating thumbnails)

Thomas Delnoij-3
I implemented your suggestion - thumbnail quality is much better now.

Thank's a lot!

Rgrds, Thomas Delnoij

On 5/30/06, Wayne Rasband <[hidden email]> wrote:

> Try upgrading to ImageJ 1.37b or later. It averages source pixels when
> RGB images are reduced by more than 4:1, resulting in better looking
> thumbnails. It also helps to enhance the contrast, which you can do
> using something like
>
>      (new ContrastEnhancer()).stretchHistogram(imp2, 0.05);
>
> or like this in a macro
>
>     run("Enhance Contrast", "saturated=0.05");
>
> -wayne
>
>
> On May 30, 2006, at 11:04 AM, TDLN wrote:
>
> > I recently switched from using javax.imageio to ImageJ and I am
> > running into several basic issues. I hope some of you can help me out.
> >
> > The requirements are a multi threaded webcrawler that is generating
> > thumbnails from URL's to Image files (jpg, png and gif). The
> > thumbnails are written to a predefined directory on the file system.
> > Thumbnails should be 100px*100px; we need the best possible quality.
> > File size of the generated thumbails is not so important. Performance
> > is crucial though. Processing should be done in the backgroung (no
> > gui).
> >
> > I started with this code.
> >
> > ImagePlus ip = new ImagePlus(imageUrl);
> > ImageProcessor imp = ip.getProcessor();
> > ImageProcessor imp2 = imp.resize(THUMB_WIDTH, THUMB_HEIGHT);
> > imp2.setInterpolate(true);
> > ImagePlus ip2 = new ImagePlus("Resized Image", imp2);
> > FileSaver fs = new FileSaver(ip2);
> > JpegWriter.setQuality(100);
> > fs.saveAsJpeg();
> >
> > Performance is OK, but the quality of the generated thumbnails is not
> > so good.
> >
> > Then I read this thread that has some info on improving the quality of
> > the generated thumbnails:
> > https://list.nih.gov/cgi-bin/wa?A2=ind0512&L=IMAGEJ&P=R2440&I=-3
> >
> > I tried both IJ.run("","") and IJ.runMacro(String macro) style syntax.
> >
> > Both give me different types of errors:
> >
> > - Image locked errors
> > - A window pops up and no thumbnail is generated
> > - Runtime exceptions
> >
> > Some thumbs are generated though and they are much better quality than
> > before, reason I like to ge this code working.
> >
> > Now, I think my problems are related to threading issues. I am very
> > new to ImageJ and probably my question shows my basic ignorance. Still
> > I hope some of you read so far and can give me some hints or pointers
> > to some examples.
> >
> > Rgrds. Thomas Delnoij
> >
>