hw8sol-2

# hw8sol-2 - count1 else sum2 = image_in[j[k count2 old_T =...

This preview shows page 1. Sign up to view the full content.

//hw8sol-2 float sum1, sum2; float new_T, old_T, delta_T; long count1, count2; /********************************************************************/ /* Image Processing begins */ /********************************************************************/ new_T = 200.0; /* initial threshold */ delta_T = 100.0; /* any big number to get into the loop */ while (delta_T > 5.0 || delta_T < -5.0) { count1 = 0; count2 = 0; sum1 = 0.0; sum2 = 0.0; for (j=0; j<height; j++) for (k=0; k<width; k++) { if (image_in[j][k] >= new_T) { sum1 += image_in[j][k];
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: count1++; } else { sum2 += image_in[j][k]; count2++; } } old_T = new_T; new_T = ((sum1/count1)+(sum2/count2))/2; delta_T = new_T - old_T; printf("new threshold = %f \n", new_T); } /* now we do thresholding */ for (j=0; j<height; j++) for (k=0; k<width; k++) { image_out[j][k] = (image_in[j][k] >= new_T ? 255 : 0); } /********************************************************************/ /* Image Processing begins */ /********************************************************************/ …...
View Full Document

## This homework help was uploaded on 04/05/2008 for the course EE/CPE 462 taught by Professor Prof.hongman during the Spring '07 term at Stevens.

Ask a homework question - tutors are online