[Insight-users] Paste Image Filter
alexandre govignon
govignon.alexandre at gmail.com
Thu Jul 31 10:26:34 EDT 2008
Hi Luis i try to use the PasteImageFilter...
But there is no effect on the image...
In the following lines i have written my function.
Please help me...
void CDose::Padder2D(string Path1)
{
ImageType2D::Pointer InImage=ImageType2D::New();
ReaderType2D::Pointer reader=ReaderType2D::New();
WriterType2D::Pointer writer=WriterType2D::New();
reader->SetFileName(Path1);
try
{
reader->Update();
InImage=reader->GetOutput();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "exception in file reader " << std::endl;
std::cerr << e << std::endl;
}
ImageType2D::RegionType Region = (InImage->GetRequestedRegion());
ImageType2D::SizeType size;
ImageType2D::IndexType index;
index[ 0] = Region.GetIndex()[0 ];
index[ 1] = Region.GetIndex()[1 ];
size[ 0] = Region.GetSize()[0 ];
size[ 1] = Region.GetSize()[1 ];
int DimX=size[0];
int DimY=size[1];
int DX=0;
int DY=0;
cout << DimX << " " << DimY << endl;
for(int i=1;i<18;i++)
{
if(DimX>=pow(2.0,i) && DimX<pow(2.0,i+1))
{
DX=pow(2.0,i+1);
}
}
DimY=reader->GetOutput()->GetBufferedRegion().GetSize()[1];
for(int i=1;i<18;i++)
{
if(DimY>=pow(2.0,i) && DimY<pow(2.0,i+1))
{
DY=pow(2.0,i+1);
}
}
cout << DX << " " << DY << endl;
Image2D::Pointer PaddedImage=Image2D::New();
Image2D::RegionType Region1;
Image2D::IndexType index1=index;
Image2D::SizeType size1={{DimX,DimY}};
Region1.SetSize( size1);
Region1.SetIndex(index);
PaddedImage->SetLargestPossibleRegion(Region1);
PaddedImage->SetBufferedRegion(Region1);
PaddedImage->Allocate();
PaddedImage->FillBuffer(0);
IteratorType2D It( PaddedImage,Region1 );
for(;!It.IsAtEnd();++It)
{
It.Set(0);
}
PastType::Pointer PastPadFilter =PastType::New();
PastPadFilter->SetInput(PaddedImage);
PastPadFilter->SetSourceImage(InImage);
PastPadFilter->SetDestinationIndex( index1 );
PastPadFilter->SetSourceRegion(Region);
PastPadFilter->Update();
PaddedImage=PastPadFilter->GetOutput();
WriterType2D::Pointer writer1 = WriterType2D::New();
writer1->SetFileName( Path1 );
writer1->SetInput(PaddedImage );
try
{
writer1->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
}
--
Cordialement,
Alexandre Govignon.
More information about the Insight-users
mailing list