Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How to transfer new intensity values to an OLD IMAGE? (http://www.go4expert.com/forums/transfer-intensity-values-image-t19839/)

metamofia 21Oct2009 12:08

How to transfer new intensity values to an OLD IMAGE?
 
Hi, this is my code below:
Code:

void
 

CLEO_MedivisionView::OnToolsHistogramequalization() {
 


int i; 


unsigned int array1[256]; 


unsigned int cdf[256]; 


unsigned int arrayhe[256]; 
 

//** Step 1 **\\
 
for (i=0;i<256;i++) // count each distinct pixel value in the image
{
array1[i]=0;
}
 

if (no_of_rows == 512 && no_of_cols == 512) {
 


for (i=0; i<262144; i++) {
array1[image[i]]++;
}
}
 


else if (no_of_rows == 256 && no_of_cols == 256) {
 


for (i=0; i<65536; i++) {
array1[image256[i]]++;
}
}
 


//** Step 2 **\\ 

 

for (i=0; i<256; i++) {
cdf[i]=0;
}
 
cdf[0] = array1[0];

// finding cumulative distribution
 
 

for (i=1; i<256; i++) {
cdf[i] = array1[i] + cdf[i-1];
}
 
 

for (i=0; i<256; i++) // applying the HE algorithm
{
arrayhe[i] = (cdf[i]*255/262144)+0.5;
}



as u can see, this set of codes is done as histogram equalization of an image. the current image i used for testing is a 512*512 image and its in 8-bit.. so im sure the algorithm is correct because the cdf[] did return me the cumulative values and the values in arrayhe[] seems probable too.. right now im not too sure how to transfer this value in arrayhe[], containing the new intensity values, to the OLD IMAGE.. im on the verge to complete this project so a decent help would be much appreciated


All times are GMT +5.5. The time now is 22:03.