[Insight-users] problems to mark with coloured pixels

c23562 c.popko at gmx.de
Fri Aug 21 04:39:16 EDT 2009


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).

        const unsigned int Dimension = 3;
        typedef float PixelType; 
        typedef itk::Image< PixelType, Dimension >  ReaderImageType;
        typedef itk::ImageFileReader< ReaderImageType  > ReaderType;
        ReaderType::Pointer reader = ReaderType::New();

Then I also create a RGBPixelTye and a FileWriter for writing the new file.

        typedef itk::RGBPixel< unsigned char > RGBPixelType;
        typedef itk::Image<RGBPixelType, Dimension>     RGBImageType;

        typedef itk::ImageFileWriter< RGBImageType > FileWriterType;
        FileWriterType::Pointer writer = FileWriterType::New();
       

After that I use a caster from ReaderImageType to RGBImageType.

        typedef itk::CastImageFilter< ReaderImageType, RGBImageType>
CastFilterType;
        CastFilterType::Pointer caster = CastFilterType::New();
        caster->SetInput( reader->GetOutput() );

Then:

        caster->Update();
        RGBImageType::Pointer image = caster->GetOutput();


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:

        RGBImageType::PixelType myPixel;

        myPixel.SetRed(255);
        myPixel.SetGreen(0);
        myPixel.SetBlue(0);

  image->SetPixel(markerIndex, myPixel);

        writer->SetImput( image );
        writer->update();

Whats wrong?

Greetings,
Christian
-- 
View this message in context: http://www.nabble.com/problems-to-mark-with-coloured-pixels-tp25075912p25075912.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list