calculates the histogram for each 2d plan of the portion of an input image
This algorithm computes the histogram on a subset of pixels for each 2d plan of a given input image. The subsets of pixels to consider are defined by the set of pixels whose values is different from 0 in the associated mask image.
The mask image is binary, and must have the same sizes as the input image.
- See also
- Histogram measurement 2d for details about the definition of the histogram.
- Note
- Calling this algorithm with a mask image with all pixels set to 1 is equivalent to call histogramMsr2d algorithm.
Two wrappers can be called : the histogramMaskMsr2d wrapper is only used to compute the histogram measurements on a grey level 2d image, whereas the multiSlice_histogramMaskMsr2d wrapper must be used for more complex data (volume, sequence and/or color).
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr
Code Example
inImg = PyIPSDK.loadTiffImageFile(os.path.join(PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images), "Lena_510x509_UInt8.tif"))
maskImg = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Binary, inImg.getSizeX(), inImg.getSizeY())
util.eraseImg(maskImg, 0);
halfImSzX = int(inImg.getSizeX() / 2)
halfImSzY = int(inImg.getSizeY() / 2)
upperLeftQuarterMaskImg = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Binary, halfImSzX, halfImSzY)
util.eraseImg(upperLeftQuarterMaskImg, 1);
util.putROI2dImg(maskImg, upperLeftQuarterMaskImg, 0, 0);
outHisto = glbmsr.histogramMaskMsr2d(inImg, maskImg)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/HistogramMaskMsr2d/HistogramMaskMsr2d.h>
Code Example
ImagePtr pInImg =
loadTiffImageFile(getIPSDKDirectory(eInternalDirectory::eID_Images) /
"Lena_510x509_UInt8.tif");
boost::shared_ptr<MemoryImage> pMaskImg = boost::make_shared<MemoryImage>();
pMaskImg->init(*
geometry2d(eImageBufferType::eIBT_Binary, pInImg->getSizeX(), pInImg->getSizeY()));
boost::shared_ptr<MemoryImage> pUpperLeftQuarterMaskImg = boost::make_shared<MemoryImage>();
pUpperLeftQuarterMaskImg->init(*
geometry2d(eImageBufferType::eIBT_Binary, pInImg->getSizeX() / 2, pInImg->getSizeY() / 2));