machinevisiontoolbox.Image.hitormiss

Image.hitormiss(s1, s2=None, border='replicate', bordervalue=0, **kwargs)

Hit or miss transform

Parameters:
  • s1 (ndarray(N,M)) – structuring element 1

  • s2 (ndarray(N,M)) – structuring element 2

  • kwargs – arguments passed to opencv.morphologyEx

Returns:

transformed image

Return type:

Image

Return the hit-or-miss transform of the binary image which is defined by two structuring elements structuring elements

\[Y = (X \ominus S_1) \cap (X \ominus S_2)\]

which is the logical-and of the binary image and its complement, eroded by two different structuring elements. This preserves pixels where ones in the window are consistent with \(S_1\) and zeros in the window are consistent with \(S_2\).

If only s1 is provided it has three possible values:
  • 1, must match a non-zero value

  • -1, must match a zero value

  • 0, don’t care, matches any value.

Example:

cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgproc/src/morph.dispatch.cpp:1224: error: (-215:Assertion failed) src.type() == CV_8UC1 in function 'morphologyEx'

Note:

For the single argument case s1 \(=S_1 - S_2\).

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

Seealso:

thin endpoint triplepoint opencv.morphologyEx