[Insight-users] problems to mark with coloured pixels

Kevin H. Hobbs hobbsk at ohiou.edu
Fri Sep 4 10:45:55 EDT 2009


My comments are below.

On Fri, 2009-08-21 at 01:39 -0700, c23562 wrote:
> Hello,
> 
> I try to mark some Pixels/Voxels in an originally grey image. Unfortunalty
> there is no marked index in my new image. What is wrong with my code? Did I
> forget something?
> 
> 
> First I create a ReaderType for reading a 3D-Image of floats (grey).
<snip>
> 
> Then I also create a RGBPixelTye and a FileWriter for writing the new file.
<snip>
> After that I use a caster from ReaderImageType to RGBImageType.

You cannot do this directly.

> Now I have a casted image from float to rgb in "image".
> I  make a coloured pixel and put it into the casted image on a certain
> index:
<snip>
> Whats wrong?

The problem is that you cannot simply cast a single component float
image to an unsigned char RGB image.

You must first use the RescaleIntensityImageFilter to convert your input
float image with whatever intensity range it has, to an unsigned char
image with the range 0 to 255.

Then you must use the ComposeRGBImageFilter to set all three components
of the RGB image. That is :

RGB_composer->SetInput1( rescaled_char_image );
RGB_composer->SetInput2( rescaled_char_image );
RGB_composer->SetInput3( rescaled_char_image );

At this point the output of the ComposeRGBImageFilter will be a RGB
image that looks grayscale. 

But it's output "knows" that it is part of a pipeline, and since you
want to change pixel values you must disconnect it from the pipeline.

RGB_composer->Update();
RGB_image = RGB_composer->GetOutput();
RGB_image->DisconnectPipeline();

Now you can mess with the pixels you want to mark and set the image as
the input to a writer.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090904/ddb4549d/attachment.pgp>


More information about the Insight-users mailing list