Applying LUT to PNG image changes bit

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

Applying LUT to PNG image changes bit

Neil Fazel
When I apply an LUT to a 16-bit PNG image and save it, it is saved as an 8-bit PNG image. Is this the expected behavior? My understanding was that applying a lookup table to an image should not change the image type (e.g. bit depth) when the image is saved.

Thanks,
Neil

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

Re: Applying LUT to PNG image changes bit

Rasband, Wayne (NIH/NIMH) [E]
On Apr 13, 2015, at 6:24 PM, Neil Fazel <[hidden email]> wrote:
>
> When I apply an LUT to a 16-bit PNG image and save it, it is saved as an 8-bit PNG image. Is this the expected behavior? My understanding was that applying a lookup table to an image should not change the image type (e.g. bit depth) when the image is saved.

Applying a lookup table does not change the bit depth when saving in TIFF format. This is not the case when saving in PNG format because 16-bit images are saved using

   ImageIO.write(BufferedImage, "png", File)

and, as far as I know, there is no way to create a 16-bit BufferedImage that has a lookup table.

-wayne

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

Re: Applying LUT to PNG image changes bit

ctrueden
Hi Wayne,

> as far as I know, there is no way to create a 16-bit BufferedImage
> that has a lookup table.

You can, but you need a custom ColorModel. Bio-Formats does it [1, 2, 3, 4,
5].

But I doubt the ImageIO.write call would work with it!

Regards,
Curtis

[1]
https://github.com/openmicroscopy/bioformats/blob/v5.1.0/components/formats-bsd/src/loci/formats/gui/Index16ColorModel.java#L43-L46
[2]
https://github.com/openmicroscopy/bioformats/blob/v5.1.0/components/formats-bsd/src/loci/formats/gui/AWTImageTools.java#L793-L808
[3]
https://github.com/openmicroscopy/bioformats/blob/v5.1.0/components/formats-bsd/src/loci/formats/gui/AWTImageTools.java#L1948-L1958

On Mon, Apr 13, 2015 at 6:49 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

> On Apr 13, 2015, at 6:24 PM, Neil Fazel <[hidden email]> wrote:
> >
> > When I apply an LUT to a 16-bit PNG image and save it, it is saved as an
> 8-bit PNG image. Is this the expected behavior? My understanding was that
> applying a lookup table to an image should not change the image type (e.g.
> bit depth) when the image is saved.
>
> Applying a lookup table does not change the bit depth when saving in TIFF
> format. This is not the case when saving in PNG format because 16-bit
> images are saved using
>
>    ImageIO.write(BufferedImage, "png", File)
>
> and, as far as I know, there is no way to create a 16-bit BufferedImage
> that has a lookup table.
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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