Hi, im doing histogram equalization on 8-bit images of sizes 512*512 and 256*256.. Here is my code below: Code: void CLEO_MedivisionView::OnUpdateToolsHistogramequalization(CCmdUI *pCmdUI) { // TODO: Add your command update UI handler code here if (fileopen) { pCmdUI->Enable(true); } else { pCmdUI->Enable(false); } } 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++) { 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 **\\ cdf[0] = array1[i]; // finding cumulative distribution for (i=1; i<256; i++) { cdf[i] = array1[i] + cdf[i-1]; } for (i=0;i<256;i++) // zeros out all the element in the array { arrayhe[i]=0; } for (i=0; i<256; i++) // applying the HE algorithm { arrayhe[i] = (cdf[i]*255/262144)+0.5; } } Im sure that step 1 is correct.. however when i toggle a breakpoint on cdf in step 2 and when i wanted to check the values inside it and make sure its cumulative frequency compared to array1 which is just frequency.. When i got the values, i get random flow of number ie: '02ex47810'.. Any ideas why is this so? Thanks

Code: for (i= !!! 1 !!!; i<256; i++) for (i= !!! 0 !!!; i<256; i++) You've reintroduced the "not starting at zero" bug.

Sorry, my mistake, it's a different bug. Code: cdf[0] = array1[i]; At this point, i is either 262144 or 65536 having just come out of the "if (no_of_rows == 512 && no_of_cols == 512)" block. So array1 is undefined, and all your values after that are critically dependent on this, so you get garbage.

All right thanks. Thats settled.. IM getting the cumulative values for cdf[] now.. My second and probably the last issue is how do i display the NEW intensity values on the old image, after this code: Code: unsigned int arrayhe[256]; for (i=0; i<256; i++) // applying the HE algorithm { arrayhe[i] = (cdf[i]*255/262144)+0.5; } Do help me out on this thanks.

hi thanks for getting back to me.. im done with the equalization.. i got a new question on segmentation which i will post in another thread