Page 1 of 1

Crop/Trim picture by specific border inside picture

Posted: 2011-12-01T03:56:19-07:00
by Natural_born_chilla
Hello girls and guys,

I already searched a lot on the internet but I just can't find a solution for this.

I have a picture with background (which needs to be removed) - the background is inhomogeneous, i.e. not of the same color etc.

Inside the picture, there is my wanted content. A border with a color I specified defines the surrounding.

How may I crop it? I tried something with txt to find the color, but I'm on windows and can't use grep. Also, it's very slow.

An example (note: the border in reality is 1px exact and same color anywhere):
Image

Any help and ideas are appreciated!!

Flo

Re: Crop/Trim picture by specific border inside picture

Posted: 2011-12-01T10:35:49-07:00
by fmw42
try a fuzzy floodfill from each corner to get a constant color around the center area. Then use -trim +repage.

see
http://www.imagemagick.org/Usage/draw/#color
http://www.imagemagick.org/Usage/crop/#trim

Re: Crop/Trim picture by specific border inside picture

Posted: 2011-12-02T00:22:41-07:00
by anthony
The other way is to generate a mask of the dividing color. A trim of that mask will then get you the bound by which you can crop the original.

Something similar to this is done (using blur rather than a mask) in
Trimming 'Noisy' Images
http://www.imagemagick.org/Usage/crop/#trim_noisy

Just generate the bounds mask instead of the blurred image.

Re: Crop/Trim picture by specific border inside picture

Posted: 2011-12-02T01:54:45-07:00
by Natural_born_chilla
Insane! Works like a charm!

I am very thankful for the tip. My solution is just straight forward, I use filltoborder with my specified border color, then trim and repage.

Thank you very much! May the force be with both of you :)