Hello,<br><br>I use visualstudio2010 and I am trying to read an image, then extract a region from the image and finally apply a median filter on the image's extracted area, getting the final image using a writer object. I created the four needed objects (reader, region, median filter, writer) as it is shown in the code bellow. But when I built my project, I get the following failure:(<i> 'FilterType' : redefinition; different basic types</i>). I can understand that my wrong was that I used the same FilterType for both <i>itk::RegionOfInterestImageFilter</i> and <i> itk::MedianImageFilter</i>, but I don't know how to solve it. Any ideas?<br>
<br>Thanks in advance.<br><br><br><br>--------------------------code----------------------------<br>----------------------------------------------------<br><br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>
<br>#include "itkRegionOfInterestImageFilter.h"<br>#include "itkMedianImageFilter.h"<br><br><br>#include "itkImage.h"<br><br><br>int main( int argc, char ** argv )<br>{<br> // Verify the number of parameters in the command line<br>
if( argc < 7 )<br> {<br> std::cerr << "Usage: " << std::endl;<br> std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;<br> std::cerr << " startX startY sizeX sizeY" << std::endl;<br>
return EXIT_FAILURE;<br> }<br><br><br> // set pixel and image type<br> typedef unsigned short InputPixelType;<br> typedef unsigned short OutputPixelType;<br> const unsigned int Dimension = 2;<br>
<br> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br><br><br> // set reader and writer object<br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br><br> <span style="background-color: rgb(255, 255, 153);"> typedef itk::RegionOfInterestImageFilter< InputImageType, </span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);"> OutputImageType > FilterType;</span><br><br> FilterType::Pointer region = FilterType::New();<br><br> // Software Guide : BeginCodeSnippet<br>
OutputImageType::IndexType start;<br> start[0] = atoi( argv[3] );<br> start[1] = atoi( argv[4] );<br> // Software Guide : EndCodeSnippet<br><br><br> // start of region<br> OutputImageType::SizeType size;<br> size[0] = atoi( argv[5] );<br>
size[1] = atoi( argv[6] );<br><br><br> // size of region<br> OutputImageType::RegionType desiredRegion;<br> desiredRegion.SetSize( size );<br> desiredRegion.SetIndex( start );<br><br> // Set region of interest<br>
region->SetRegionOfInterest( desiredRegion );<br> <br> // Create reader and writer object<br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> // Set the input and output filename on the reader and writer respectively<br>
const char * inputFilename = argv[1];<br> const char * outputFilename = argv[2];<br><br><br> reader->SetFileName( inputFilename );<br> writer->SetFileName( outputFilename );<br> <br> //////////////////////////////////////////////<br>
//////////////////////////////////////////////<br> // Set and create median filter<br><br><br> <span style="background-color: rgb(255, 255, 153);"> typedef itk::MedianImageFilter<</span><br style="background-color: rgb(255, 255, 153);">
<span style="background-color: rgb(255, 255, 153);"> InputImageType, OutputImageType > FilterType;</span><br><br> FilterType::Pointer filter = FilterType::New();<br><br><br> // set the neighborhood of median filter. Here 3x3.<br>
InputImageType::SizeType indexRadius;<br> <br> indexRadius[0] = 1; // radius along x<br> indexRadius[1] = 1; // radius along y<br><br> filter->SetRadius( indexRadius );<br><br> /////////////////////////////////////////////////<br>
///////////////////////////////////////<br><br> // pipeline <br> region->SetInput( reader->GetOutput() );<br> filter->SetInput( region->GetOutput() );<br> writer->SetInput( filter->GetOutput() );<br>
<br><br><br> // try-catch update of the filters<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> return EXIT_FAILURE;<br> } <br><br><br><br> return EXIT_SUCCESS;<br>}<br><br><br>