Measure Image & Object Texture
Measure Image Texture and Measure Object Texture measure the texture of one channel with Haralick’s features: how the gray levels of pixel pairs a fixed distance apart go together. Contrast is high where neighbouring pixels differ a lot, the angular second moment where few pairs repeat over and over (smooth or regular), entropy where the pairs are all different. The two commands compute the same 13 features; Measure Image Texture over the whole image, Measure Object Texture for each object of a class. To get both, add both steps. The values are those of CellProfiler’s MeasureTexture (which uses mahotas), value for value.
Both are measurement steps: they run once per image plane, after all tiles of the image are read and all objects are found.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
| ID | The step’s ID, unique in the project. It is given automatically - texture_01, … for Measure Image Texture, object_texture_01, … for Measure Object Texture - and starts the names of its values in the results. |
| Objects | Measure Object Texture only: the objects measured. It must be set; the step stops with an error otherwise. |
| Channel | The channel measured. |
| Scale [px] | How far apart the two pixels of a pair are, in pixels (1 to 1000, default 3) - about the size of the texture’s grain. |
| Gray levels | The gray levels the 8-bit values are rescaled to (2 to 256, default 256). Fewer are faster and less noisy; more see finer differences. |
| Directions | Mean of the directions (default): one value per feature, the mean over 0°, 45°, 90° and 135°. Each direction: one value per feature and direction - four times as many values. |
Measurements
Section titled “Measurements”Each name ends with the channel and the scale, e.g. “Contrast (channel 0, scale 3)”. With Each direction the angle is added (“Contrast 45° (channel 0, scale 3)”). Both commands use the same names. None of them has a unit.
| Measurement | Range | High when … |
|---|---|---|
| Angular second moment | 0 to 1 | few pairs repeat over and over: smooth or very regular. |
| Contrast | ≥ 0 | neighbouring pixels differ a lot. |
| Correlation | -1 to 1 | the gray levels of a pair depend linearly on each other. |
| Variance | ≥ 0 | the gray levels spread widely. |
| Inverse difference moment | 0 to 1 | the pairs have (nearly) equal gray levels: homogeneous. |
| Sum average | ≥ 0 | the pairs are bright. |
| Sum variance | ≥ 0 | the brightness of the pairs varies a lot. |
| Sum entropy | ≥ 0 | the sums of the pairs are spread over many values. |
| Entropy | ≥ 0 | the pairs are all different: irregular, complex. |
| Difference variance | ≥ 0 | the differences of the pairs are unevenly distributed. |
| Difference entropy | ≥ 0 | the differences of the pairs are spread over many values. |
| Information measure of correlation 1 | -1 to 0 | (closer to -1) the two pixels of a pair depend on each other. |
| Information measure of correlation 2 | 0 to 1 | the two pixels of a pair depend on each other. |
How it works
Section titled “How it works”Gray levels
Section titled “Gray levels”The channel, as it is loaded from the image, is first converted to 8 bits: its values, normalised to 0 to 1 by the bit depth’s maximum, times 255 (rounded as scikit-image’s img_as_ubyte does). So the result does not depend on the bit depth. With fewer than 256 Gray levels the 8-bit values are then rescaled to . An RGB image is turned into its luminance first.
Co-occurrence matrix
Section titled “Co-occurrence matrix”For each direction, every pixel is paired with the pixel Scale pixels away:
| Direction | Partner |
|---|---|
| 0° | to the right |
| 45° | down and to the left (= up and right) |
| 90° | below |
| 135° | down and to the right |
Each pair of gray levels is counted in both orders, so the matrix is symmetric. Divided by the number of counts, it gives the probabilities . From it come the marginal (the same as ), its mean and variance , the distribution of the sums () and of the differences ().
The features
Section titled “The features”With to base 2:
The Difference variance is the variance of the values themselves, as mahotas computes it. The information measures of correlation use and :
Where the variance is 0 (a uniform image), the correlation is 1.
Image and objects
Section titled “Image and objects”- Measure Image Texture: every pixel counts, dark background included. Pairs that cross a tile border are counted as well.
- Measure Object Texture: only pixels of the object’s mask, and only pairs whose two pixels are both in the mask and not at gray level 0 (as CellProfiler, which sets the pixels outside the object to 0). An object too small to hold a pair in one of the directions - e.g. narrower than Scale - gets no values (CellProfiler stores 0).
Choosing the settings
Section titled “Choosing the settings”- Scale: about the size of the structures whose texture you want - a few pixels for fine speckles, larger for coarse patterns. For objects, keep it clearly smaller than the objects.
- Gray levels: 256 keeps all detail but makes the matrix sparse and the features noisy on small objects; 8 to 64 levels are steadier and faster.
- Directions: the mean is independent of the texture’s orientation. Use Each direction only when the orientation matters (e.g. aligned fibres).
Results
Section titled “Results”The values of Measure Image Texture belong to the image plane; in the List view they are under Columns › Measurements, named “texture_01 · Contrast (channel 0, scale 3)”. With A row per: Images each image shows its own value; with A row per: Objects each object row shows the value of its image plane. The values of Measure Object Texture (“object_texture_01 · Contrast (channel 0, scale 3)”) are shown on each object’s row and are aggregated over the image’s objects with A row per: Images.
The export option Measurements - one row per value writes every value with one row per value - see Exporting Results. With Each direction, one step gives 52 values, so select the measurements you need in the export’s Measurements.