[Dcmlib] FileHelper->GetImageData()

Jean-Pierre Roux jpr at creatis.insa-lyon.fr
Mon Sep 5 17:23:03 CEST 2005


Greg Book wrote:

> So, regardless of whether SamplesPerPixel is 1 or 3, GetImageData() 
> always returns RGB, RGB, RGB...? So if its a monochrome image, each 
> RGB set will be R=G=B? and then for palette images, it will be 
> expanded to RGB.

--> For palette images, the 'raw image + Palettes' is expanded to RGB, 
RGB, RGB...
--> For monochrome images there is not expansion (grey grey grey ... 
-stored or 8 bits or 16 bits, according to the 'Bits Allocated' field-)

--> MONOCHROME1 (high values = dark, low values = bright) are 
automatiquely turned as if they were MONOCHROME2 (high values = bright 
low values = dark, that's the most usual acceptation), so user don't 
have to worry about it.
JP

>
> -Greg
>
>
> Jean-Pierre ROUX wrote:
>
>> At 21:54 -0400 4/09/05, Greg Book wrote:
>>
>>> Thanks for the info. That function will be very helpful. So, what 
>>> happens if 'samples per pixel' is not 3? I would assume it's 1 when 
>>> its a monochrome image?
>>
>>
>>
>> 'Sample Per Pixel' is a mandatory Dicom field.
>> It can contain only 1 (monochrome image, or palette color image) or 3 
>> (RGB or YBR images)
>>
>>> If thats the case, are monochrome images ever compressed, and if so, 
>>> how would they be read using gdcm.
>>
>>
>>
>> Any kind of image may be compressed or not.
>> gdcm users don't have to worry about compression.
>> Just write, as for any image:
>>
>> gdcm::File *f = new gdcm::File();
>> f->SetFileName(yourFileName);
>> f->Load(); // Load the header;
>>
>> if (!f->IsReadable())
>> {
>>   --> stop everything :-(
>> }
>>
>> gdcm::FileHelper *fh = new gdcm::FileHelper(f);
>> uint8_t *imageData;
>>
>> imageData = fh->GetImageData();
>>
>> The pixels are now loaded in memory, line by line, RGB, RGB, RGB ..., 
>> if it's a color image.
>>
>> According to what you found in f, you decide how you must cast.
>>
>> JP
>>
>>
>>
>>
>>>
>>> -Greg
>>>
>>>
>>> Jean-Pierre ROUX wrote:
>>>
>>>> At 14:04 -0400 2/09/05, Greg Book wrote:
>>>>
>>>>> I'm interested in using the GetImageData() function to read my 
>>>>> files instead of reading them by opening them and reading the 
>>>>> bytes. Once you've called this function and have an array of 
>>>>> unsigned integers... how is that array structured?
>>>>> Is it one byte for R, G, B? so 3 bytes per pixel? Then I assume 
>>>>> line breaks occur at pixel (3 byte) boundaries? So to read a 
>>>>> 100x100pixel image, I'd take the first 300 bytes of the buffer 
>>>>> returned from GetImageData as the first line of the image, then 
>>>>> get the next 300 for the next line, and so on?
>>>>
>>>>
>>>>
>>>>
>>>> You're absolutely right.
>>>> In Dicom, there are 2 possibilities for RGB images :
>>>> - Storing 'Plane R + Plage G + Plane B'
>>>> - Storing pixels RGB RGB RGB ...
>>>>
>>>> We choosed to convert them as RGB RGB RGB ...
>>>> (we convert YBR to RGB too).
>>>>
>>>> Just be sure that field 'Samples per Pixel' value is 3.
>>>> JP
>>>>
>>>>>
>>>>> Thanks,
>>>>> Greg
>>>>> _______________________________________________
>>>>> Dcmlib mailing list
>>>>> Dcmlib at creatis.insa-lyon.fr
>>>>> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>>>>
>>>>
>>>>
>>>>
>>>> Jean-Pierre ROUX
>>>> CREATIS - CNRS UMR 5515, INSERM U 630
>>>> Laboratoire de Radiologie Experimentale
>>>> Hopital Cardiologique
>>>> 28 Avenue du Doyen LEPINE
>>>> B.P. Lyon-Montchat
>>>> 69394 Lyon Cedex 03
>>>>
>>>> Tel      : (+33) 04 72 35 74 12
>>>> Fax      : (+33) 04 72 68 49 16
>>>> URL      : http://www.creatis.univ-lyon1.fr
>>>> e-mail   : jpr at creatis.univ-lyon1.fr
>>>>
>>
>>   Jean-Pierre ROUX
>>   CREATIS - CNRS UMR 5515, INSERM U 630
>>   Laboratoire de Radiologie Experimentale
>>   Hopital Cardiologique
>>   28 Avenue du Doyen LEPINE
>>   B.P. Lyon-Montchat
>>   69394 Lyon Cedex 03
>>
>>   Tel      : (+33) 04 72 35 74 12
>>   Fax      : (+33) 04 72 68 49 16
>>   URL      : http://www.creatis.univ-lyon1.fr
>>   e-mail   : jpr at creatis.univ-lyon1.fr
>>                                   
>
>
>
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>



More information about the Dcmlib mailing list