hw8sol-2 - count1++; } else { sum2 += image_in[j][k];...

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

View Full Document Right Arrow Icon
//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];
Background image of page 1
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(&quot;new threshold = %f \n&quot;, new_T); } /* now we do thresholding */ for (j=0; j&lt;height; j++) for (k=0; k&lt;width; k++) { image_out[j][k] = (image_in[j][k] &gt;= new_T ? 255 : 0); } /********************************************************************/ /* Image Processing begins */ /********************************************************************/...
View Full Document

Ask a homework question - tutors are online