[Insight-users] SetPixel value.

Javier González González-Zabaleta jgonzabal at gmail.com
Thu Oct 30 07:47:46 EDT 2008


Hi,

my name's Javier González and I'm working with ITK, VTK y MFC on C++ for 7
months. I'm trying to make changes in a 2D image to make a graph. I only
need put some point and maybe some lines. I'm using SetPixel(...,...) but
when I show my image It has not changed. ¿May I use another method? My code
is:

------------------------------------------------------------------------------------------------------------------------------------------
const char * inputFilename  = "D:/fondografica.jpg";
reader = ReaderType::New();
reader->SetFileName( inputFilename );
ImageType::Pointer newimage = reader->GetOutput();
ImageType::SizeType size;
    size[0] = 255; // size along X
    size[1] = 255; // size along Y
ImageType::IndexType start;
    start[0] = 0; // first index on X
    start[1] = 0; // first index on Y
ImageType::RegionType region;
    region.SetSize( size );
    region.SetIndex( start );
newimage->SetRegions(size);
newimage->Allocate();

ImageType::Pointer image = this->pitkDICOM5->GetOutput();
ImageType::IndexType pixelValue1;
    pixelValue1[0] = 80;
    pixelValue1[1] = 80;
image = this->pitkDICOM4->GetOutput();
ImageType::IndexType pixelValue2;
    pixelValue2[0] = 125;
    pixelValue2[1] = 125;
image = this->pitkDICOM3->GetOutput();
ImageType::IndexType pixelValue3;
    pixelValue3[0] = 170;
    pixelValue3[1] = 170;
image = this->pitkDICOM1->GetOutput();
ImageType::IndexType pixelValue4;
    pixelValue4[0] = 215;
    pixelValue4[1] = 215;

    newimage->SetPixel(pixelValue1, 0);
    newimage->SetPixel(pixelValue2, 0);
    newimage->SetPixel(pixelValue3, 0);
    newimage->SetPixel(pixelValue4, 0);

    return newimage;
------------------------------------------------------------------------------------------------------------------------------------------

Thans for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081030/43acfe20/attachment-0001.htm>


More information about the Insight-users mailing list