Project

General

Profile

Files » histo-eq-sqrt.txt

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

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

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

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

for (x=0; x<width;x++) {
for(y=0; y<height; y++) {
p = getPixel(x,y);
setPixel(x,y,h[p]);
}
}
Plot.create("Cumulative Histogram of "+getTitle, "Value", "Sum of pixel count", h);
Plot.show();
// end
(16-16/18)