<DIV>
<DIV>Hi all,</DIV>
<DIV>I want to define a public filter in my function which I will use as a buffer to hold my images, but I am getting an exception error. Actually even before the exception error, I can see that the output of the filter is empty, which makes me think that I am defining the RegionType in a wrong way -- could you please particularly look at that and tell me if it is correct? I am copying parts of the code below from the header file and the c++ file. </DIV>
<DIV> </DIV>
<DIV>
<DIV>//------------------------------------------------------------------------------</DIV></DIV>
<DIV>//part of the code from my .h file:</DIV>
<DIV>
<DIV>//------------------------------------------------------------------------------</DIV>
<DIV> </DIV></DIV>
<DIV>public:</DIV>
<DIV> </DIV>
<DIV>// ........</DIV>
<DIV> </DIV>
<DIV>//===================<BR>//My ITK Object Pointers<BR>//===================<BR> <BR> typedef int integer;<BR> typedef unsigned short PixelType;</DIV>
<DIV> typedef unsigned char InputPixelType;<BR> typedef unsigned char OutputPixelType;<BR> typedef itk::Image< InputPixelType, 2 > InputImageType;<BR> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<BR> typedef itk::RegionOfInterestImageFilter<InputImageType, OutputImageType > FilterType;<BR> typedef itk::ImageFileWriter< OutputImageType> WriterTypeGL;</DIV>
<DIV><BR> FilterType::Pointer filter; <BR> WriterTypeGL::Pointer writergl;</DIV>
<DIV> </DIV>
<DIV> InputImageType::RegionType regionGL;</DIV>
<DIV>// ........</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>//------------------------------------------------------------------------------</DIV>
<DIV>//-------------------- part of my c++ code --------------------------</DIV>
<DIV> </DIV>
<DIV>int FrontDialog::CropImage(){</DIV>
<DIV> </DIV>
<DIV>//...........................</DIV>
<DIV> </DIV>
<DIV> writerMoving->SetFileName( output.c_str() );<BR> writerMoving->SetInput( cropMoving->GetOutput() );<BR> try {<BR> writerMoving->Update();<BR> } catch (itk::ExceptionObject &err) {<BR> std::cout<< "Exception caught:" << std::endl;<BR> std::cout<< err <<std::endl;<BR> <BR> return -1;<BR> }</DIV>
<DIV> </DIV>
<DIV>//here I definitely know that cropMoving->GetOutput() gives correct results</DIV>
<DIV>//because I am able to save it as an image. However, I also want to save it in a</DIV>
<DIV>//public variable to use over and over.</DIV>
<DIV> </DIV>
<DIV>//here comes the part which fails:</DIV>
<DIV> </DIV>
<DIV> regionGL.SetSize(Width, Height);<BR> regionGL.SetIndex(0,0);</DIV>
<DIV><BR> filter = FilterType::New();<BR> filter->SetRegionOfInterest(regionGL);<BR> filter->SetInput( crop->GetOutput());<BR> try {<BR> filter->Update();<BR> } catch (itk::ExceptionObject &err) {<BR> std::cout<< "Exception caught:" << std::endl;<BR> std::cout<< err <<std::endl;<BR> <BR> return -1;<BR> }</DIV>
<DIV><BR> filter->GetOutput()->Print( std::cout );</DIV>
<DIV> </DIV>
<DIV>//.............</DIV>
<DIV>return 0;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>//-------------------------------------------------------------------</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>
<DIV>I spent too much time to figure out this problem but I am now clueless on what to do. The output of the exe file is as below. I will really appreciate it a lot if anyone could help me...</DIV>
<DIV>Thanks a lot in advance,</DIV>
<DIV>Seniha</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>This program resizes the input file with the following parameters<BR>x starting value: 300<BR>y starting value: 300<BR>x extension : 200<BR>y extension : 200<BR>===========================</DIV>
<DIV>images are cropped</DIV>
<DIV>Image (02695AA0)<BR> RTTI typeinfo: class itk::Image<unsigned char,2><BR> Reference Count: 1<BR> Modified Time: 236<BR> Debug: Off<BR> Observers:<BR> none<BR> Source: (02695B90)<BR> Source output index: 0<BR> Release Data: Off<BR> Data Released: False<BR> Global Release Data: Off<BR> PipelineMTime: 222<BR> UpdateMTime: 237<BR> LargestPossibleRegion:<BR> Dimension: 2<BR> Index: [0, 0]<BR> Size: [0, 0]<BR> BufferedRegion:<BR> Dimension: 2<BR> Index: [0, 0]<BR> Size: [0, 0]<BR> RequestedRegion:<BR> Dimension: 2<BR> Index: [0, 0]<BR> Size: [0, 0]<BR> Spacing: [1, 1]<BR> Origin: [300, 300]<BR> PixelContainer:<BR> ImportImageContainer
(02694BE0)<BR> RTTI typeinfo: class itk::ImportImageContainer<unsigned long,unsigned ch<BR>ar><BR> Reference Count: 1<BR> Modified Time: 235<BR> Debug: Off<BR> Observers:<BR> none<BR> Pointer: 02694C10<BR> Container manages memory: true<BR> Size: 0<BR> Capacity: 0<BR>Exception caught:</DIV>
<DIV>itk::ExceptionObject (0109E4C0)<BR>Location: "Unknown"<BR>File: C:\ITK\InsightToolkit-2.0.0\InsightToolkit-2.0.0\Code\IO\itkPNGImageIO.cxx</DIV>
<DIV>Line: 395<BR>Description: itk::ERROR: PNGImageIO(026955F0): PNG Writer can only write 2-dimen<BR>sional images</DIV>
<DIV><BR> </DIV></DIV></DIV><BR><BR><DIV>Seniha Esen Yuksel <BR>Research Assistant <BR>Computer Vision and Image Processing Lab, <BR>Lutz Hall Rm 414, <BR>University of Louisville, <BR>Louisville, KY <BR>work ph: 502- 8521528 <BR>home ph: 502- 8549856 <BR>email: esen@cvip.uofl.edu // esenyuksel@ieee.org <BR>web: <A href="http://www.cvip.louisville.edu/~esen/">http://www.cvip.louisville.edu/~esen/</A></DIV><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam? Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com