[Insight-users] how to fill an image?
Gwenaël Guillard
gwenael.guillard@enst-bretagne.fr
Thu, 05 Dec 2002 18:41:01 +0100
Hi,
I try to fill an image pixel by pixel using the SetPixel method of image
class. To initialize this image I'm trying two way. The second works,
but it needs to have already an image. The first doesn't work. It's
taken from the itkExtractImageTest.cxx file. If I ask to print
Image->GetLargestPossibleRegion().GetSize()[1], it gives me the right
answer, but when I display the image: nothing except black in the image
viewer, with wrong size. For the second method, I have the image I'm
waiting for.
Here is the code for the two methods:
first method:
int width =
m_Laplacian->GetOutput()->GetLargestPossibleRegion().GetSize()[0] ;
int height =
m_Laplacian->GetOutput()->GetLargestPossibleRegion().GetSize()[1] ;
ImageType::IndexType index = {{0, 0}};
ImageType::SizeType size = {{width, height}};
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( index );
m_ZeroCrossing->SetLargestPossibleRegion( region );
m_ZeroCrossing->SetBufferedRegion( region );
m_ZeroCrossing->Allocate();
computation with SetPixel()
second method:
m_ZeroCrossing->SetLargestPossibleRegion(
m_Laplacian->GetOutput()->GetLargestPossibleRegion() ) ;
m_ZeroCrossing->SetBufferedRegion(
m_Laplacian->GetOutput()->GetLargestPossibleRegion() ) ;
m_ZeroCrossing->SetRequestedRegion(
m_Laplacian->GetOutput()->GetLargestPossibleRegion() ) ;
m_ZeroCrossing->Allocate() ;
computation with SetPixel()
Thanks,
Gwenael