[Insight-users] About reading palette-grayscale tiff image
yanqiao zhu
yanqiao.zhu at gmail.com
Fri Jun 17 19:00:26 EDT 2011
Hi everyone,
I think I have made an stupid mistake. Originally I was using *unsigned char
* as the PixelType and then used GetPixel method to obtain
pixel values. While today I tried to use the RGB as pixel type and then
using GetPixel().GetRed() method to read the pixels. And then
basically the problem is solved.
By basically, I mean, most of the pixel values are consistent with the
matlab reading result. While when I counted the number of pixels
with each value, I found that the number of pixels with intensity 32 in itk
is the sum of number of pixels with intensity 32 and 33 from
Matlab. So the result of Matlab is postponed for one since 32. It is like:
Matlab Result: n0 n1 n2 ... n31 n32 n33 n34 ... n253 n254 n255
itk Result: n0 n1 n2 .... n31 n32+n33 n34 n35 ... n254 0
n255
where n0 is the number of pixels with intensity 0, and so on.
I am wondering what may cause this problem.
*Any ideas?*
*
*
*Thanks.*
*Yanqiao*
On Thu, Jun 16, 2011 at 10:57 AM, yanqiao zhu <yanqiao.zhu at gmail.com> wrote:
> Hi folks,
>
>
> Recently I have got problems with reading tiff images. They are grayscale
> image in fact, but mapped to red colors. I
>
> am guessing this is so-called palette-grayscale image. My problem is the
> default reading result of itkTIFFImageIO is
>
> different with that of Matlab. I have counted the number of pixels with
> each possible value, say, from 0 to 255. The
>
> results differs a lot.
>
>
> Actually I think Matlab is right. I used v3d to show the image and observe
> the pixels values. There are pixels values
>
> larger than 200, while the largest possible pixel value I have got from itk
> is only under 100. I have tried to read some
>
> other grayscale images without color mapping, ITK is working fine. So I am
>
> guessing the problem is caused by the color mapping in my tiff image. I
> checked the itkTIFFImageIo file, and found
>
> there some "anonymous enum {NOFORMAT, RGB_, GRAYSCALE, PALETTE_RGB,
> PALETTE_GRAYSCALE,
>
> OTHER}", while I don't know how to use this. Should itk get this
> information correct automatically?
>
>
>
> I have tried to search online and found similar case, but don't see a clear
> solution. Below are the links:
>
>
> http://itk-insight-users.2283740.n2.nabble.com/GetPixel-problem-td6025567.html
> http://www.itk.org/pipermail/insight-users/2005-March/012350.html
>
>
>
> I am a little frustrated. So if you have any idea about this, please help
> me out. Thanks very much!
>
>
> I have attached one sample tiff image for investigation purpose.
>
> Best!
> Yanqiao
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110617/021f13c5/attachment.htm>
More information about the Insight-users
mailing list