how to count image pixel
i want to know how to apply this "The horizontal position, counting pixels from the left edge of the image, of the center of the smallest rectangular box that can be drawn with all "on" pixels inside the box." 
Note that the box==image 

using opencv code

any help 
how to count image pixel
===

i want to know how to apply this "The horizontal position, counting pixels from the left edge of the image, of the center of the smallest rectangular box that can be drawn with all "on" pixels inside the box." 
Note that the box==image 

using opencv code

any help 