Page 1 of 1

Enhancing multiscrop

Posted: 2017-10-13T12:53:47-07:00
by TedBaker
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.

Re: Enhancing multiscrop

Posted: 2017-10-13T13:38:25-07:00
by fmw42
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

Re: Enhancing multiscrop

Posted: 2017-10-13T14:19:48-07:00
by TedBaker
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.

Re: Enhancing multiscrop

Posted: 2017-10-13T14:48:22-07:00
by fmw42
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.

Re: Enhancing multiscrop

Posted: 2017-10-13T15:47:10-07:00
by TedBaker
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.

Re: Enhancing multiscrop

Posted: 2017-10-13T17:05:54-07:00
by fmw42
If you post your versions to Git Hub, then you need to include a page about my licensing terms.

Re: Enhancing multiscrop

Posted: 2017-10-14T02:28:04-07:00
by TedBaker
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.

Re: Enhancing multiscrop

Posted: 2017-10-14T10:13:05-07:00
by fmw42
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.

Re: Enhancing multiscrop

Posted: 2017-10-18T13:24:00-07:00
by fmw42
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.