I have an interesting problem that I'm trying to solve. So for example, if we have a black and white image containing two textures (A and B), I'm interested in knowing the pixel values of the boundaries that would completely cover the individual textures.

I thought of using cross correlation, which would give me a cluster of the positions, of the template (legends) on the image but is there a way to use that to get the pixel values of the boundaries (these are typically irregular)? Also, is there any other better way of doing this?

A real world example of this would be in detecting the regions of rainfall on a map showing three levels of rainfall in a year. Each level is assigned a texture thats present in the legend, which is used for texture matching on the same image.

  • 4
    $\begingroup$ It would be useful if you actually shared examples and perhaps some preliminary solutions you've tried $\endgroup$
    – Ivo Flipse
    Commented Nov 29, 2011 at 13:31
  • 3
    $\begingroup$ Definitely upload some example images so we understand what you're doing. Like some regions are filled solid and others are cross-hatched? nps.gov/sagu/naturescience/images/… $\endgroup$
    – endolith
    Commented Nov 29, 2011 at 15:09
  • $\begingroup$ In case you have matlab, you could use the image processing toolbox. If not, their website still gives a good overview of standard algorithms you might want to use, for example the function bwconncomp. $\endgroup$
    – Mr. White
    Commented Dec 2, 2011 at 14:31

1 Answer 1


Here's a simple process:

  1. Assign texture measurements to each region in the image.
  2. Use a region labeling / connectivity algorithm (or region growing algorithm) to join adjacent regions having the same texture measure.
  3. Implement a simple edge-following algorithm to trace the contour of each region.

Law's Texture Measures are an older but still useful technique for determining the texture in an image, and they may be sufficient for you to distinguish texture A from texture B throughout the image. See the section "Laws Texture Energy Measures" in the Wikipedia article:


As a first step, calculate all texture measures and determine which particular measure (e.g. Edge or Spot) allows you to distinguish one texture from the other most easily. (If you post some pictures I could help you identify a texture measure.)

If you have only two textures, A and B, then you can treat them as foreground and background, and a standard region labeling algorithm will work. To make it easier to see what's happening in the processing, you could generate a new image by assigning A texels (texture elements, little chunks of texture) to the color white, and B texels to the color black. Region labeling and/or contour-following algorithms would then find the connected white and black regions. The findContours() function in OpenCV will work well.


The same Wikipedia article includes both the traditional multipass algorithm as well as a single-pass algorithm. I haven't implemented the single-pass algorithm described there, but I have worked with the single-pass algorithm described in the paper "A Component-Labeling Algorithm Using Contour Tracing Technique" by Chen and Chang. The paper by Chen and Chang also describes a standard contour-following algorithm that can be implemented quickly.

If you have more than two textures, then you might use a watershed or mean shift algorithm to cluster regions together after you've remapped textures to colors. Although this remapping from texture to color isn't necessary, it does make the process easier to debug and understand.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.