Quantize scan matrix - cerr/CERR GitHub Wiki

Quantizing a scan matrix refers to binning the continuous intensities into bins. The bins can be created by fixing the number of bins or the bin width. Let scan3M be the scan matrix and mask3M be the binary mask for the ROI. It can be accessed from CERR's planC object or input via another application.

Fixed number of bins

The user defines the total number of bins. The scan is then binned into the specified number of bins between min and max intensities. The user has an option to define these min/max intensities or to use min/max from the region of interest. Following example shows the necessary steps to bin scan matrix into the fixed number of bins.

numGrLevels = 64;
quantizedM = imquantize_cerr(scan3M,numGrLevels);

where numGrLevels are the number of bins (gray levels). min/max values are chosen from the the min/max within the ROI.

The following example shows discretization using the user-defined min and max:

numGrLevels = 64;
minIntensity = -400;
maxIntensity = 500;
quantizedM = imquantize_cerr(scan3M,numGrLevels, minIntensity,maxIntensity);

where numGrLevels, minIntensity, maxIntensity are the number of gray levels, minimum and maximum intensity respectively.

Fixed bin width

In order to bin using a fixed bin width, pass the binWidth parameter while leaving the numGrLevels empty.

numGrLevels = [];
binWidth = 25;
quantizedM = imquantize_cerr(scan3M,numGrLevels, minIntensity,maxIntensity,binWidth);

minIntensity, maxIntensity can be left empty in which case min/max from the ROI willbe used.