Login  Register

Re: Batch conversion of RGB images

Posted by Jan Eglinger on Jun 02, 2014; 1:47pm
URL: http://imagej.273.s1.nabble.com/Batch-conversion-of-RGB-images-tp5007980p5007985.html

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