[Insight-users] itkDeformableTest.

Waltraud Henrich henrich@ira.uka.de
Thu, 30 Jan 2003 09:48:19 +0100


Hello

How can I work with a binary image and the original image? 
In your example the image already exist .I transform the images from vtk to
itk. The binary image can be accessed by itkImporter1->GetOutput() and the
origal image can be accessed by itkImporter->GetOutput().

As I didn't understand the following lines of code in your example
completely, I would ask you to tell me whether my interpretation is correct:
  1  size[0] = 36;
  2: size[1] = 36;
  3: size[2] = 36;

  4: start[0] = 18;
  5: start[1] = 18;
  6: start[2] = 18;

Interpretation: 
Do 1-3 represent the size of the bounding box / search region?
Do 4-6 represent the origin of the bounding box / search region?

It would be a great help for me if you could arrange to take a look at the
following piece of code. It's almost completely your example, except the
market(*) lines.



   *	binaryImageType::Pointer       biimg = itkImporter1->GetOutput();
//=binaryImageType::New();
	myGradientImageType::Pointer   gdimg=myGradientImageType::New();
	
	typedef itk::ImageRegionIteratorWithIndex<myImageType>
myIteratorType;
	typedef itk::ImageRegionIteratorWithIndex<myGradientImageType>
myGradientIteratorType;
	
	binaryImageType::SizeType      bisize={{WIDTH,HEIGHT,DEPTH}};
	binaryImageType::IndexType     biindex;
	binaryImageType::RegionType    biregion;
	biindex.Fill(0);
	biregion.SetSize(bisize);
	biregion.SetIndex(biindex);
	
	myGradientImageType::SizeType   gdsize={{WIDTH,HEIGHT,DEPTH}};
	myGradientImageType::IndexType  gdindex;
	myGradientImageType::RegionType gdregion;
	gdindex.Fill(0);
	gdregion.SetSize(gdsize);
	gdregion.SetIndex(gdindex);
	
	biimg->SetLargestPossibleRegion( biregion );
	biimg->SetBufferedRegion( biregion );
	biimg->SetRequestedRegion( biregion );
	biimg->Allocate();
	
	gdimg->SetLargestPossibleRegion( gdregion );
	gdimg->SetBufferedRegion( gdregion );
	gdimg->SetRequestedRegion( gdregion );
	gdimg->Allocate();
	
	// image
   *	myImageType::Pointer inputImage  =
itkImporter->GetOutput();//myImageType::New();
	
	mySizeType size={{WIDTH,HEIGHT,DEPTH}};
	myIndexType start;
	start.Fill(0);
	
	myRegionType region;
	region.SetIndex( start );
	region.SetSize( size );
	
	// Initialize Image A
	inputImage->SetLargestPossibleRegion( region );
	inputImage->SetBufferedRegion( region );
	inputImage->SetRequestedRegion( region );
	inputImage->Allocate();
	
	itk::ImageRegionIteratorWithIndex <myImageType> it(inputImage,
region);
	it.GoToBegin();
	itk::ImageRegionIteratorWithIndex <binaryImageType> bit(biimg,
biregion);
	bit.GoToBegin();
	
	
	while( !it.IsAtEnd() ) 
	{
		it.Set( 0.0 );
		bit.Set( 0 );
		++it;
		++bit;
	}
	
 *	size[0] = 20; 
  *	size[1] = 20; 
  *	size[2] = 6; 
	
  *	start[0] = 232;
  *	start[1] = 119;
  *	start[2] = 0;
	
	// Create one iterator for an internal region
	region.SetSize( size );
	region.SetIndex( start );
	biregion.SetSize( size );
	biregion.SetIndex( start );
	itk::ImageRegionIteratorWithIndex <myImageType> itb( inputImage,
region );
	itk::ImageRegionIteratorWithIndex <binaryImageType> bitb( biimg,
biregion );
	
	// Initialize the content the internal region
	while( !itb.IsAtEnd() ) 
	{
		itb.Set( 100.0 );
		bitb.Set ( 255 );
		++itb;
		++bitb;
	}
	


Thanks in advance.

Waltraut