Next: , Previous: , Up: Image Processing   [Contents][Index]


Segmentation

The Guile-CV procedures and methods related to segmentation.

Procedures

im-label
im-label-channel
im-label-all
im-label-all-channel
im-canny
im-canny-channel
im-crack-edge
im-crack-edge-channel
Procedure: im-label image [#:con 8] [#:bg 'black]
Procedure: im-label-channel channel width height [#:con 8] [#:bg 'black]
Procedure: im-label-all image [#:con 8]
Procedure: im-label-all-channel channel width height [#:con 8]

Returns two values: a new GRAY image or channel, and the total number of labels25.

The im-label and im-label-channel procedures label foreground objects in the binary image. In the new image or channel, 0.0 indicates a background pixel, 1.0 indicates that the pixel belongs to object number 1, 2.0 that the pixel belongs to object number 2, etc.

The im-label-all and im-label-all-channel procedures label all objects in the binary image, with no specific distinction for any background value. As a result, these two procedures will label not only the continuous background, if any, but also any hole(s). As an example, they are used by im-fill-holes, defined in the module (cv morphology), which you may have a look at for a better understanding of how it works.

Two pixels belong to the same object if they are neighbors. By default the algorithm uses 8-connectivity to define a neighborhood, but this can be changed through the keyword argument #:con, which can be either 4 or 8.

pp-17-bf pp-17-bf-label pp-17-bf-label-all

Here above, left being the original image, you can see the difference between im-label (2 labels) and im-label-all (6 labels). Note that we had to run im-threshold on the original image first (all labeling procedures take a binary image (or channel) as their mandatory argument), for the record, we used 128 as the threshold value.

Procedure: im-canny image [#:sigma 1.0] [#:threshold 0.0] [#:marker 255.0]
Procedure: im-canny-channel channel width height [#:sigma 1.0] [#:threshold 0.0] [#:marker 255.0]

Returns a new image or channel.

Detect and mark edges using a Canny Edge Detector algorithm: (a) compute the image Gaussian gradient using sigma, (b) remove edges whose strength is below threshold, then for all remaining edges, (d) remove the non-local maxima (edge thinning) and (e) set their intensity using marker.

edx edx-canny-s1.0-t0.0-m255.0 edx-canny-s1.0-t8.0-m255.0 edx-canny-s1.5-t8.0-m255.0 edx-canny-s1.0-t8.0-m96.0

Here above, left being the original tif image26, you can see the difference between im-canny called using the default values, then using #:threshold 8, and finally both #:sigma 1.5 and #:threshold 8. The last example is an illustration of the use of #:marker 96.027.

Procedure: im-crack-edge image [#:marker 255.0]
Procedure: im-crack-edge-channel channel width height [#:marker 255.0]

Returns a new image or channel.

Crack edges are marked ‘between’ the (different) pixels of image. In order to accommodate the cracks, the resulting image or channel size must be (- (* width 2) 1) and (- (* height 2) 1) respectively.

Crack pixels are first inserted, then all crack pixels whose non-crack neighbors have different values are crack edges and marked using marker, while all other pixels (crack and non-crack) become region pixels. Here is a simple example, with two regions, a and b, and using * as the crack edge marker:

OriginalInserted CracksFinal Result
         a b b
         a a b
         a a a
     a . b . b
     . . . . .
     a . a . b
     . . . . .
     a . a . a
      a * b b b
      a * * * b
      a a a * b
      a a a * *
      a a a a a
pp-17-label-all-marked

Here above is the result of (im-crack-edge img #:marker 127), with img being the 6 labels image displayed earlier.

Crack Edge Images have the following properties:

  • Crack Edge Images have odd width and height.
  • Crack pixels have at least one odd coordinate.
  • Only crack pixels may be marked as crack edge pixels.
  • Crack pixels with two odd coordinates must be marked as edge pixels whenever any of their neighboring crack pixels was marked.

As a consequence of the last two properties, both edges and regions are 4-connected. Thus, 4-connectivity and 8-connectivity yield identical connected components in Crack Edge Images (the so called well-composedness). This ensures that Crack Edge Images have nice topological properties28.


Footnotes

(25)

The number of labels correspond to the highest label value + 1: earlier version of Guile-CV, prior to version 1.8.0, did return the number of objects, which correspond to the highest label value. This was less then optimal, since not only 0.0 is a label, but other procedures, im-features for example, do consider and return and element for the background as well.

(26)

Actually, all images displayed in the documentation are png images, though all described im-canny calls where performed on the original tif image. This is because in Guile-CV, all images are 32bit float images, and when saved as tif, all values are preserved (as opposed to being normalized): however, most viewers do not handle floating point pixel values (they donĀ“t know how to scale the values, which may be negative, fractional...). In order to show the results in the documentation, even though all computations of this example were made upon the original tif image, they were saved to png (which normalize all pixel values to [0 255].).

(27)

Note that in order to show the result in the documentation, we had to manually set one pixel of one of the edges to 255.0: this is because, just as we explained in the previous footnote, to be able to display the image in the documentation, we had to save the image as png, which does normalize all values: if you do not set one of the pixels of one edge to 255.0, all markers values would be normalized to 255.0, there by loosing the original marker value.

(28)

See L. J. Latecki: Well-Composed Sets, Academic Press, 2000


Next: Compose, Previous: Morphology, Up: Image Processing   [Contents][Index]