2

My question is rather about feasibility of a task.

Note that I have read the solution of this question, however you can guess I am not dealing with rectangles and cameras here.

Situation:

I need to save lot of pictures in a folder all of them obeying to these rules:

  • In each picture, there is ONLY one object.
  • The object can be anything (car, horse, human hand ...)
  • The size and the format of the picture belong to certain set.
  • The background of the object is ALWAYS white.
  • The color of the object itself can be anything else (including, why not, areas of white pixels)

Goal:

I want to detect if the object of each image is CENTERED.

Development environment:

  • Python
  • OpenCV

Do you think this is feasible ?

I hope my question is not too broad. I just ask if this can be done automatically without human intervention on the pictures. I have thousands of them. The program will save in a separate folder pictures in which the object is not centered.

EDIT:

Following the comments and answer above: for me, a centered object is the one if I draw a square or rectangle around it, the edges of the square/rectangle must be equivalently distant from let and right sides of the image, whereas the top and the bottom of the object must be equivalently distant from the top and bottom of the picture.

Community
  • 1
  • 1
  • is the background pure white, or some photographed white, possibly with shadings and stuff? The task sounds very feasible, but at the end it really depends on the "quality" of the images... another problem might be the definition of being "centered" for "objects" that are not symmetric. – Micka Feb 23 '15 at 14:33
  • @Micka Yes, background is pure white. –  Feb 23 '15 at 14:40
  • So just convert to grayscale, then threshold the image < 255. Then use findContours and your outermost contour ist your object. Use center of gravity or sth to find object center and compare it to the image center position. – Micka Feb 23 '15 at 15:04
  • @Micka Thank you very much. That is an other interesting approach. –  Feb 23 '15 at 15:06

1 Answers1

0

Yep this is very feasible. However, depending on the type of objects the images contain, they are different ways to accomplish this. Assuming the objects in the images all have a uniform color you can easily perform a color detection algorithm, find the centre point of the object in terms of pixels and find it's position using the image resolution as the reference.

As the background is always white as specified, this is probably your best method as you can just extract all the non white (Or different shade of white) objects within the image.

if you do decide to go with this approach, i should be able to point you to some relevant code

Although writing in c++, more information on this can be found in the link below.

http://opencv-srf.blogspot.co.uk/2010/09/object-detection-using-color-seperation.html

the link is based on object detection in a video but as a video is just a series images the same concept can be used on images

Eni
  • 105
  • 8
  • Also as Micka mentioned, depending on how asymetrical the object is, it might not be possible to get the exact centre of the object. – Eni Feb 23 '15 at 14:36
  • the objects of the image can have uniform color, however they can be multi colorized and even have some areas of white too inside them –  Feb 23 '15 at 14:46
  • The areas of white inside the object can be filtered out by specifying that any white area below a certain size can be ignored or assuming there are different shade of whites. This should enable the filtering of only the background. This method should work assuming the white parts of the object are all enclosed with colored parts. – Eni Feb 23 '15 at 14:52
  • Could you please edit your answer to give me a link or explain me briefly what do you mean by : *centre point of the object in terms of pixels and find it's position using the image resolution as the reference.* ? –  Feb 23 '15 at 14:54
  • The underlining problem is with the symmetry of the object. how do you find the centre point of something like a chair – Eni Feb 23 '15 at 14:54
  • This is good example. If you skip to the end of the video, you can see that the guy is tracking the centre point of the object, with respect to the video resoluton (ie the x and y pixel cordinates of each frame) – Eni Feb 23 '15 at 14:58