I want to calculate textural features using a small neighborhood around each pixel, the size of which I would like to experiment with. Right now I am looking at the basic Haralick textural features that are computed from a gray level cooccurrence matrix (I want to use many different offset directions and average each texural characteristic across the offsets to get one value for, say, the cluster shade of a particular pixel's neighbors).
<br><br>The goal is to end up with a set of characteristics (feature vector) for each pixel in the image, and then use a simple KMeans classification to separate those pixels in the feature space into disjoint classes.<br>
<br>Thanks for your help<br><br><div><span class="gmail_quote">On 8/10/07, <b class="gmail_sendername">Luis Ibanez</b> <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi Dave,<br><br>Why do you want to treat the group of pixels in the neighborhood<br>as a "full image object" ?<br><br>Maybe it will be helpful to start from the beginning and share<br>with us a bit of background regarding what you are actually trying
<br>to compute from your input image.<br><br>Using a neighborhood as a full-image looks like an overkill.<br>Is very likely that there are better ways of implementing the<br>process that you are interested on.<br><br><br>
Please let us know,<br><br><br> Thanks<br><br><br> Luis<br><br><br>--------------<br>dave wrote:<br>> Hello again<br>><br>> To be more specific, I don't know how to grab the current neighborhood
<br>> as an image from the NeighborhoodIterator. My code is below. The<br>> problem I am having is that the texture calculator keeps returning the<br>> same feature values (energy, entropy) for all supposed neighborhoods.
<br>> If I use different input image files, the feature values are different,<br>> so it does seem that the calculator is getting something from the file,<br>> but the "block" doesn't seem to update after the first iteration. Do I
<br>> need to actually take the neighborhood pixel values, one by one, and<br>> place them in my temp image each time? (I'm hoping no since the reason<br>> I'm using ITK is so I can have generalized code)
<br>><br>> Again, thanks for any help someone can provide<br>><br>><br>><br>> #if defined(_MSC_VER)<br>> #pragma warning ( disable : 4786 )<br>> #endif<br>><br>> #include "itkImageFileReader.h
"<br>> #include "itkNeighborhoodIterator.h"<br>> #include "itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.h"<br>> #include "itkGreyLevelCooccurrenceMatrixTextureCoefficientsCalculator.h
"<br>><br>><br>> int main( int argc, char * argv [] )<br>> {<br>> if( argc < 2 )<br>> {<br>> std::cerr << "Usage: " << std::endl;<br>> std::cerr << argv[0];
<br>> std::cerr << " inputScalarImage" << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>><br>> const char * inputImageFileName = argv[1];<br>><br>> typedef char InputPixelType;
<br>> const unsigned int Dimension = 2;<br>><br>> typedef itk::Image<InputPixelType, Dimension > InputImageType;<br>> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>> typedef itk::NeighborhoodIterator< InputImageType >
<br>> NeighborhoodIteratorType;<br>> typedef<br>> itk::Statistics::ScalarImageToGreyLevelCooccurrenceMatrixGenerator<<br>> InputImageType> GLCMGenType;<br>> typedef<br>> itk::Statistics::GreyLevelCooccurrenceMatrixTextureCoefficientsCalculator<
<br>> GLCMGenType::HistogramType > TexCalcType;<br>><br>> // Read input image<br>> ReaderType::Pointer reader = ReaderType::New();<br>> reader->SetFileName( inputImageFileName );<br>> try
<br>> {<br>> reader->Update();<br>> }<br>> catch( itk::ExceptionObject & err )<br>> {<br>> std::cerr << "ExceptionObject caught !" << std::endl;<br>> std::cerr << err << std::endl;
<br>> return EXIT_FAILURE;<br>> }<br>><br>> // Set up neighborhood iterator and the temp output image, "block"<br>> NeighborhoodIteratorType::RadiusType radius;<br>> radius.Fill(1);
<br>> NeighborhoodIteratorType it( radius, reader->GetOutput(),<br>> reader->GetOutput()->GetRequestedRegion() );<br>> InputImageType::Pointer block = InputImageType::New();<br>> block->SetRegions(
it.GetRegion());<br>> block->Allocate();<br>> block->Print( std::cout );<br>><br>> // Set up GLCM<br>> GLCMGenType::Pointer glcm = GLCMGenType::New();<br>> glcm->SetInput( block );<br>
> InputImageType::OffsetType offset = {1,1};<br>> glcm->SetOffset( offset );<br>> glcm->Compute();<br>><br>> // Set up texture calculator<br>> GLCMGenType::HistogramType::Pointer hist = glcm->GetOutput();
<br>> TexCalcType::Pointer texCalc = TexCalcType::New();<br>> texCalc->SetHistogram( hist );<br>><br>><br>> for (it.GoToBegin() ; !it.IsAtEnd(); ++it)<br>> {<br>><br>> // Update GLCM
<br>> try<br>> {<br>> glcm->Compute();<br>> }<br>> catch( itk::ExceptionObject & err )<br>> {<br>> std::cerr << "ExceptionObject caught !" << std::endl;
<br>> std::cerr << err << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>><br>><br>> // Calculate Textural Information from GLCM<br>> try<br>> {<br>
> texCalc->Compute();<br>> }<br>> catch( itk::ExceptionObject & err )<br>> {<br>> std::cerr << "ExceptionObject caught !" << std::endl;<br>> std::cerr << err << std::endl;
<br>> return EXIT_FAILURE;<br>> }<br>><br>><br>> // Output (testing)<br>> std::cout << "Center Pixel Index = " << it.GetIndex() << std::endl;<br>> InputImageType::PixelType value =
it.GetCenterPixel();<br>> std::cout << " Center Pixel value = " << value << std::endl;<br>> std::cout << " Energy = " << texCalc->GetEnergy() << std::endl;
<br>> std::cout << " Entropy = " << texCalc->GetEntropy() << std::endl;<br>> }<br>><br>> return EXIT_SUCCESS;<br>> }<br>><br>><br>><br>> On 8/6/07, dave <
<a href="mailto:common8@gmail.com">common8@gmail.com</a> <mailto:<a href="mailto:common8@gmail.com">common8@gmail.com</a>>> wrote:<br>>> I am trying to use a neighborhood operator. I would like to extract a
<br>> small (say 3x3 or 5x5) region, and then pass the output image to the<br>> ScalarImageToGreyLevelCooccurr enceMatrixGenerator for textural feature<br>> extraction. Then, increment the iterator and repeat the process.
<br>>><br>>> Looking at the software guide and the dox, I see that the<br>> NeighborhoodIterator has functions for accessing individual pixel<br>> values, but how do I setup a small output image that can be updated and
<br>> used at each iteration? I suppose what I really want to do is just feed<br>> the iterator "output image" to the GLCMGenerator but I can't seem to<br>> find the correct way to do it.<br>>>
<br>>> Forgive me if this is something really simple, and thanks<br>>> Dave<br>>><br>>><br>><br>><br>> ------------------------------------------------------------------------<br>><br>
> _______________________________________________<br>> Insight-users mailing list<br>> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>> <a href="http://www.itk.org/mailman/listinfo/insight-users">
http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote></div><br>