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> &lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt; 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 &quot;full image object&quot; ?<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>
&nbsp;&nbsp; Please let us know,<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Luis<br><br><br>--------------<br>dave wrote:<br>&gt; Hello again<br>&gt;<br>&gt; To be more specific, I don&#39;t know how to grab the current neighborhood
<br>&gt; as an image from the NeighborhoodIterator.&nbsp;&nbsp;My code is below.&nbsp;&nbsp;The<br>&gt; problem I am having is that the texture calculator keeps returning the<br>&gt; same feature values (energy, entropy) for all supposed neighborhoods.
<br>&gt; If I use different input image files, the feature values are different,<br>&gt; so it does seem that the calculator is getting something from the file,<br>&gt; but the &quot;block&quot; doesn&#39;t seem to update after the first iteration.&nbsp;&nbsp;Do I
<br>&gt; need to actually take the neighborhood pixel values, one by one, and<br>&gt; place them in my temp image each time? (I&#39;m hoping no since the reason<br>&gt; I&#39;m using ITK is so I can have generalized code)
<br>&gt;<br>&gt; Again, thanks for any help someone can provide<br>&gt;<br>&gt;<br>&gt;<br>&gt; #if defined(_MSC_VER)<br>&gt; #pragma warning ( disable : 4786 )<br>&gt; #endif<br>&gt;<br>&gt; #include &quot;itkImageFileReader.h
&quot;<br>&gt; #include &quot;itkNeighborhoodIterator.h&quot;<br>&gt; #include &quot;itkScalarImageToGreyLevelCooccurrenceMatrixGenerator.h&quot;<br>&gt; #include &quot;itkGreyLevelCooccurrenceMatrixTextureCoefficientsCalculator.h
&quot;<br>&gt;<br>&gt;<br>&gt; int main( int argc, char * argv [] )<br>&gt; {<br>&gt;&nbsp;&nbsp; if( argc &lt; 2 )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0];
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot; inputScalarImage&quot; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp; const char * inputImageFileName = argv[1];<br>&gt;<br>&gt;&nbsp;&nbsp; typedef char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputPixelType;
<br>&gt;&nbsp;&nbsp; const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;Dimension = 2;<br>&gt;<br>&gt;&nbsp;&nbsp; typedef itk::Image&lt;InputPixelType, Dimension &gt; InputImageType;<br>&gt;&nbsp;&nbsp; typedef itk::ImageFileReader&lt; InputImageType &gt; ReaderType;<br>&gt;&nbsp;&nbsp; typedef itk::NeighborhoodIterator&lt; InputImageType &gt;
<br>&gt; NeighborhoodIteratorType;<br>&gt;&nbsp;&nbsp; typedef<br>&gt; itk::Statistics::ScalarImageToGreyLevelCooccurrenceMatrixGenerator&lt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType&gt; GLCMGenType;<br>&gt;&nbsp;&nbsp; typedef<br>&gt; itk::Statistics::GreyLevelCooccurrenceMatrixTextureCoefficientsCalculator&lt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GLCMGenType::HistogramType &gt; TexCalcType;<br>&gt;<br>&gt;&nbsp;&nbsp; //&nbsp;&nbsp;Read input image<br>&gt;&nbsp;&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&gt;&nbsp;&nbsp; reader-&gt;SetFileName( inputImageFileName );<br>&gt;&nbsp;&nbsp; try
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp; //&nbsp;&nbsp;Set up neighborhood iterator and the temp output image, &quot;block&quot;<br>&gt;&nbsp;&nbsp; NeighborhoodIteratorType::RadiusType radius;<br>&gt;&nbsp;&nbsp; radius.Fill(1);
<br>&gt;&nbsp;&nbsp; NeighborhoodIteratorType it( radius, reader-&gt;GetOutput(),<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;GetOutput()-&gt;GetRequestedRegion() );<br>&gt;&nbsp;&nbsp; InputImageType::Pointer block = InputImageType::New();<br>&gt;&nbsp;&nbsp; block-&gt;SetRegions( 
it.GetRegion());<br>&gt;&nbsp;&nbsp; block-&gt;Allocate();<br>&gt;&nbsp;&nbsp; block-&gt;Print( std::cout );<br>&gt;<br>&gt;&nbsp;&nbsp; //&nbsp;&nbsp;Set up GLCM<br>&gt;&nbsp;&nbsp; GLCMGenType::Pointer glcm = GLCMGenType::New();<br>&gt;&nbsp;&nbsp; glcm-&gt;SetInput( block );<br>
&gt;&nbsp;&nbsp; InputImageType::OffsetType offset = {1,1};<br>&gt;&nbsp;&nbsp; glcm-&gt;SetOffset( offset );<br>&gt;&nbsp;&nbsp; glcm-&gt;Compute();<br>&gt;<br>&gt;&nbsp;&nbsp; //&nbsp;&nbsp;Set up texture calculator<br>&gt;&nbsp;&nbsp; GLCMGenType::HistogramType::Pointer hist = glcm-&gt;GetOutput();
<br>&gt;&nbsp;&nbsp; TexCalcType::Pointer texCalc = TexCalcType::New();<br>&gt;&nbsp;&nbsp; texCalc-&gt;SetHistogram( hist );<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; for (it.GoToBegin() ; !it.IsAtEnd(); ++it)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;Update GLCM
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glcm-&gt;Compute();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; // Calculate Textural Information from GLCM<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; texCalc-&gt;Compute();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;Output (testing)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;Center Pixel Index = &quot; &lt;&lt; it.GetIndex() &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType::PixelType value = 
it.GetCenterPixel();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;&nbsp;&nbsp; Center Pixel value = &quot; &lt;&lt; value &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;&nbsp;&nbsp; Energy = &quot; &lt;&lt; texCalc-&gt;GetEnergy() &lt;&lt; std::endl;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;&nbsp;&nbsp; Entropy = &quot; &lt;&lt; texCalc-&gt;GetEntropy() &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp; return EXIT_SUCCESS;<br>&gt; }<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 8/6/07, dave &lt;
<a href="mailto:common8@gmail.com">common8@gmail.com</a> &lt;mailto:<a href="mailto:common8@gmail.com">common8@gmail.com</a>&gt;&gt; wrote:<br>&gt;&gt;&nbsp;&nbsp;I am trying to use a neighborhood operator.&nbsp;&nbsp;I would like to extract a
<br>&gt; small (say 3x3 or 5x5) region, and then pass the output image to the<br>&gt; ScalarImageToGreyLevelCooccurr enceMatrixGenerator for textural feature<br>&gt; extraction. Then, increment the iterator and repeat the process.
<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp;Looking at the software guide and the dox, I see that the<br>&gt; NeighborhoodIterator has functions for accessing individual pixel<br>&gt; values, but how do I setup a small output image that can be updated and
<br>&gt; used at each iteration? I suppose what I really want to do is just feed<br>&gt; the iterator &quot;output image&quot; to the GLCMGenerator but I can&#39;t seem to<br>&gt; find the correct way to do it.<br>&gt;&gt;
<br>&gt;&gt;&nbsp;&nbsp;Forgive me if this is something really simple, and thanks<br>&gt;&gt;&nbsp;&nbsp;Dave<br>&gt;&gt;<br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>
&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users">
http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote></div><br>