Save TIFF as displayed?

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

Save TIFF as displayed?

Mike Myerburg
Hi-

Is it possible to have ImageJ save as a .tif file with the saved file
having the same contrast as it is displayed?  Basically I would like to
save "representative" images, following auto-contrast, to use in a
figure.  This would save me having to open the files in Photoshop and
doing the leveling there.

Thanks!
Reply | Threaded
Open this post in threaded view
|

setIconImage

Joachim Wesner
Hi list,

I was wondering if it would be possible to change the Icon of my plugin´s
ImagePlus windows from the "microscope" to represent the contents, this
would be nice.

It seems setIconImage would be the method to call, looking to the API docs
I found that the following code might work (imp is a refrence to the
current ImagePlus);

      ImageWindow win = imp.getWindow();
      win.setIconImage(imp.getImage());

This code is compile without errors, however when the above lines of code
are executed, it seems that execution disappears in never-land, no
exception, no CPU load, ImageJ does no longer
update it´s main window.

What is going on?

When I create a simple BufferedImage, I can setIconImage from that, when I
try to explicitely cast the image returned from getImage to a
BufferedImage, I get an exception, telling that it´s
a sun.awt.ToolkitImage!??

How to do it right?

Thanx

Joachim


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: setIconImage

Sami Badawi-2
Hi Joachim,

java.awt.Image is an abstract super class for several concrete Image
implementation classes.
This method will turn any subclass of java.awt.Image into a BufferedImage:

        public static BufferedImage toBufferedImage(Image image, int newModelId) {
                BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),
                                image.getHeight(null), newModelId);
                Graphics2D graphics = bufferedImage.createGraphics();
                graphics.drawImage(image, 0, 0, null);
                return bufferedImage;
        }

I am not sure if icons need to be a particular color model or size,
but this will change you image into an int RGB BufferedImage:

       ImageWindow win = imp.getWindow();
       BufferedImage bufferedIconInRGB =
toBufferedImage(imp.getImage(), BufferedImage.TYPE_INT_RGB);
       win.setIconImage(bufferedIconInRGB);

-Sami Badawi
http://www.shapelogic.org
Reply | Threaded
Open this post in threaded view
|

Re: Save TIFF as displayed?

Wayne Rasband
In reply to this post by Mike Myerburg
> Is it possible to have ImageJ save as a .tif file with the saved  
> file having the same contrast as it is displayed?  Basically I  
> would like to save "representative" images, following auto-
> contrast, to use in a figure.  This would save me having to open  
> the files in Photoshop and doing the leveling there.

With 8-bit images, click "Apply" in the B&C window before saving as  
TIFF. With 16 and 32 bit images, convert to 8-bit before saving as TIFF.

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

Re: Save TIFF as displayed?

Mike Myerburg
Thanks- adding the apply LUT to the macro fixed the problem!

Fantastic and will save me a lot of time.

Cheers, Mike

Rasband Wayne wrote:

>> Is it possible to have ImageJ save as a .tif file with the saved file
>> having the same contrast as it is displayed?  Basically I would like
>> to save "representative" images, following auto-contrast, to use in a
>> figure.  This would save me having to open the files in Photoshop and
>> doing the leveling there.
>
> With 8-bit images, click "Apply" in the B&C window before saving as
> TIFF. With 16 and 32 bit images, convert to 8-bit before saving as TIFF.
>
> -wayne
>