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?".
I'm quite new to ImageMagick. I have scanned thousands of old slides. On some of them, I have rounded corners I'd like to automatically remove.
The position of the corners is not always the same so applying exactly the same inner cropping would not work.
I would like to detect automatically and crop only the red area, while respecting the ratio of the picture. https://cl.ly/222C1b3w042R
Please say what version of IM you use, on what platform (eg Windows, Unix, etc) and your preferred script language (Windows BAT, bash, etc) if any.
The first image has a "CloudApp" logo bottom-left, obscuring that corner. Has that been added by your hoster? If so, I suggest you upload them to somewhere that doesn't alter your images. For example, put them in zips that you upload to dropbox.com or somewhere.
Doing the crop is easy, with "-crop" or "-shave". Detecting whether it is needed, and how much, is more difficult. The photographed subject may be very dark in the corners, leading to false readings.
A possible approach: from each corner, examine the line at 45 degrees, towards the centre of the image. As we examine pixels from the corner inwards, if there is a jump from almost-black to something lighter, that marks a point for a crop. If all four corners have a jump at a similar distance, use the inner-most as a crop for all four.
(This could be done by rotating the image by 45 degrees, and taking horizontal or vertical crops.)
If two adjacent corners have a jump but the other two don't, do you care what happens? We could assume the other two have a jump in the same places.