[Insight-users] Exporting RGB-Quad Data to itk::Image

Dan Mueller dan.muel at gmail.com
Thu Sep 23 15:59:18 EDT 2010


Hi Christian,

Consider using itk::Image<RGBPixel<unsigned char>, 2>. You will have
to use iterators to "swizzle" [1] BGR to RGB and skip the "reserved"
byte (which the documentation says is zero).

Alternatively you could import the buffer directly into
itk::Image<RGBAPixel<unsigned char>, 2> but B-R will be swapped, and A
will be zero...

HTH

Cheers, Dan

[1] http://en.wikipedia.org/wiki/Swizzling_%28computer_graphics%29

On 23 September 2010 14:57, Christian Werner
<christian.werner at rwth-aachen.de> wrote:
>  Hi there!
>
> I see that you can assign a pointer to some image data in memory to an
> itk::Image instance. What should I do, if my data is an RGB-Quad Array? The
> thing is that I am doing a screenshot in a Win32 environment and want to do
> image analysis on a part of that screenshot with ITK. If you wonder how a
> RGB-Quad looks like, this is what the MSDN-Library tells us:
>
> typedef struct tagRGBQUAD {
>  BYTE rgbBlue;
>  BYTE rgbGreen;
>  BYTE rgbRed;
>  BYTE rgbReserved;
> } RGBQUAD;
>
> The data of my screenshot is here:
>
> RGBQUAD*            colorData_;
>
> Should I create a itk::Image<unsigned char[4], 2>? Or should I use the
> itk-iterators to write the image data pixel by pixel into my itk::Image?
>
> Best regards,
> Christian


More information about the Insight-users mailing list