Look for 3D 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.
See HitAndMiss2dImg algorithm for 2D examples of the Hit And Miss algorithm.
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLBasicMorphology as morpho
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
foregroundSE = PyIPSDK.emptySEXYZInfo()
foregroundSE.insert(0, 0, 0);
foregroundSE.insert(1, 0, 0);
foregroundSE.insert(0, 1, 0);
foregroundSE.insert(1, 1, 0);
backgroundSE = PyIPSDK.emptySEXYZInfo()
for offsetY in range(-1, 2):
for offsetX in range(-1, 2):
backgroundSE.insert(offsetX, offsetY, -1);
backgroundSE.insert(-1, -1, 0);
backgroundSE.insert(0, -1, 0);
backgroundSE.insert(1, -1, 0);
backgroundSE.insert(-1, 0, 0);
backgroundSE.insert(-1, 1, 0);
outImg = morpho.hitAndMiss3dImg(inImg, foregroundSE, backgroundSE);
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBasicMorphology/Processor/HitAndMiss3dImg/HitAndMiss3dImg.h>
Code Example
pForegroundSE->insert(0, 0, 0);
pForegroundSE->insert(1, 0, 0);
pForegroundSE->insert(0, 1, 0);
pForegroundSE->insert(1, 1, 0);
for(ipInt32 offsetY = -1; offsetY<=1; ++offsetY)
for(ipInt32 offsetX = -1; offsetX<=1; ++offsetX)
pBackgroundSE->insert(offsetX, offsetY, -1);
pBackgroundSE->insert(-1, -1, 0);
pBackgroundSE->insert(0, -1, 0);
pBackgroundSE->insert(1, -1, 0);
pBackgroundSE->insert(-1, 0, 0);
pBackgroundSE->insert(-1, 1, 0);
ImagePtr pOutImg = hitAndMiss3dImg(pInBinImg, pForegroundSE, pBackgroundSE);