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.
Enhancing multiscrop
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancing multiscrop
This would be a post processing step after extracting the individual images using multicrop2. See my script autotrim. For example: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.
Input:
Code: Select all
autotrim -m inner -p save img.png img_crop.png
Cropped Image:
Re: Enhancing multiscrop
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancing multiscrop
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.
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
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancing multiscrop
If you post your versions to Git Hub, then you need to include a page about my licensing terms.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancing multiscrop
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancing multiscrop
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.