I am trying to calculate texture features for a segmented 3D brain MRI using the ITK library with C ++. So I followed this example . The example takes a 3D image and extracts 3 different elements for all 13 possible spatial directions. In my program, I just want to get the given three-dimensional image:
- Energy
- Correlation
- Inertia
- Haralick correlation
- Backward difference
- Cluster prominence
- Cluster shade
Here is what I still have:
//definitions of used types typedef itk::Image<float, 3> InternalImageType; typedef itk::Image<unsigned char, 3> VisualizingImageType; typedef itk::Neighborhood<float, 3> NeighborhoodType; typedef itk::Statistics::ScalarImageToCooccurrenceMatrixFilter<InternalImageType> Image2CoOccuranceType; typedef Image2CoOccuranceType::HistogramType HistogramType; typedef itk::Statistics::HistogramToTextureFeaturesFilter<HistogramType> Hist2FeaturesType; typedef InternalImageType::OffsetType OffsetType; typedef itk::AddImageFilter <InternalImageType> AddImageFilterType; typedef itk::MultiplyImageFilter<InternalImageType> MultiplyImageFilterType; void calcTextureFeatureImage (OffsetType offset, InternalImageType::Pointer inputImage) { // principal variables //Gray Level Co-occurance Matrix Generator Image2CoOccuranceType::Pointer glcmGenerator=Image2CoOccuranceType::New(); glcmGenerator->SetOffset(offset); glcmGenerator->SetNumberOfBinsPerAxis(16); //reasonable number of bins glcmGenerator->SetPixelValueMinMax(0, 255); //for input UCHAR pixel type Hist2FeaturesType::Pointer featureCalc=Hist2FeaturesType::New(); //Region Of Interest typedef itk::RegionOfInterestImageFilter<InternalImageType,InternalImageType> roiType; roiType::Pointer roi=roiType::New(); roi->SetInput(inputImage); InternalImageType::RegionType window; InternalImageType::RegionType::SizeType size; size.Fill(50); window.SetSize(size); window.SetIndex(0,0); window.SetIndex(1,0); window.SetIndex(2,0); roi->SetRegionOfInterest(window); roi->Update(); glcmGenerator->SetInput(roi->GetOutput()); glcmGenerator->Update(); featureCalc->SetInput(glcmGenerator->GetOutput()); featureCalc->Update(); std::cout<<"\n Entropy : "; std::cout<<featureCalc->GetEntropy()<<"\n Energy"; std::cout<<featureCalc->GetEnergy()<<"\n Correlation"; std::cout<<featureCalc->GetCorrelation()<<"\n Inertia"; std::cout<<featureCalc->GetInertia()<<"\n HaralickCorrelation"; std::cout<<featureCalc->GetHaralickCorrelation()<<"\n InverseDifferenceMoment"; std::cout<<featureCalc->GetInverseDifferenceMoment()<<"\nClusterProminence"; std::cout<<featureCalc->GetClusterProminence()<<"\nClusterShade"; std::cout<<featureCalc->GetClusterShade(); }
The program works. However, I have this problem: it gives the same results for different 3D images , even when I change the window size .
Has anyone used ITK for this? If there is any other way to achieve this, can someone point me to a solution?
Any help would be greatly appreciated.
source share