[Insight-users] Generating coocurence feature maps for 2D images

Sachin Jambawalikar sachinjam at gmail.com
Thu Mar 3 19:13:33 EST 2005


Hi all,

Especially Luis, Zachary Pincus and Glenn Pierce

I'm trying to use the  itkScalarImageTextureCalculator class 
 to compute texture features for an image slice.
However instead of finding  one mean  feature value(energy entropy
etc) for the 2D image I  am trying to find  the same for a 5x5 window
. Similar to convolution but here the glcm and the features are
computed for  each of the windowed subimages and the center pixel is
replaced by the feature value. However this  seems to be
computationally expensive  for my  image of 512*512  . Can any one
suggest a faster way of computing the cooccurence feature maps or tell
me what I'm doing wrong in my code


ImagePointer2D ComputeNeighboorhoodConvolution(ImagePointer2D inimage)
{
typedef itk::Image<double,2> InternalPixelType;
InternalPixelType::Pointer output = InternalPixelType::New();
typedef itk::ImageRegionIterator< InternalPixelType>        Iterator2DType;

output->SetRegions(inimage->GetRequestedRegion());
output->Allocate();

ImageType2D::Pointer BBOut = ImageType2D::New();

NeighborhoodIteratorType::RadiusType radius;
radius.Fill(2);
typedef itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<
ImageType2D> FaceCalculatorType;
	FaceCalculatorType faceCalculator;
	FaceCalculatorType::FaceListType faceList;
	faceList = faceCalculator(inimage, output->GetRequestedRegion(),
		radius);
	FaceCalculatorType::FaceListType::iterator fit;

	Iterator2DType out;
  NeighborhoodIteratorType it;
	
typedef itk::Statistics::ScalarImageTextureCalculator<ImageType2D>
ScalarImageTextureCalculatorType;
ScalarImageTextureCalculatorType::Pointer
texturecal=ScalarImageTextureCalculatorType::New();
typedef itk::RegionOfInterestImageFilter< ImageType2D,ImageType2D >
ROIFilterType;

typedef VectorContainer<unsigned char, double>      FeatureValueVector;
typedef typename FeatureValueVector::Pointer        FeatureValueVectorPointer;

ROIFilterType::Pointer roifilter=ROIFilterType::New();
  
roifilter->SetInput(inimage);
	for ( fit=faceList.begin(); fit != faceList.end(); ++fit)
		{
		it = NeighborhoodIteratorType( radius,inimage, *fit );
		out = Iterator2DType( output, *fit );
		for (it.GoToBegin(), out.GoToBegin(); ! it.IsAtEnd(); ++it, ++out)
			{
		
		
double result=0.0;
bool BoundryFlag=false;			
                                try
				{
	             
				roifilter->SetRegionOfInterest(it.GetBoundingBoxAsImageRegion());
				roifilter->Update();
				BBOut=roifilter->GetOutput();
                               }
			catch( itk::ExceptionObject & err )
				{
				std::cout << "ExceptionObject caught !" << std::endl;
				std::cout << err << std::endl;
				BoundryFlag=true;
			        result=0.0;
				}
			
			if(BoundryFlag==false)
				{	
                                texturecal->SetInput(BBOut);
				 texturecal->SetNumberOfBinsPerAxis(16);
			        texturecal->Compute();
				FeatureValueVectorPointer tmp= texturecal->GetFeatureMeans();
				result=static_cast<double>(tmp->GetElement(0));
				}
		
			out.Set(result);
			}
	
			std::cout<<"faceList"<< "done out of="<<faceList.size()<<std::endl;
		}
		
	return inimage;// for jus checking time taken  in reality outimgae
should be recasted
                              //  and returned
	}



Regards
--Sachin


More information about the Insight-users mailing list