[Insight-users] Writing Image Problem
Selim Hasan
selimhasan at gmail.com
Sun May 3 10:09:42 EDT 2009
Hi again,
I added the function that i use to make float number a volume. I tested
this code with adding only one pixel value, but it didnt work.
I cant also write as dicom image, this functions works without error if i
change the final image to .vtk but I can not see anything in the image.
Can someone help me to solve this problem.
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
typedef itk::Image< float, 3 > ImageType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ImageType::Pointer image = ImageType::New();
WriterType::Pointer writer = WriterType::New();
cout<<"MakeImage"<<endl;
ImageType::IndexType start;
ImageType::SizeType size;
size[0] = 144; // size along X
size[1] = 144; // size along Y
size[2] = 60; // size along Z
start[0] = 0; // first index on X
start[1] = 0; // first index on Y
start[2] = 0; // first index on Z
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( start );
image->SetRegions( region );
image->Allocate();
ImageType::PixelType initialValue = 0;
image->FillBuffer( initialValue );
cout<<"MakeImage"<<endl;
ImageType::PixelType pixelValue;
ImageType::IndexType pixelIndex;
pixelIndex[0] = 27; // x position
pixelIndex[1] = 29; // y position
pixelIndex[2] = 37; // z position
pixelValue=0.52356; // TEST
image->SetPixel( pixelIndex, pixelValue );
cout<<"MakeImage"<<endl;
writer->SetInput(image);
writer->SetImageIO(gdcmImageIO);
writer->SetFileName("C:\\selimmingwinput\\test.dcm");
try
{
writer->Update();
}
catch( itk::ExceptionObject & e )
{
std::cerr << "WRITER UPDATE ERROR" << std::endl;
std::cerr << e << std::endl;
}
On Thu, Apr 30, 2009 at 11:19 PM, C.Cagatay Bilgin <bilgic at cs.rpi.edu>wrote:
> Merhaba Selim, follow " 4.1.1 Creating an Image " Software manual to
> create an image.
> Then iterate on the image you just created and follow 4.1.3 Accessing
> Pixel Data
> to write the pixel values you read from the text file. Make sure the
> spacing
> values and the order you iterate (row,col,depth vs col,row,depth...)are
> consistent
> with the given input.
>
> Regards,
> C. Cagatay Bilgin
>
> On Apr 30, 2009, at 3:04 AM, Selim Hasan wrote:
>
> Hello all,
>
> I have a problem for writing an image(3D). I have an 144*144*60 values
> inside a 3-D image, those values are writen in a txt file.
>
> I need to write a program that takes this .txt fıle as an input and writes
> the volume basically having the same image again. This input comes from an
> another software.
>
> Does anyone know how to write this to an image?
> Thank You
>
> --
> Selim Hasan
>
> Yeditepe University
> Computer Science Engineering
>
> selimhasan at gmail.com
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
--
Selim Hasan
Yeditepe University
Computer Science Engineering
selimhasan at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090503/991f840a/attachment.htm>
More information about the Insight-users
mailing list