Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

10 bit image handling

257 views
Skip to first unread message

R Gow

unread,
Jul 9, 2004, 6:48:57 AM7/9/04
to
Hi,
I'm trying to load a 10bit PGM file for processing in MATLAB, but I
understand that MATLAB does not support 10 bits? Are there any ways
around this?
Using imread, matlab seems to load the file as uint16 but if the
software can't handle 10 bits in the first place, does this mean data
has been lost/ignored in getting to the 16 bit format? It is
important for me to retain all the original values in the image!
If anyone has faced similar problems I would appreciate your advice.
Thanks,

R Gow

Dave Tarkowski

unread,
Jul 9, 2004, 8:48:30 AM7/9/04
to

MATLAB can handle ten bit images. According to the documentation for
IMREAD, it can read in PGM files with up to 16 bits of resolution.

MATLAB does not have a 10 bit data type, so it must store your data as a
UINT16.

-Dave Tarkowski

R Gow

unread,
Jul 9, 2004, 8:51:32 AM7/9/04
to
Dave,

Thanks for the info, so do you know exactly what operation MATLAB
does to store the 10 bit image as 16 bit unsigned integer?

Thanks,

Ryan

Dave Tarkowski wrote:
>
>
> On Fri, 9 Jul 2004 06:48:57 -0400, R Gow wrote:

Steve Eddins

unread,
Jul 9, 2004, 8:55:49 AM7/9/04
to

"R Gow" <r.d...@no.spam.ed.ac.uk> writes:

> Dave,
>
> Thanks for the info, so do you know exactly what operation MATLAB
> does to store the 10 bit image as 16 bit unsigned integer?
>
> Thanks,
>
> Ryan
>

The least-significant 10 bits of the MATLAB uint16 value are exactly the
original 10 bits.

--
Steve Eddins

Development Manager, Image Processing Group
The MathWorks, Inc.

R Gow

unread,
Jul 9, 2004, 9:07:07 AM7/9/04
to
Steve,

Thanks but does that mean that bits > 10 are simply set to zero to
basically store the 1024 codes from original image in 65536 codes, or
is the data scaled to fill the new range?

Thank again,

R Gow

Steve Eddins wrote:
>
>
>> Dave Tarkowski wrote:
>> >
>> >
>> > On Fri, 9 Jul 2004 06:48:57 -0400, R Gow wrote:

Steve Eddins

unread,
Jul 9, 2004, 9:08:00 AM7/9/04
to

"R Gow" <r.d...@no-spam.ed.ac.ukk> writes:

> Steve,
>
> Thanks but does that mean that bits > 10 are simply set to zero

yes

Peter J. Acklam

unread,
Jul 9, 2004, 5:14:40 PM7/9/04
to
"R Gow" <r.d...@no-spam.ed.ac.ukk> wrote:

> Thanks but does that mean that bits > 10 are simply set to zero
> to basically store the 1024 codes from original image in 65536
> codes, or is the data scaled to fill the new range?

When writing 10 bit PGM images, bits 11-16 are set to zero, if I
remember correctly, and if MATLAB is still using the code I wrote.
On read, those bits are simply ignored.

The PGM specs don't allow binary images with more than 8 bits, but
some applications still write 16 bit PGM images, so I added
support for binary images with bitdepth > 8 by request from
someone missing support for 16 bit PGM images. I have never seen
or heard of 10 bit binary PGM images, although the code should
handle them correctly (I hope).

Peter

--
Everyone has a blind spot in each eye. I also have a deaf spot
in each ear. If you stand at a certain place, I can't hear you.

us

unread,
Jul 9, 2004, 5:33:21 PM7/9/04
to
Peter J. Acklam:
<SNIP 10-bit pgm problem

...and if MATLAB is still using the code I wrote...

they do, peter, they do:

function [X, map] = readpnm(filename)
%READPNM Read image data from a
%PPM/PGM/PBM file.
% SNIP
% Author: Peter J. Acklam
% E-mail: pjac...@online.no

% Copyright 2001-2002 The MathWorks, Inc.
% $Revision: 1.1.6.2 $ $Date: 2004/02/01 22:04:51 $

us

Peter J. Acklam

unread,
Jul 9, 2004, 6:15:00 PM7/9/04
to
us <u...@neurol.unizh.ch> wrote:

> Peter J. Acklam:
>
> <SNIP 10-bit pgm problem
>
> ...and if MATLAB is still using the code I wrote...
>
> they do, peter, they do:

Evidently so. :-)

0 new messages