IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

calculates the histogram for each 2d plan of the portion of an input image More...

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMaskMsr2d (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg)
 wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMaskMsr2d (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg, const ipsdk::imaproc::attr::HistoMsrParamsConstPtr &pHistoPrms)
 wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMaskMsr2d (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg)
 wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMaskMsr2d (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg, const ipsdk::imaproc::attr::HistoMsrParamsConstPtr &pHistoPrms)
 wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask More...
 

Detailed Description

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).

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InMaskImg [Input] Binary image for masking operation X
ipsdk::imaproc::attr::InOptHistoMsrParams [Input Optional] histogram measure parameters X
ipsdk::imaproc::attr::OutPIHistogram [Output] Plan indexed collection of histogram properties ipsdk::imaproc::fromImage (_pOutPIHistogram, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchImagePlans (_pOutPIHistogram,_pInImg,eImagePlansMatchPolicy::eIPMP_ZCT) && 
ipsdk::imaproc::matchSize (_pInImg,_pInMaskImg) && 
(ipsdk::processor::If (
  ipsdk::processor::isSet (_pInOptHistoMsrParams), ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::HistoMsrParams::Min>(_pInImg,_pInOptHistoMsrParams) && ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::HistoMsrParams::Max>(_pInImg,_pInOptHistoMsrParams) && ipsdk::processor::isGreater<ipsdk::imaproc::attr::HistoMsrParams::BinWidth>(_pInOptHistoMsrParams,0),
  ipsdk::processor::none ()))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# load input image from file
inImg = PyIPSDK.loadTiffImageFile(os.path.join(PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images), "Lena_510x509_UInt8.tif"))
# ------------------------------------------------------------------------
# build mask image; remember, we want a mask image with pixels of upper-left quarter
# set to 1, and all other pixels set to 0
maskImg = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Binary, inImg.getSizeX(), inImg.getSizeY())
# first, initialize all pixels values of pMaskImg to 0
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);
# copy upperLeftQuarterMaskImg (with all pixels set to 1) in the upper left quarter of
# maskImg (with all pixels initially set to 0)
# after this operation, our mask image is as expected
util.putROI2dImg(maskImg, upperLeftQuarterMaskImg, 0, 0);
# compute histogram on expected portion of input image (portion defined by set of voxels different from 0 in binary image pInMaskImg)
outHisto = glbmsr.histogramMaskMsr2d(inImg, maskImg)

Example of C++ code :

Example informations

Associated library

IPSDKIPLGlobalMeasure

Header file

Code Example

// in this example, we want to compute the histogram on the upper-left quarter
// of the Lena grey levels image only
// ------------------------------------------------------------------------
// load input image from image samples folder
ImagePtr pInImg = loadTiffImageFile(getIPSDKDirectory(eInternalDirectory::eID_Images) / "Lena_510x509_UInt8.tif");
// ------------------------------------------------------------------------
// build mask image; remember, we want a mask image with pixels of upper-left quarter
// set to 1, and all other pixels set to 0
boost::shared_ptr<MemoryImage> pMaskImg = boost::make_shared<MemoryImage>();
pMaskImg->init(*geometry2d(eImageBufferType::eIBT_Binary, pInImg->getSizeX(), pInImg->getSizeY()));
// first, initialize all pixels values of pMaskImg to 0
util::eraseImg(pMaskImg, 0);
boost::shared_ptr<MemoryImage> pUpperLeftQuarterMaskImg = boost::make_shared<MemoryImage>();
pUpperLeftQuarterMaskImg->init(*geometry2d(eImageBufferType::eIBT_Binary, pInImg->getSizeX() / 2, pInImg->getSizeY() / 2));
util::eraseImg(pUpperLeftQuarterMaskImg, 1);
// copy pUpperLeftQuarterMaskImg (with all pixels set to 1) in the upper left quarter of
// pMaskImg (with all pixels initially set to 0)
// after this operation, our mask image is as expected
util::putROI2dImg(pMaskImg, pUpperLeftQuarterMaskImg, 0, 0);
// ------------------------------------------------------------------------
// apply the histogram computation on the portion of the image that interests us
See also
HistogramMaskMsr2dLvl1
HistogramMaskMsr2dLvl2
HistogramMaskMsr2dLvl3

Function Documentation

◆ histogramMaskMsr2d() [1/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMaskMsr2d ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg 
)

wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_histogramMaskMsr2d() [1/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMaskMsr2d ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg 
)

wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ histogramMaskMsr2d() [2/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMaskMsr2d ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg,
const ipsdk::imaproc::attr::HistoMsrParamsConstPtr pHistoPrms 
)

wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_histogramMaskMsr2d() [2/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMaskMsr2d ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg,
const ipsdk::imaproc::attr::HistoMsrParamsConstPtr pHistoPrms 
)

wrapper function for calculates the histogram for each 2d plan of an input image intersected with a mask

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure