Project

General

Profile

Files » histo-eq.txt

example of a macro that does histogram equalization - Volker Baecker, 06/28/2011 06:23 PM

 
// get stats
getRawStatistics(area, mean, min, max, std, h);
width = getWidth();
height = getHeight();

// Cumulative Histogram
for (i=1;i< h.length;i++) {
h[i] = h[i-1]+h[i];
}

// Normalized Cumulative Histogram
for (i=0;i< h.length;i++) {
h[i] = round( ( (h[i] - h[0])/ ((width * height)-h[0])) * 255);
}

// Change pixel values
for (x=0; x<width;x++) {
for(y=0; y<height; y++) {
p = getPixel(x,y);
setPixel(x,y,h[p]);
}
}

// plot normalized cumulative histogram
Plot.create("Cumulative Histogram of "+getTitle, "Value", "Sum of pixel count", h);
Plot.show();
// end
(15-15/18)