Humboldt-Universität zu Berlin - Faculty of Mathematics and Natural Sciences - Strukturforschung / Elektronenmikroskopie


// This script produces a live histogram of a given image.
// The region from which the histogram is computed may be resized and moved
// Finally, a normalized histogram will be shown

number width, height,top,left,bottom,right
ROI histRoi

// get the front image and its image display:
ImageDisplay imgDisp = GetFrontImage().ImageGetImageDisplay(0)
number ROIcount = ImageDisplayCountROIs(imgDisp);

// if no ROI exists, we will create one that spans the whole image:
if (ROIcount == 0) {
number height, width
// crate an empty Region of interest
histRoi = CreateROI();

// determine the size of the current image:
// set the size of the newly created ROI to the size of the whole image
// assign the newly created ROI to the current image display:
// Give the ROI that we are using a name:
histRoi = imgDisp.ImageDisplayGetROI(0)
histRoi.ROISetLabel("Histogram ROI")

// Create a live histogram from this ROI (Note, that the last parameter
// defines the number of bins used for the histogram!)
image img = getfrontimage()

// We will use exactly as many bins as their are different values in the histogram
number bins = max(img[top,left,bottom,right])-min(img[top,left,bottom,right])

if (0) {