Page 1 of 1

Remove background using special markers

Posted: 2019-02-15T14:50:48-07:00
by vesa
Greetings,

I would like to remove the background automatically from photos. The object is a table that can move and can have some random objects on it. The background is a wooden floor that can have some random objects. I was wondering if I can mark the corners of the table with some special markers like QR codes or color dots and then remove everything outside the quadrilateral formed by the markers.

Cheers,
Vesa

Re: Remove background using special markers

Posted: 2019-02-15T16:19:47-07:00
by fmw42
Measure the top left corner x,y and width and height of the region you want to keep and then use -crop WxH+X+Y +repage. See https://imagemagick.org/Usage/crop/#crop

_____________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli

Re: Remove background using special markers

Posted: 2019-02-15T23:14:11-07:00
by vesa
That doesn't really help since there shouldn't be any manual interaction. Also the area is not a rectangle.

Re: Remove background using special markers

Posted: 2019-02-15T23:47:11-07:00
by fmw42
You mentioned putting dots on the image. That means you have manual interaction. Please clarify or show an example image.

With 4 points, you can draw a polygon (quadrilateral) from the coordinates and then mask out the image.

If the dots are uniquely colored, then one could extract, in principle, the coordinates of the centers of the dots.

Re: Remove background using special markers

Posted: 2019-02-16T02:21:28-07:00
by vesa
The dots would be physical dots, not marked afterwards to the image. The idea is that with some physical markers a software could automatically determine these positions and crop accordingly without any human interaction.

Re: Remove background using special markers

Posted: 2019-02-16T02:40:45-07:00
by vesa
I think I got it. I'll put for example green dots on red background and use compare + maxima to determine the coordinates. Let's see how it works.

Re: Remove background using special markers

Posted: 2019-02-16T08:52:09-07:00
by snibgo
This is like motion capture in the movies: targets are stuck to actors, the camera captures the actions, and computers replace the actors with animated figures.

The targets can be something like these (Windows syntax):

Code: Select all

magick ^
  -size 100x100 ^
  xc:Black xc:White +append ^
  ( +clone -flop ) ^
  -append +repage ^
  mcTarget1.png
Image

Code: Select all

magick ^
  -size 200x200 xc:Black ^
  -fill White -draw "circle 100,100 100,200" ^
  -fill Black -draw "circle 100,100 100,180" ^
  -fill White -draw "circle 100,100 100,160" ^
  -fill Black -draw "circle 100,100 100,140" ^
  -fill White -draw "circle 100,100 100,120" ^
  mcTarget2.png
Image
The circular target is better when you don't care about the orientation.