IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Look for particular patterns of foreground and background given as structuring elements. More...

IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::hitAndMiss2dImg (const image::ImageConstPtr &pInBinImg, const StructuringElementXYInfoConstPtr &pInForegroundSEXY, const StructuringElementXYInfoConstPtr &pInBackgroundSEXY)
 wrapper function for Look for particular patterns of foreground and background given as structuring elements More...
 
IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::hitAndMiss2dImg (const image::ImageConstPtr &pInBinImg, const StructuringElementXYInfoConstPtr &pInForegroundSEXY, const StructuringElementXYInfoConstPtr &pInBackgroundSEXY, const image::ImagePtr &pOutBinImg)
 wrapper function for Look for particular patterns of foreground and background given as structuring elements More...
 

Detailed Description

Look for particular patterns of foreground and background given as structuring elements.

The Hit and Miss, also known as Hit or Miss, is a binary morphological operation used to find a particular pattern. This algorithm generates a binary image where pixels with the value 1 (or true) match the pattern given by the foreground and background structuring elements.

The foreground structuring element contains relative coordinates in the current pixel neighbourhood whith an intensity of 1, whereas the background structuring element determines the pixels that must have an intensity of 0. If a pixel can indefferently equal 0 or 1, its coordinate is not specified. Obviously, a pixel coordinate can not appear in both structuring elements.

The figure below illustrate an example where two patterns can be accepted by the algorithm. The object must describe a 3x3 cross but allows the top-right neigbhour to either belong to the foreground or the background since it is absent in both structuring elements.

hitAndMiss2dImg_illustration

Here is the result of the hit and miss operation applied to a binary input image (we are here looking for top left corners) :

hitAndMiss2dImg_illustration
See also
https://en.wikipedia.org/wiki/Hit-or-miss_transform
https://homepages.inf.ed.ac.uk/rbf/HIPR2/hitmiss.htm

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InBinImg [Input] binary image for processing operation X
ipsdk::imaproc::attr::InSEXY1 [Input] first structuring element xy for processing operation X
ipsdk::imaproc::attr::InSEXY2 [Input] second structuring element xy for processing operation X
ipsdk::imaproc::attr::OutBinImg [Output] binary image for processing operation ipsdk::imaproc::duplicateInOut (_pOutBinImg, _pInBinImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSizeAndType (_pInBinImg,_pOutBinImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# Fill the structuring element, we want the
# following foreground ('X' are ignored pixels) :
# X X X X
# X 1 1 1
# X 1 1 1
foregroundSE = PyIPSDK.emptySEXYInfo()
foregroundSE.insert(0, 0)
foregroundSE.insert(1, 0)
foregroundSE.insert(2, 0)
foregroundSE.insert(0, 1)
foregroundSE.insert(1, 1)
foregroundSE.insert(2, 1)
# Fill the structuring element, we want the
# following background ('X' are ignored pixels) :
# 0 0 0
# 0 X X
# 0 X X
backgroundSE = PyIPSDK.emptySEXYInfo()
backgroundSE.insert(-1, -1)
backgroundSE.insert(0, -1)
backgroundSE.insert(1, -1)
backgroundSE.insert(-1, 0)
backgroundSE.insert(-1, 1)
# Compute operation on the input image
# With the combination of the 2 structuring elements,
# the algorithm will look for the following pattern
# 0 0 0 0
# 0 1 1 1
# 0 1 1 1
outImg = morpho.hitAndMiss2dImg(inImg, foregroundSE, backgroundSE);

Example of C++ code :

Example informations

Associated library

IPSDKIPLBasicMorphology

Header file

Code Example

// opening input image
ImagePtr pInBinImg = loadTiffImageFile(inputImgPath);
// Create an empty structuring element to describe the desired foreground
// Fill the structuring element, we want the
// following foreground ('X' are ignored pixels) :
// X X X X
// X 1 1 1
// X 1 1 1
pForegroundSE->insert(0, 0);
pForegroundSE->insert(1, 0);
pForegroundSE->insert(2, 0);
pForegroundSE->insert(0, 1);
pForegroundSE->insert(1, 1);
pForegroundSE->insert(2, 1);
// Create an empty structuring element to describe the desired background
// Fill the structuring element, we want the
// following background ('X' are ignored pixels) :
// 0 0 0
// 0 X X
// 0 X X
pBackgroundSE->insert(-1, -1);
pBackgroundSE->insert(0, -1);
pBackgroundSE->insert(1, -1);
pBackgroundSE->insert(-1, 0);
pBackgroundSE->insert(-1, 1);
// Compute operation on the input image
// With the combination of the 2 structuring elements,
// the algorithm will look for the following pattern
// 0 0 0 0
// 0 1 1 1
// 0 1 1 1
ImagePtr pOutImg = hitAndMiss2dImg(pInBinImg, pForegroundSE, pBackgroundSE);
See also
HitAndMiss2dImgLvl1
HitAndMiss2dImgLvl2
HitAndMiss2dImgLvl3

Function Documentation

◆ hitAndMiss2dImg() [1/2]

IPSDKIPLBASICMORPHOLOGY_API image::ImagePtr ipsdk::imaproc::morpho::hitAndMiss2dImg ( const image::ImageConstPtr pInBinImg,
const StructuringElementXYInfoConstPtr pInForegroundSEXY,
const StructuringElementXYInfoConstPtr pInBackgroundSEXY 
)

wrapper function for Look for particular patterns of foreground and background given as structuring elements

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ hitAndMiss2dImg() [2/2]

IPSDKIPLBASICMORPHOLOGY_API void ipsdk::imaproc::morpho::hitAndMiss2dImg ( const image::ImageConstPtr pInBinImg,
const StructuringElementXYInfoConstPtr pInForegroundSEXY,
const StructuringElementXYInfoConstPtr pInBackgroundSEXY,
const image::ImagePtr pOutBinImg 
)

wrapper function for Look for particular patterns of foreground and background given as structuring elements

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure