machinevisiontoolbox.Image.zerocross

Image.zerocross()

Compute zero crossing

Returns:

boolean image

Return type:

Image instance

Compute a zero-crossing image, where pixels are true if they are adjacent to a change in sign.

Example:

>>> from machinevisiontoolbox import Image
>>> U, V = Image.meshgrid(None, 6, 6)
>>> img = Image(U - V - 2, dtype='float')
>>> img.print()
 -2.00 -1.00  0.00  1.00  2.00  3.00
 -3.00 -2.00 -1.00  0.00  1.00  2.00
 -4.00 -3.00 -2.00 -1.00  0.00  1.00
 -5.00 -4.00 -3.00 -2.00 -1.00  0.00
 -6.00 -5.00 -4.00 -3.00 -2.00 -1.00
 -7.00 -6.00 -5.00 -4.00 -3.00 -2.00
>>> img.zerocross().print()
 0 0 0 1 0 0
 0 0 1 0 1 0
 0 0 0 1 0 1
 0 0 0 0 1 0
 0 0 0 0 0 0
 0 0 0 0 0 0
Note:

Use morphological filtering with 3x3 structuring element, can lead to erroneous values in border pixels.

References:
  • Robotics, Vision & Control for Python, Section 11.5.1.3, P. Corke, Springer 2023.

Seealso:

Laplace LoG