FANDOM


< Filters documentation

Example Edit

input
ImageTest

inImage

output
TutorialC3 CoOccurrenceMatrix outImage

outImage

 features_angularSecondMoment = 0.021377
 features_angularSecondMoment = 0.146209
 features_entropy = 6.631931
 features_contrast = 3752.599609
 features_dissimilarity = 35.073566
 features_inverseDifferenceMoment = 0.567048
 features_mean_i = 131.224045
 features_mean_j = 131.233536
 features_variance_i = 4666.876953
 features_variance_j = 4666.885742
 features_correlation = 0.597963

Parameters Edit

to be certain to have a up to date information you can list all parameters with their description directly with the Filters API (see TutorialC1 in langage C or Tutorial3 in Delphi)

[inImage] Edit

input image
type : image

[outImageMonitoring] Edit

you can provide a outImageMonitoring to show the pixel corresponding to the ROI you have setted on the outImage
-> try FiltersTest for more information, and have a look on is code type : image

[horizontalDistance] Edit

relative to the current pixel, the x delta for the pixel to calcul the co-occurence
type : integer

[verticalDistance] Edit

relative to the current pixel, the y delta for the pixel to calcul the co-occurence
type : integer

[xAnalyse] Edit

determine the calcul of the co-occurence

0 -> Intensity 
1 -> Red
2 -> Green
3 -> Blue
4 -> Hue
5 -> Saturation

type : integer

[scale] Edit

type : integer

Output Edit

[outImage] Edit

the co-occurence matrix : each pixel is in fact a Single (4 octets) type : image

[features_*] Edit

features_angularSecondMoment features_energy features_entropy features_contrast features_dissimilarity features_inverseDifferenceMoment features_mean_i/j features_variance_i/j features_correlation type : float

Sample code Edit

C Edit

void testCoOccurrenceMatrix()
{
	PFBitmap32 fImageTest = image_createImageTest( 512, 512 );
	//PFBitmap32 outImageMonitoring = image_createImageLike( fImageTest );
	
	__int32 filterCoOccurrenceMatrix = filters_createFilter( "filterCoOccurrenceMatrix" );
	
	filters_setParameterImage( filterCoOccurrenceMatrix, "inImage", fImageTest );
    //filters_setParameterImage( filterCoOccurrenceMatrix, "outImageMonitoring", outImageMonitoring );
    filters_setParameterInteger( filterCoOccurrenceMatrix, "horizontalDistance", 1 );
    filters_setParameterInteger( filterCoOccurrenceMatrix, "verticalDistance", 0 );
    filters_setParameterInteger( filterCoOccurrenceMatrix, "xAnalyse", 0 ); // Intensity
    filters_setParameterInteger( filterCoOccurrenceMatrix, "yAnalyse", 0 ); // Intensity
    filters_setParameterFloat( filterCoOccurrenceMatrix, "scale",  1 );

	filters_run( filterCoOccurrenceMatrix );
	
	// get outImage
	PFBitmap32 outImage = filters_getOutputImage( filterCoOccurrenceMatrix, "outImage" );
	helper_saveImage( outImage, "C:/DEV/FiltersTutorial/Bin/tutorialC3_CoOccurrenceMatrix_outImage.bmp" );
	// and features
	float tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_angularSecondMoment" );
    printf( "features_angularSecondMoment = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_energy" );
    printf( "features_angularSecondMoment = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_entropy" );
    printf( "features_entropy = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_contrast" );
    printf( "features_contrast = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_dissimilarity" );
    printf( "features_dissimilarity = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_inverseDifferenceMoment" );
    printf( "features_inverseDifferenceMoment = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_mean_i" );
    printf( "features_mean_i = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_mean_j" );
    printf( "features_mean_j = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_variance_i" );
    printf( "features_variance_i = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_variance_j" );
    printf( "features_variance_j = %f \n", tmpSingle );
    tmpSingle = filters_getOutputFloat( filterCoOccurrenceMatrix, "features_correlation" );
    printf( "features_correlation = %f \n", tmpSingle );
        
	filters_deleteFilter( filterCoOccurrenceMatrix );
	
	image_freeImage( fImageTest );
}

