Detect a white square in a black and white image
- by gcc
I saw that question i one web site (cite name like that programm.)
then i tried to solve but icannot (not my and myfriend homework )
how can i approach to that one (in program.net no solution there is )
Read black & white image data from standard input, and detect a white square in the image. Output the coordinates of the upper left corner of the square, and the width of the square. In the preliminary work, you can print the output and terminate your program after you detect your first square. If you can't find any square on the image, you will print the string: "NO DETECTION".
Input (which represents a 2 by 2 square in the center of a 5 by 4 image):
2 2
5 4
0 0 0 0 0
0 0 255 255 0
0 0 255 255 0
0 0 0 0 0
Output:
3 2 2
Input (more comprehensible format of the image, with the same output):
2
6 4
000 000 000 000 000 000
000 000 255 255 255 000
000 000 000 255 255 000
000 000 000 000 000 000
Output:
no detection
Input can be:
000 255 255 000 000 000
000 255 255 000 000 000
000 000 000 000 000 000
000 000 000 000 000 000
000 000 255 255 255 000
000 000 255 255 255 000
000 000 255 255 255 000
000 000 000 000 000 000
If there are two squares detected, we should use the biggest one