IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Masked statistics measurement 2dSee full documentation
StatsResultstatsMaskMsr2d (inImg,inMaskImg)

Detailed Description

measure of common statistics indicators (mean, max, etc.) in an image intersected with a mask for each 2d plan

For each 2d plan of the input image, this algorithm measures common statistic indicators (number of pixels, minimum, maximum, mean and standard deviation) on the set of pixels in the input image whose associated pixel in the mask image has a value that equals to 1.

Like Statistics measurement 2d, two wrappers can be called : the statsMaskMsr2d wrapper is only used to compute the statistic measurements on the whole grey level 2d image, whereas the multiSlice_statsMaskMsr2d wrapper must be used for more complex data (channel of a color image, slice of a volume, frame in a 2d sequence, ...).

See ipsdk::imaproc::attr::StatsResult for a complete list of image statistic measurements processed by this algorithm.

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# opening of input image
imageGeometry = PyIPSDK.geometry2d(PyIPSDK.eIBT_UInt8, 510, 509);
inImg = PyIPSDK.loadRawImageFile(inputImgPath, imageGeometry)
# Openninh of the input mask image
inMask = PyIPSDK.loadTiffImageFile(inputMaskPath)
# statistics measurement
statsMsrResult = glbmsr.statsMaskMsr2d(inImg, inMask)
# retrieve measurement results
mean = statsMsrResult.mean
print("Mean value for image is " + str(mean))

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/StatsMaskMsr2d/StatsMaskMsr2d.h>

Code Example

// ------------------ Calculation on a mono-slice grey level image ------------------ //
ImageGeometryPtr pImageGeometry = geometry2d(eImageBufferType::eIBT_UInt8, 510, 509);
ImagePtr pInImg = loadRawImageFile(inImgPath, *pImageGeometry);
ImagePtr pMaskImg = loadTiffImageFile(maskPath);
// Compute statistics on input image
StatsResultPtr pStatsRes = statsMaskMsr2d(pInImg, pMaskImg);
// Retrieve the results as scalar variables
const ipUInt64 uPixCount = pStatsRes->getValue<StatsResult::PixCount>();
const ipReal64 fSum = pStatsRes->getValue<StatsResult::Sum>();
const ipReal64 fMean = pStatsRes->getValue<StatsResult::Mean>();
const ipReal64 fStdDev = pStatsRes->getValue<StatsResult::StdDev>();
const ipReal64 fMin = pStatsRes->getValue<StatsResult::Min>();
const ipReal64 fMax = pStatsRes->getValue<StatsResult::Max>();
// ----------------------------------- Calculation on a multi-slice RGB image ---------------------------------- //
// Compute statistics on input image
PlanIndexedStatsResultPtr pStatsRes_multiSlice = multiSlice_statsMaskMsr2d(pInImg_multiSlice, pMaskImg_multiSlice);
// Retrieve the results as scalar variables for the channel 1 (Green color)
const ipUInt64 c = 1;
const ipUInt64 uPixCount_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::PixCount>().getValue();
const ipReal64 fSum_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::Sum>().getValue();
const ipReal64 fMean_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::Mean>().getValue();
const ipReal64 fStdDev_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::StdDev>().getValue();
const ipReal64 fMin_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::Min>().getValue();
const ipReal64 fMax_multiSlice = pStatsRes_multiSlice->getValue(0, c, 0).getNode<StatsResult::Max>().getValue();