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

Sachin Jambawalikar sachinjam at gmail.com
Fri Mar 4 02:09:30 EST 2005


Hi  Zach,
thanks  for your prompt reply.
I made the necessary changes you asked for. But still the  Glcm takes
about  360 second
 for one slice with  the radius of neighboorhood 12. I was wondering 
if you  know of a faster implementation of glcm or have come across
some references  for fast glcm matrix computation, I had implemented a
 C code for (without using the itk library) glcm maps computation
which  computed   glcm maps for window 5x5  and histogram bins 256 in
about  780 second ,so I feel that the glcm computation with  your
class  is slightly faster
or round about the same ( for your class  I am using radius 12 ie
window of 25x25). Is there any scope  for improving the speed .

I'm trying to compute slice by slice glcm feature maps for a 3D
volume.And my volumes are 512x512x50 so it would take me like 5 hours
for a volume.

this is the   out put and the changed code:
          Probe Tag    Starts    Stops           Time
          Slice glcm           1            1           360.968
computed0thslice
          Probe Tag    Starts    Stops           Time
          Slice glcm           1            1           364.125
computed1thslice
          Probe Tag    Starts    Stops           Time
          Slice glcm           1            1           370.906
computed2thslice
          Probe Tag    Starts    Stops           Time
          Slice glcm           1            1           371.359
computed3thslice




ComputeNeighboorhoodConvolution(ImagePointer2D inimage)
	{
	
//typedef  PixelType short;

	 itk::TimeProbesCollectorBase collector;

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

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

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

NeighborhoodIteratorType::RadiusType radius;
	

itk::NeighborhoodInnerProduct<ImageType2D> innerProduct;
	radius.Fill(12);
	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;
double result=0.0;

ROIFilterType::Pointer roifilter=ROIFilterType::New();
 	roifilter->SetInput(inimage);
			fit=faceList.begin();
		it = NeighborhoodIteratorType( radius,inimage, *fit );
		out = Iterator2DType( output, *fit );
   collector.Start("Slice glcm");
 texturecal->SetNumberOfBinsPerAxis(16);	
	 for (it.GoToBegin(), out.GoToBegin(); ! it.IsAtEnd(); ++it, ++out)
			{
		
   	BBOut->SetRequestedRegion(it.GetBoundingBoxAsImageRegion());
	     texturecal->SetInput(BBOut);
			  texturecal->Compute();
		 	FeatureValueVectorPointer tmp= texturecal->GetFeatureMeans();
				result=static_cast<double>(tmp->GetElement(0));
				out.Set(result);
			}
	
		collector.Stop("Slice glcm");
		collector.Report();

		
	return inimage;
	}




Regards
--Sachin


More information about the Insight-users mailing list