Enhancing multiscrop

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
TedBaker
Posts: 36
Joined: 2017-10-10T14:14:55-07:00
Authentication code: 1151

Enhancing multiscrop

Post by TedBaker » 2017-10-13T12:53:47-07:00

Problem:

Looking for some pointers on how to control the mask so that it is automatically modified to match the red areas in this example https://ibb.co/j0mjYw i.e. the new mask should be the largest rectangle with all sides 90degrees that will fit within the existing mask.

i.e. thinking to build the mask in two steps but help would be appreciated!

Background:

I am working on a project to better automate flatbed scanning.

The current problem is to use multicrop to split 4 strips from this example image https://ibb.co/hYwi6G

its important for the subsequent steps that image NOT be rotated so -u 3 should be used, and that resulting crops do not have of the original border color contained in them.

I modified the script to allow negative values for -e extend option, and this works when you know how much to remove...
I also tried value setting a high fuzzy value and discard value but this sometimes cuts the strip.

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Enhancing multiscrop

Post by fmw42 » 2017-10-13T13:38:25-07:00

TedBaker wrote:Looking for some pointers on how to control the mask so that it is automatically modified to match the red areas in this example https://ibb.co/j0mjYw i.e. the new mask should be the largest rectangle with all sides 90degrees that will fit within the existing mask.
This would be a post processing step after extracting the individual images using multicrop2. See my script autotrim. For example:

Input:
Image

Code: Select all

autotrim -m inner -p save img.png img_crop.png
Crop Box:
Image

Cropped Image:
Image

TedBaker
Posts: 36
Joined: 2017-10-10T14:14:55-07:00
Authentication code: 1151

Re: Enhancing multiscrop

Post by TedBaker » 2017-10-13T14:19:48-07:00

Thanks that amazing! It worked with original multicrop.

what is the difference between multicrop2 and the original? I am running imagemagick 6.8.9-9 so I will need to upgrade to use multicrop2.

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Enhancing multiscrop

Post by fmw42 » 2017-10-13T14:48:22-07:00

Two minor differences.

Multicrop uses a grid to located large regions for cropping and prunes small regions using -morphology

Multicrop2 uses connected components to locate all regions and also to throw out small regions. It is the connected components IM tool that requires a higher version of ImageMagick.

TedBaker
Posts: 36
Joined: 2017-10-10T14:14:55-07:00
Authentication code: 1151

Re: Enhancing multiscrop

Post by TedBaker » 2017-10-13T15:47:10-07:00

Thanks for all the help!

I ran a final multicrop on the single strips to create the separate frames, and that works well.

I need to test it a bit more and improve my own scripts that drive the process. I can think of useful enhancement to the multicrop, to do with the -b and -c options, but I have not quite thought it through yet, I just noticed the -g option...

Will post my scripts, and put on git hub once I have it working nicely.

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Enhancing multiscrop

Post by fmw42 » 2017-10-13T17:05:54-07:00

If you post your versions to Git Hub, then you need to include a page about my licensing terms.

TedBaker
Posts: 36
Joined: 2017-10-10T14:14:55-07:00
Authentication code: 1151

Re: Enhancing multiscrop

Post by TedBaker » 2017-10-14T02:28:04-07:00

fmw42 wrote:
2017-10-13T17:05:54-07:00
If you post your versions to Git Hub, then you need to include a page about my licensing terms.
Thanks for the reminder will contact you when I get to that stage, to ensure that I do that correctly.

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Enhancing multiscrop

Post by fmw42 » 2017-10-14T10:13:05-07:00

I will be looking into linking multicrop with autotrim so you can do it all at the same time. You will still need to have autotrim, since multicrop will just make a call to autotrim.

User avatar
fmw42
Posts: 22101
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Enhancing multiscrop

Post by fmw42 » 2017-10-18T13:24:00-07:00

I have just uploaded new versions of multicrop and multicrop2 that permit innertrim of the regions. Updated versions of unrotate and autotrim are needed if using -u 2 (unrotate script) or -i yes (autotrim script). The -e argument allows negative values so that even without innertrim, the results may be made smaller to remove excess border.

Post Reply