[Insight-users] problem with defining public Filter objects
Seniha Esen Yuksel
eseny99 at yahoo.com
Mon Aug 29 00:08:57 EDT 2005
Hi all,
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.
//------------------------------------------------------------------------------
//part of the code from my .h file:
//------------------------------------------------------------------------------
public:
// ........
//===================
//My ITK Object Pointers
//===================
typedef int integer;
typedef unsigned short PixelType;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef itk::Image< InputPixelType, 2 > InputImageType;
typedef itk::Image< OutputPixelType, 2 > OutputImageType;
typedef itk::RegionOfInterestImageFilter<InputImageType, OutputImageType > FilterType;
typedef itk::ImageFileWriter< OutputImageType> WriterTypeGL;
FilterType::Pointer filter;
WriterTypeGL::Pointer writergl;
InputImageType::RegionType regionGL;
// ........
//------------------------------------------------------------------------------
//-------------------- part of my c++ code --------------------------
int FrontDialog::CropImage(){
//...........................
writerMoving->SetFileName( output.c_str() );
writerMoving->SetInput( cropMoving->GetOutput() );
try {
writerMoving->Update();
} catch (itk::ExceptionObject &err) {
std::cout<< "Exception caught:" << std::endl;
std::cout<< err <<std::endl;
return -1;
}
//here I definitely know that cropMoving->GetOutput() gives correct results
//because I am able to save it as an image. However, I also want to save it in a
//public variable to use over and over.
//here comes the part which fails:
regionGL.SetSize(Width, Height);
regionGL.SetIndex(0,0);
filter = FilterType::New();
filter->SetRegionOfInterest(regionGL);
filter->SetInput( crop->GetOutput());
try {
filter->Update();
} catch (itk::ExceptionObject &err) {
std::cout<< "Exception caught:" << std::endl;
std::cout<< err <<std::endl;
return -1;
}
filter->GetOutput()->Print( std::cout );
//.............
return 0;
}
//-------------------------------------------------------------------
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...
Thanks a lot in advance,
Seniha
This program resizes the input file with the following parameters
x starting value: 300
y starting value: 300
x extension : 200
y extension : 200
===========================
images are cropped
Image (02695AA0)
RTTI typeinfo: class itk::Image<unsigned char,2>
Reference Count: 1
Modified Time: 236
Debug: Off
Observers:
none
Source: (02695B90)
Source output index: 0
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 222
UpdateMTime: 237
LargestPossibleRegion:
Dimension: 2
Index: [0, 0]
Size: [0, 0]
BufferedRegion:
Dimension: 2
Index: [0, 0]
Size: [0, 0]
RequestedRegion:
Dimension: 2
Index: [0, 0]
Size: [0, 0]
Spacing: [1, 1]
Origin: [300, 300]
PixelContainer:
ImportImageContainer (02694BE0)
RTTI typeinfo: class itk::ImportImageContainer<unsigned long,unsigned ch
ar>
Reference Count: 1
Modified Time: 235
Debug: Off
Observers:
none
Pointer: 02694C10
Container manages memory: true
Size: 0
Capacity: 0
Exception caught:
itk::ExceptionObject (0109E4C0)
Location: "Unknown"
File: C:\ITK\InsightToolkit-2.0.0\InsightToolkit-2.0.0\Code\IO\itkPNGImageIO.cxx
Line: 395
Description: itk::ERROR: PNGImageIO(026955F0): PNG Writer can only write 2-dimen
sional images
Seniha Esen Yuksel
Research Assistant
Computer Vision and Image Processing Lab,
Lutz Hall Rm 414,
University of Louisville,
Louisville, KY
work ph: 502- 8521528
home ph: 502- 8549856
email: esen at cvip.uofl.edu // esenyuksel at ieee.org
web: http://www.cvip.louisville.edu/~esen/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050828/b765de0c/attachment.html
More information about the Insight-users
mailing list