IPSDK 0.2
IPSDK : Image Processing Software Development Kit
HitAndMiss3dImg algorithmSee full documentation
imagehitAndMiss3dImg (inBinImg3d,inForegroundSEXYZ,inBackgroundSEXYZ)

Detailed Description

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

# 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.emptySEXYZInfo()
# Fill the structuring element, we want the
# following foreground ('X' are ignored pixels) :
# X X X
# X 1 1
# X 1 1
# Z
foregroundSE.insert(0, 0, 0);
foregroundSE.insert(1, 0, 0);
foregroundSE.insert(0, 1, 0);
foregroundSE.insert(1, 1, 0);
# Fill the structuring element, we want the
# following background ('X' are ignored pixels) :
# 0 0 0
# 0 X X
# 0 X X
backgroundSE = PyIPSDK.emptySEXYZInfo()
# 0 0 0 0 0 0
# 0 0 0 0 X X
# 0 0 0 0 X X
# Z-1 Z
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);
# 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 0
# 0 0 0 0 1 1
# 0 0 0 0 1 1
# Z-1 Z
outImg = morpho.hitAndMiss3dImg(inImg, foregroundSE, backgroundSE);

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLBasicMorphology/Processor/HitAndMiss3dImg/HitAndMiss3dImg.h>

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 1 1
// X 1 1
// Z
pForegroundSE->insert(0, 0, 0);
pForegroundSE->insert(1, 0, 0);
pForegroundSE->insert(0, 1, 0);
pForegroundSE->insert(1, 1, 0);
// 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 0 0
// 0 0 0 0 X X
// 0 0 0 0 X X
// Z-1 Z
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);
// 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 0
// 0 0 0 0 1 1
// 0 0 0 0 1 1
// Z-1 Z
ImagePtr pOutImg = hitAndMiss3dImg(pInBinImg, pForegroundSE, pBackgroundSE);