[Insight-users] Writing Image Problem
C.Cagatay Bilgin
bilgic at cs.rpi.edu
Mon May 4 12:03:51 EDT 2009
Selim I guess the code you provide solves
your initial problem if the pixel type is not
float. When set to float I believe this is the
error you are getting.
you might be getting
itk::ExceptionObject (0x569c90)
Location: "virtual void itk::GDCMImageIO::Write(const void*)"
File: /Users/bilgic/opt/itkSrc/Code/IO/itkGDCMImageIO.cxx
Line: 1246
Description: itk::ERROR: GDCMImageIO(0x5690c0): DICOM does not support
this component type
I have not worked on Dicom files before and dont know the
status of it in ITK but a search on google gives this
http://www.itk.org/pipermail/insight-users/2008-October/027467.html
apparently float is not supported.
Cagatay Bilgin
On May 3, 2009, at 10:09 AM, Selim Hasan wrote:
> 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
> _____________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090504/c4815aed/attachment.htm>
More information about the Insight-users
mailing list