Batch conversion of RGB images

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

Batch conversion of RGB images

Straub, Volko A. (Dr.)
I have a large folder of b/w images (100's of images) that are saved in RGB Tiff format (Unfortunately the software that was used to collect the images saves images automatically as RGB images, even if they are only b/w images). When I open an image in ImageJ and manually change the image type to 8-bit, all is fine and the new image uses the full data range for an 8-bit image (i.e. 0 to 255). However, if I try to use the Process->Batch->Convert... command to convert all the images in a folder and set the output format to 8-bit TIFF, the dynamic range of the resulting image is compressed to values between 0 and 32.

To illustrate the problem I have attached a sample of an original image (Image1 - original, RGB TIFF), the same image manually converted to 8-bit (Image1 - 8-bit manual) and a version converted using Process->Batch->Convert... with the output format selected as 8-bit TIFF (Image 1 - 8-bit batch).

I could obviously write a short macro to do the necessary conversion, but I was wondering whether there is anything obvious I am missing in the batch conversion process that would make the batch conversion behave the same as the manually changing the image type from RGB to 8-bit.

Thanks for any suggestions/help,
Volko



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Image1 - 8-bit manual.tif (39K) Download Attachment
Image1 - original.tif (118K) Download Attachment
Image1 - 8-bit batch.tif (42K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Batch conversion of RGB images

Christian Goosmann-2
Hi Volko
I remember having problems with that kind of format out of a b/w camera.
My quick and dirty solution was to include "color>split channels" in the
batch code and to delete two of the channels. The remaining channel was
used. Is it thoughtlessness of the camera manufacturers to pack so much
redundant data in your files? They probably get paid by the harddrive
manufacturers.

---
Christian Goosmann
Mikroskopie
Max-Planck-Institut für Infektionsbiologie
Campus Charité Mitte
Charitéplatz 1
10117 Berlin
Tel.: +49 30 28460 388

Straub, Volko A. (Dr.) wrote:

> I have a large folder of b/w images (100's of images) that are saved in RGB Tiff format (Unfortunately the software that was used to collect the images saves images automatically as RGB images, even if they are only b/w images). When I open an image in ImageJ and manually change the image type to 8-bit, all is fine and the new image uses the full data range for an 8-bit image (i.e. 0 to 255). However, if I try to use the Process->Batch->Convert... command to convert all the images in a folder and set the output format to 8-bit TIFF, the dynamic range of the resulting image is compressed to values between 0 and 32.
>
> To illustrate the problem I have attached a sample of an original image (Image1 - original, RGB TIFF), the same image manually converted to 8-bit (Image1 - 8-bit manual) and a version converted using Process->Batch->Convert... with the output format selected as 8-bit TIFF (Image 1 - 8-bit batch).
>
> I could obviously write a short macro to do the necessary conversion, but I was wondering whether there is anything obvious I am missing in the batch conversion process that would make the batch conversion behave the same as the manually changing the image type from RGB to 8-bit.
>
> Thanks for any suggestions/help,
> Volko
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch conversion of RGB images

Jan Eglinger
In reply to this post by Straub, Volko A. (Dr.)
Hi Volko,

the problem is that the batch converter uses the "8-bit Color" command
to convert an RGB image to 8-bit TIFF format. In the class
ij.plugin.BatchConverter [1], you find the following lines:

     if (format.equals("8-bit TIFF") || format.equals("GIF")) {
         if (imp.getBitDepth()==24)
             IJ.run(imp, "8-bit Color", "number=256");

You can reproduce the batch behaviour by running
'Image > Type > 8-bit Color' on your image manually. You will see that
it converts the grey levels into 12 indexed colors and leaves the
remaining color indices for other colors (which are absent from your b/w
image).

Try running 'Process > Batch > Macro...' instead and put
'run("8-bit");' in the macro text field, leaving the output format as TIFF.

Hth,
Jan

[1]:
https://github.com/imagej/imagej1/blob/master/ij/plugin/BatchConverter.java#L81-83


On 02.06.2014, 11:50 AM, Straub, Volko A. (Dr.) wrote:
> I have a large folder of b/w images (100's of images) that are saved in RGB Tiff format (Unfortunately the software that was used to collect the images saves images automatically as RGB images, even if they are only b/w images). When I open an image in ImageJ and manually change the image type to 8-bit, all is fine and the new image uses the full data range for an 8-bit image (i.e. 0 to 255). However, if I try to use the Process->Batch->Convert... command to convert all the images in a folder and set the output format to 8-bit TIFF, the dynamic range of the resulting image is compressed to values between 0 and 32.
>
> To illustrate the problem I have attached a sample of an original image (Image1 - original, RGB TIFF), the same image manually converted to 8-bit (Image1 - 8-bit manual) and a version converted using Process->Batch->Convert... with the output format selected as 8-bit TIFF (Image 1 - 8-bit batch).
>
> I could obviously write a short macro to do the necessary conversion, but I was wondering whether there is anything obvious I am missing in the batch conversion process that would make the batch conversion behave the same as the manually changing the image type from RGB to 8-bit.
>
> Thanks for any suggestions/help,
> Volko
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html