Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to write a grayscale 16 bit tiff image from a 2D image array

Subject: How to write a grayscale 16 bit tiff image from a 2D image array

From: kostas Karakasiliotis

Date: 15 Sep, 2010 17:04:05

Message: 1 of 3

Hi,

I've got some 2D arrays which contain image information in grayscale and they are uint16 (so they have values from 0 - 2^16, 0 being the black).
I'm trying to save tiff images from these arrays but no luck.. I can't see how to determine the bit depth and I'm always getting a white image full of 255. I've been using imwrite().

Thanks for any help on that!
Kostas

Subject: How to write a grayscale 16 bit tiff image from a 2D image array

From: Sean

Date: 15 Sep, 2010 17:21:07

Message: 2 of 3

"kostas Karakasiliotis" <kostas.karakasiliotis@epfl.ch> wrote in message <i6qua5$fcq$1@fred.mathworks.com>...
> Hi,
>
> I've got some 2D arrays which contain image information in grayscale and they are uint16 (so they have values from 0 - (
2^16 -1)
, 0 being the black).
> I'm trying to save tiff images from these arrays but no luck.. I can't see how to determine the bit depth and I'm always getting a white image full of 255. I've been using imwrite().
>
> Thanks for any help on that!
> Kostas

How are you viewing the images once you've written them? IMWRITE with 16bit Tiff options, according to the doc should be acceptable.

When you view the image what range are you viewing it with? I would check and see if you're only viewing it from 0-255 in which case most of the 16bit values will appear white.
Try:
>>imshow(I,[ 0 2^16-1])

Subject: How to write a grayscale 16 bit tiff image from a 2D image array

From: kostas Karakasiliotis

Date: 15 Sep, 2010 18:37:05

Message: 3 of 3

Hi,
It was kind of stupid in the end because it needs to specify again the type of the image contents individually using "uint16(image)" even if when I was building the image I was loading uint16s. Then it saves the tiff fine.
Regards,
Kostas

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i6qva3$lr3$1@fred.mathworks.com>...
> "kostas Karakasiliotis" <kostas.karakasiliotis@epfl.ch> wrote in message <i6qua5$fcq$1@fred.mathworks.com>...
> > Hi,
> >
> > I've got some 2D arrays which contain image information in grayscale and they are uint16 (so they have values from 0 - (
> 2^16 -1)
> , 0 being the black).
> > I'm trying to save tiff images from these arrays but no luck.. I can't see how to determine the bit depth and I'm always getting a white image full of 255. I've been using imwrite().
> >
> > Thanks for any help on that!
> > Kostas
>
> How are you viewing the images once you've written them? IMWRITE with 16bit Tiff options, according to the doc should be acceptable.
>
> When you view the image what range are you viewing it with? I would check and see if you're only viewing it from 0-255 in which case most of the 16bit values will appear white.
> Try:
> >>imshow(I,[ 0 2^16-1])

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us