<div dir="ltr"><div><div>Hi,<br>the GetDimensions function may be of help. You may want to have a look at the documentation of the class in here:<br><a href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageIOBase.html">http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageIOBase.html</a><br>
<br>A call to GetDimensions( i ) will give you the number of pixels along the specified dimension "i".<br><br></div>Kind regards,<br></div>JON HAITZ<br></div><div class="gmail_extra"><br clear="all"><div><table border="0" cellpadding="0" cellspacing="0" align="center">
<tbody><tr><td><table style="border-width:1px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#00abc9" border="0" cellpadding="0" width="100%"><tbody><tr><td style="border-width:1px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#ffffff">
<div align="left"><a href="http://www.vicomtech.org/" target="_blank"><img src="http://www.vicomtech.es/firmas/html/logovicomtech_150.png" longdesc="http://Visual+Interaction+Communication+Technologies" border="0" height="150" width="211"></a></div>
</td><td style="border-width:0px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#00abc9"><div align="center"><img src="http://www.vicomtech.es/firmas/html/barraSinFondo_150.png" border="0" height="150" width="10"></div>
</td><td style="border-width:0px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#00abc9"><table border="0" cellpadding="0" cellspacing="0" width="100%" align="center"><tbody><tr><td><table border="0" cellpadding="0" align="center">
<tbody><tr><td><span style="font-size:10px;color:white;font-family:Verdana,Arial,Helvetica,sans-serif;font-weight:bold">Jon Haitz Legarreta Gorrońo</span></td></tr><tr><td><span style="font-size:10px;color:white;font-family:Verdana,Arial,Helvetica,sans-serif">Ikertzailea / Investigador / Researcher</span></td>
</tr><tr><td>
<span style="font-size:10px;color:white;font-family:Verdana,Arial,Helvetica,sans-serif">
eOsasuna eta Aplikazio Biomedikoak / eSalud y Aplicaciones Biomedicas / eHealth & Biomedical Applications
</span>
</td></tr><tr><td><table border="0" cellpadding="0" width="100%" align="left"><tbody><tr><td><span style="font-size:10px;color:white;font-family:Verdana,Arial,Helvetica,sans-serif"><a href="http://www.vicomtech.es/castellano/html/contacto/index.html" target="_blank">Donostia - San Sebastián - Spain</a></span></td>
<td rowspan="3" style="border-width:0px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#00abc9" align="right"><div align="right"><a href="http://www.vicomtech.org/" target="_blank"><img src="http://www.vicomtech.es/firmas/html/ojo.png" longdesc="http://Visual+Interaction+Communication+Technologies+-+IK4+Research+Alliance" border="0" height="74" width="104"></a></div>
</td></tr><tr><td><span style="font-size:10px;color:white;font-family:Verdana,Arial,Helvetica,sans-serif">Tel: +[34] 943 30 92 30</span></td></tr><tr><td><span style="font-size:10px;color:blue;font-family:Verdana,Arial,Helvetica,sans-serif"><a href="mailto:jhlegarreta@vicomtech.org" target="_blank">jhlegarreta@vicomtech.org</a></span></td>
</tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td><td style="border-width:0px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#00abc9"><div align="center"><img src="http://www.vicomtech.es/firmas/html/barraSinFondo_150.png" border="0" height="150" width="10"></div>
</td><td style="border-width:1px;border-color:#00abc9;border-collapse:collapse;border-style:solid;background-color:#ffffff"><div align="left"><img src="http://www.vicomtech.es/firmas/html/GraphicsMediaNet-IK4_150.png" longdesc="http://International+Network+for+the+Cooperation+in+Applied+Research+in+Computer+Graphics,+Multimoda-Multimedia+Technologies+and+Visual+Interactive+Digital+Media+Technologies+-+IK4+Research+Alliance" usemap="#SafeHtmlFilter_graphicsmedia-ik4" border="0" height="150" width="211"><map name="SafeHtmlFilter_graphicsmedia-ik4"><area shape="rect" coords="0,0,211,75" href="http://www.ik4.es" target="_blank"><area shape="rect" coords="0,75,211,150" href="http://www.graphicsmedia.net/" target="_blank"></map></div>
</td></tr></tbody></table></td></tr><tr><td><table border="0" cellpadding="0" align="center"><tbody><tr><td><span style="font-size:10px;color:gray;font-family:Verdana,Arial,Helvetica,sans-serif"><a href="http://www.vicomtech.es/castellano/html/informacion_legal/index.html" style="color:gray" target="_blank">Aviso Legal - Política de privacidad</a> / <a href="http://www.vicomtech.es/euskera/html/informacion_legal/index.html" style="color:gray" target="_blank">Lege Oharra - Pribatutasun politika</a> / <a href="http://www.vicomtech.es/ingles/html/informacion_legal/index.html" style="color:gray" target="_blank">Legal Notice - Privacy policy</a></span></td>
</tr></tbody></table></td></tr></tbody></table></div>
<br><br><div class="gmail_quote">On 7 February 2013 09:33, shirani kannangara <span dir="ltr"><<a href="mailto:mangalika673@gmail.com" target="_blank">mangalika673@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Dear insight-users</span><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">It was found difficult to get dimensions in my image data file(.vtk) using vtkImageReader2 Then I tried with ItkImageFileReader .It reads the file.The outputs would like this.<div>
<div>Pixel Type is unsigned_char</div><div>numDimensions:3</div><div>component size:1</div><div>pixeltype<string>:rgb</div><div>pixel type:2</div><div>I need the hole extent of dimensions from the file(that is x=675 y=401 z=450)</div>
<div>What codes should be added to get the hole dimensions.<br> </div><div>My codes are as follows.</div><div><div><br></div><div>#include "itkImage.h"</div><div>#include "itkImageFileReader.h"</div>
<div>
</div><div>template<typename TImageType></div><div>static void ReadFile(std::string filename, typename TImageType::Pointer image);</div><div> </div><div>int main(int argc, char *argv[])</div><div>{</div><div> if(argc < 2)</div>
<div> {</div><div> std::cerr << "Required: filename" << std::endl;</div><div> </div><div> return EXIT_FAILURE;</div><div> }</div><div> std::string inputFilename ="D:\\rgbabdomen\\Debug\\output.vtk" ;</div>
<div> </div><div> typedef itk::ImageIOBase::IOComponentType ScalarPixelType;</div><div> </div><div> itk::ImageIOBase::Pointer imageIO =</div><div> itk::ImageIOFactory::CreateImageIO(</div><div> inputFilename.c_str(), itk::ImageIOFactory::ReadMode);</div>
<div> </div><div> imageIO->SetFileName("D:\\rgbabdomen\\Debug\\output.vtk");</div><div> imageIO->ReadImageInformation();</div><div> const ScalarPixelType pixelType = imageIO->GetComponentType();</div>
<div> std::cout << "Pixel Type is " << imageIO->GetComponentTypeAsString(pixelType) // 'double'</div><div> << std::endl;</div><div> const size_t numDimensions = imageIO->GetNumberOfDimensions();</div>
<div> std::cout << "numDimensions: " << numDimensions << std::endl; // '2'</div><div> </div><div> std::cout << "component size: " << imageIO->GetComponentSize() << std::endl; // '8'</div>
<div> std::cout << "pixel type (string): " << imageIO->GetPixelTypeAsString(imageIO->GetPixelType()) << std::endl; // 'vector'</div><div> std::cout << "pixel type: " << imageIO->GetPixelType() << std::endl; // '5'</div>
<div> </div><div> /*</div><div> switch (pixelType)</div><div> {</div><div> case itk::ImageIOBase::COVARIANTVECTOR:</div><div> typedef itk::Image<unsigned char, 2> ImageType;</div><div> ImageType::Pointer image = ImageType::New();</div>
<div> ReadFile<ImageType>(inputFilename, image);</div><div> break;</div><div> </div><div> typedef itk::Image<unsigned char, 2> ImageType;</div><div> ImageType::Pointer image = ImageType::New();</div>
<div> ReadFile<ImageType>(inputFilename, image);</div><div> break;</div><div> </div><div> default:</div><div> std::cerr << "Pixel Type ("</div><div> << imageIO->GetComponentTypeAsString(pixelType)</div>
<div> << ") not supported. Exiting." << std::endl;</div><div> return -1;</div><div> }</div><div> */</div><div> </div><div> return EXIT_SUCCESS;</div><div>}</div><div> </div><div>
template<typename TImageType></div><div>void ReadFile(std::string filename, typename TImageType::Pointer image)</div><div>{</div><div> typedef itk::ImageFileReader<TImageType> ReaderType;</div><div> typename ReaderType::Pointer reader = ReaderType::New();</div>
<div> </div><div> reader->SetFileName(filename);</div><div> reader->Update();</div><div> </div><div> image->Graft(reader->GetOutput());</div><div>}</div></div><div><br></div><div><br></div><div>Cmake is also attached herewith.</div>
<div><br></div><div>regards</div></div><span class="HOEnZb"><font color="#888888"><div>Shirani</div></font></span></div>
<br>_____________________________________<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>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<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>
<br></blockquote></div><br></div>