How to detect a custom border (rectangle) inside an image?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rayern
Posts: 1
Joined: 2017-02-28T02:38:59-07:00
Authentication code: 1151

How to detect a custom border (rectangle) inside an image?

Post by rayern »

I have an image in which there is a rectangle with custom border (anyhow I want). There is an image drawn inside the rectangle.I need to crop the outer image to the rectangle border.So I need to detect the rectangle border inside the image.Any ideas how do I do that? I've looked at 'Imagick' but I cant seem to find out a solution. Any help would be appreciated

I want to then crop the image inside the rectangle.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to detect a custom border (rectangle) inside an image?

Post by Bonzo »

I would suggest you upload an image somewhere and share a link here.

Also what version of Imagemagick you are using along with your preferred code - you want to use Imagick?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to detect a custom border (rectangle) inside an image?

Post by snibgo »

If your custom border is visually distinctive, this is possible. For example, the border contains a distinctive colour such as pure red that does not occur elsewhere. Then you can simply turn all non-red pixels white, and "trim" gives the location of the border.

The same principle applies to any distinctive marking.

I'm moving this to the Users forum.
snibgo's IM pages: im.snibgo.com
Post Reply