Delphi Edit

procedure TFormMain.btnTextureComputeClick(Sender: TObject);
var
  filterCoOccurrenceMatrix : Integer;
  imageCoOccurrenceMatrix, imageMask : PFBitmap32;
  tmpSingle : Single;
  i, iMax, j, jMax : Integer;
  value : Single;
  features_occurrenceMax : Single;
  features_occurrenceMax_col, features_occurrenceMax_row : Integer;
begin
  txtOutput.Clear();
  // load image to analyse in 'imageLoaded'
  cmdLoadClick( Self );

  // create filter 'filterCoOccurrenceMatrix'
  filterCoOccurrenceMatrix := createFilter( 'filterCoOccurrenceMatrix' );
  // set 'inImage'
  setParameterImage( filterCoOccurrenceMatrix, 'inImage', imageLoaded );
  // we would like to analyse only a part of the image, we use a mask
  // load the mask image
  imageMask := loadOneImage( '.\texture_mask.jpg' );
  // set 'mask'
  setParameterImage( filterCoOccurrenceMatrix, 'mask', imageMask );
  // set pixels to compare : p1(c,r) <-> p2(c+1,r+0)
  setParameterInteger( filterCoOccurrenceMatrix, 'horizontalDistance', 1 );
  setParameterInteger( filterCoOccurrenceMatrix, 'verticalDistance', 0 );
  // set data to compare : p1(0=Intensity) <-> p2(0=Intensity)
  setParameterInteger( filterCoOccurrenceMatrix, 'xAnalyse', 0 );
  setParameterInteger( filterCoOccurrenceMatrix, 'yAnalyse', 0 );
  // set 'scale'
  setParameterFloat( filterCoOccurrenceMatrix, 'scale',  1 );
  // run
  run( filterCoOccurrenceMatrix );

  // show build in texture features computed by the filter
  tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_angularSecondMoment' );
  txtOutput.Lines.Add( 'features_angularSecondMoment = ' + FloatToStrF(tmpSingle,ffFixed,10,10) );
  tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_energy' );
  txtOutput.Lines.Add( 'features_energy = ' + FloatToStrF(tmpSingle,ffFixed,10,10) );
  tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_entropy' );
  txtOutput.Lines.Add( 'features_entropy = ' + FloatToStrF(tmpSingle,ffFixed,10,10) );
  tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_contrast' );
  txtOutput.Lines.Add( 'features_contrast = ' + FloatToStrF(tmpSingle,ffFixed,10,10) );
  tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_inverseDifferenceMoment' );
  txtOutput.Lines.Add( 'features_inverseDifferenceMoment = ' + FloatToStrF(tmpSingle,ffFixed,10,10) );

  // now we will compute our own texture features : the mean
  // get 'outImage' (= the co-occurrence matrix) (this image contains float value, not pixels)
  imageCoOccurrenceMatrix := getOutputImage( filterCoOccurrenceMatrix, 'outImage' );
  features_occurrenceMax := -1.0;
  features_occurrenceMax_col := -1;
  features_occurrenceMax_row := -1;
  iMax := imageCoOccurrenceMatrix.Height-1;
  jMax := imageCoOccurrenceMatrix.Width-1;
  for i:=0 to iMax do begin
    for j:=0 to jMax do begin
      value := image.getPixelAsSingle( imageCoOccurrenceMatrix, j, i );
      if value>features_occurrenceMax then begin
        features_occurrenceMax := value;
        features_occurrenceMax_col := j;
        features_occurrenceMax_row := i;
      end;
    end;
  end;
  txtOutput.Lines.Add( 'my feature : features_occurrenceMax = ' + FloatToStrF(features_occurrenceMax,ffFixed,5,10) +
    ', for co-occurrence of intensity [' + IntToStr(features_occurrenceMax_col) + ']' +
    ' and intensity [' + IntToStr(features_occurrenceMax_row) + ']' );

  // delete the filter
  deleteFilter( filterCoOccurrenceMatrix );
  // delete 'imageMask'
  image.freeImage( imageMask );
end;


Links Edit

"The GLCM Tutorial Home Page" by Mryka Hall-Beyer

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.