Hello,<br><br>I am using ITK for my project and I have wrote the following code.Could somebody tell me how can I get the size of my image?<br><br>Thanks in advance<br><br> typedef unsigned char InputPixelType;<br> typedef unsigned char OutputPixelType;<br>
<br> typedef itk::Image< InputPixelType, 3 > InputImageType;<br> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> reader->SetFileName( fileName.toStdString() );<br>
writer->SetFileName( "2D.png" );<br><br> <br> typedef itk::ExtractImageFilter< InputImageType, OutputImageType > FilterType;<br> FilterType::Pointer filter = FilterType::New();<br><br> reader->Update();<br>
InputImageType::RegionType inputRegion =<br> reader->GetOutput()->GetLargestPossibleRegion();<br><br> InputImageType::SizeType size = inputRegion.GetSize();<br> size[2] = 0; <br> <br> InputImageType::IndexType start = inputRegion.GetIndex();<br>
const unsigned int sliceNumber = 89;<br> start[2] = sliceNumber;<br><br> InputImageType::RegionType desiredRegion;<br> desiredRegion.SetSize( size );<br> desiredRegion.SetIndex( start );<br><br> filter->SetExtractionRegion( desiredRegion );<br>
<br> filter->SetInput( reader->GetOutput() );<br> writer->SetInput( filter->GetOutput() );<br><br> try<br> {<br> writer->Update(); <br> }<br> catch( itk::ExceptionObject & err )<br>
{<br> std::cerr << "ExceptionObject caught !" << std::endl;<br> std::cerr << err << std::endl;<br> }<br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>