Haralick Texture Descriptors Extraction

Context

Hello all, I am trying to extract textural information from a large group of single-banded raster images using the “HaralickTextureExtraction” tool. I need to use a batch process, and I am having problems setting the parameters so that the tool works with the correct “Image minimum” and “Image maximum.”

Configuration setup

My system: Windows10

Version of the OTB: 8.0.1

I installed the OTB with: the binaries

If relevant, you may also provide:

QGIS version: 3.26.0

Description of my issue

*I need to be able to run a large number of raster files using the batch option of QGIS to obtain their Haralick descriptors. So far, I can adjust the Image minimum value and Image maximum value manually for processing a single image, although my goal is to extract the descriptors from more than 3750 images. I have tried “Not set” as an option in the “Image minimum” and “Image maximum” on the column of the batch dialog box, but that does not bring about good results. I have also tried to leave the default minimum and maximum values (0 and 255), but since those values do not represent the actual values, the results are also bad. The Haralick rasters are generated in both cases, but their bands are empty. See below. Could you please help me figure out a method to have the tool automatically detect the minimum and maximum values as the batch runs? I imagine there would be a way to achieve my goal using the “autofill” option of the batch processing, but I have not been able to figure it out.
Sometimes the tool does not even process a single raster image, sending an error message like the one also listed below. The command line turns a similar error when I tried it on a single file (HaralickTextureExtraction: Lower threshold (-parameters.min) cannot be greater than upper threshold (-parameters.max)), which is strange, see error message below and notice that the input min is in fact smaller than the input max value *

Information from provider (Resulting Haralick Raster file, properties)

Extent 357835.7359154801815748,3069733.2960509438998997 : 357835.9937726052594371,3069733.5825588610023260

Width 9

Height 10

Data type Float32 - Thirty two bit floating point

GDAL Driver Description GTiff

GDAL Driver Metadata GeoTIFF

Dataset Description C:\RESEARCH

Compression

Band 1

STATISTICS_MAXIMUM=1

STATISTICS_MEAN=1

STATISTICS_MINIMUM=1

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 2

STATISTICS_MAXIMUM=0

STATISTICS_MEAN=0

STATISTICS_MINIMUM=0

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 3

STATISTICS_MAXIMUM=0

STATISTICS_MEAN=0

STATISTICS_MINIMUM=0

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 4

STATISTICS_MAXIMUM=1

STATISTICS_MEAN=1

STATISTICS_MINIMUM=1

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 5

STATISTICS_MAXIMUM=0

STATISTICS_MEAN=0

STATISTICS_MINIMUM=0

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 6

STATISTICS_MAXIMUM=0

STATISTICS_MEAN=0

STATISTICS_MINIMUM=0

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 7

STATISTICS_MAXIMUM=0

STATISTICS_MEAN=0

STATISTICS_MINIMUM=0

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

Band 8

STATISTICS_MAXIMUM=447.8571472168

STATISTICS_MEAN=447.8571472168

STATISTICS_MINIMUM=447.8571472168

STATISTICS_STDDEV=0

STATISTICS_VALID_PERCENT=100

Scale: 1

Offset: 0

More information

AREA_OR_POINT=Area

DataType=3

METADATATYPE=OTB

OTB_VERSION=8.0.1

TileHintX=9

TileHintY=10

Dimensions X: 9 Y: 10 Bands: 8

Origin 357835.7359154801815748,3069733.5825588610023260

Pixel Size 0.0286507916753180325,-0.02865079171024263044

Error message:

QGIS version: 3.26.0-Buenos Aires

QGIS code revision: 0aece2818e

Qt version: 5.15.3

Python version: 3.9.5

GDAL version: 3.5.0

GEOS version: 3.10.3-CAPI-1.16.1

PROJ version: Rel. 9.0.1, June 15th, 2022

PDAL version: 2.3.0 (git-version: e64939)

Algorithm started at: 2022-07-18T14:48:02

Algorithm ‘HaralickTextureExtraction’ starting…

Input parameters:

{ ‘in’ : ‘C:/RESEARCH/Doct 3rd Chapter/Grid Elevation Data/Grid - 1/Texture Descriptors Extraction/B1 - Blue Band/Plot 30 cm/Clipped Square Rasters/Raster_N_510.tif’, ‘channel’ : 1, ‘step’ : 1, ‘parameters.xrad’ : 2, ‘parameters.yrad’ : 2, ‘parameters.xoff’ : 1, ‘parameters.yoff’ : 1, ‘parameters.min’ : 960, ‘parameters.max’ : 2442, ‘parameters.nbbin’ : 8, ‘texture’ : ‘simple’, ‘out’ : ‘TEMPORARY_OUTPUT’ }

2022-07-18 14:48:02 (FATAL) HaralickTextureExtraction: Lower threshold (-parameters.min) cannot be greater than upper threshold (-parameters.max).

Execution completed in 0.14 seconds

Results:

{‘out’: ‘C:/Users/aliglezpe/AppData/Local/Temp/processing_NiExDU/d4f1a6783576463d986a62721c15a9e1/out.tif’}

Loading resulting layers

The following layers were not correctly generated.

Information from provider (input Raster image)

|Ex**tent|357846.1648036492988467,3069781.2001746222376823 : 357846.4226607743185014,3069781.4866825388744473|
| — | — |
|Width|9|
|Height|10|
|Data type|UInt16 - Sixteen bit unsigned integer|
|GDAL Driver Description|GTiff|
|GDAL Driver Metadata|GeoTIFF|
|Dataset Description|C:\RESEARCH\Doct 3rd Chapter\Grid Elevation Data\Grid - 1\Texture Descriptors Extraction\B1 - Blue Band\Plot 30 cm\Clipped Square Rasters\Raster_N_510.tif|
|Compression||
|Band 1| BandName=Band_1*
** RepresentationType=ATHEMATIC*
** STATISTICS_MAXIMUM=2442*
** STATISTICS_MEAN=1611.6333333333*
** STATISTICS_MINIMUM=960*
** STATISTICS_STDDEV=335.06737133498*
** STATISTICS_VALID_PERCENT=100*

** Scale: 1*
** Offset: 0|*
|More information| AREA_OR_POINT=Area*
** DataType=Generic|*
|Dimensions|X: 9 Y: 10 Bands: 1|
|Origin|357846.1648036492988467,3069781.4866825388744473|
|Pixel Size|0.02865079166885051501,-0.02865079166367650101|

Hi @Aliglezpe ,

Tweaking the haralick texture descriptors is quite tricky, it really depends on your input image pixels distribution since the indices are computed from a grey level cooccurrence matrix (GLCM). See here for a deeper discussion on the subject.

Regarding the statistics of your input image, you could give a try with the following settings:

  • parameters.min to 950
  • parameters.max to 2300
  • parameters.nbbin: try with different values (e.g. 8, 16, 32)

Explanation: the min and max set the range mean -/+ 2* std, which is “represents enough well” the input pixels values distribution. The number of bins will set the quantization of the GLCM, from which are the indices computed.

Hope that helps,

Rémi