<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Selim I guess the code you provide solves <div>your initial problem if the pixel type is not </div><div>float. When set to float I believe this is the </div><div>error you are getting. </div><div><br><div><div>you might be getting </div><div>itk::ExceptionObject (0x569c90)</div><div>Location: "virtual void itk::GDCMImageIO::Write(const void*)" </div><div>File: /Users/bilgic/opt/itkSrc/Code/IO/itkGDCMImageIO.cxx</div><div>Line: 1246</div><div>Description: itk::ERROR: GDCMImageIO(0x5690c0): DICOM does not support this component type</div><div><br></div><div><br></div><div>I have not worked on Dicom files before and dont know the </div><div>status of it in ITK but a search on google gives this </div><div><br></div><div><a href="http://www.itk.org/pipermail/insight-users/2008-October/027467.html">http://www.itk.org/pipermail/insight-users/2008-October/027467.html</a></div><div>apparently float is not supported. </div><div><br></div><div>Cagatay Bilgin</div><div><br></div></div><div><br><div><div>On May 3, 2009, at 10:09 AM, Selim Hasan wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi again,</div><div><br></div><div><br></div><div>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.</div><div>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.</div> <div><br></div><div>Can someone help me to solve this problem.</div><div><br></div><div> typedef itk::GDCMImageIO ImageIOType;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div> <span class="Apple-tab-span" style="white-space:pre">                </span>ImageIOType::Pointer gdcmImageIO = ImageIOType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>typedef itk::Image< float, 3 > ImageType;</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>typedef itk::ImageFileWriter< ImageType > WriterType;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::Pointer image = ImageType::New();</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>WriterType::Pointer writer = WriterType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cout<<"MakeImage"<<endl;</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::IndexType start;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::SizeType size;</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>size[0] = 144; // size along X</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>size[1] = 144; // size along Y</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>size[2] = 60; // size along Z</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>start[0] = 0; // first index on X</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>start[1] = 0; // first index on Y</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>start[2] = 0; // first index on Z</div><div> <span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::RegionType region;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>region.SetSize( size );</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>region.SetIndex( start );</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>image->SetRegions( region );</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>image->Allocate();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::PixelType initialValue = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>image->FillBuffer( initialValue );</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>cout<<"MakeImage"<<endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::PixelType pixelValue;</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>ImageType::IndexType pixelIndex;</div><div> </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pixelIndex[0] = 27; // x position</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>pixelIndex[1] = 29; // y position</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pixelIndex[2] = 37; // z position</div><div> <span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pixelValue=0.52356; // TEST </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>image->SetPixel( pixelIndex, pixelValue );</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span>cout<<"MakeImage"<<endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>writer->SetInput(image);</div><div> writer->SetImageIO(gdcmImageIO);<br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>writer->SetFileName("C:\\selimmingwinput\\test.dcm");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div> <div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div> <span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>try</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>{</div><div> <span class="Apple-tab-span" style="white-space:pre">                        </span>writer->Update();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> catch( itk::ExceptionObject & e )</div> <div><span class="Apple-tab-span" style="white-space:pre">                        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>std::cerr << "WRITER UPDATE ERROR" << std::endl;</div><div> <span class="Apple-tab-span" style="white-space:pre">                        </span>std::cerr << e << std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div> <div><span class="Apple-tab-span" style="white-space:pre">                </span></div><br><div class="gmail_quote">On Thu, Apr 30, 2009 at 11:19 PM, C.Cagatay Bilgin <span dir="ltr"><<a href="mailto:bilgic@cs.rpi.edu">bilgic@cs.rpi.edu</a>></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">Merhaba Selim, <div>follow " <span style="font-size:11px">4.1.1 Creating an Image <span style="font-size:12px">" Software manual to create an image. </span></span></div> <div>Then iterate on the image you just created and follow <span style="font-size:11px">4.1.3 Accessing Pixel Data <span style="font-size:12px"></span></span></div><div><span style="font-size:11px"><span style="font-size:12px">to write the pixel values you read from the text file. Make sure the spacing </span></span></div> <div>values and the order you iterate (row,col,depth vs col,row,depth...)are consistent </div><div>with the given input. </div><div><br></div><div>Regards, </div><div>C. Cagatay Bilgin</div><div><br><div><div><div></div><div class="h5"> <div>On Apr 30, 2009, at 3:04 AM, Selim Hasan wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5"><div>Hello all,</div> <div> </div> <div>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.</div> <div> </div> <div>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.</div> <div> </div> <div>Does anyone know how to write this to an image?<br clear="all"> </div> <div>Thank You</div> <div></div><br>-- <br>Selim Hasan<br><br>Yeditepe University<br>Computer Science Engineering<br><br><a href="mailto:selimhasan@gmail.com" target="_blank">selimhasan@gmail.com</a><br></div></div> _____________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br> <br>Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br> </blockquote></div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Selim Hasan<br><br>Yeditepe University<br>Computer Science Engineering<br><br><a href="mailto:selimhasan@gmail.com">selimhasan@gmail.com</a><br> _____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></div></body></html>