Page 1 of 1

How do i use Multicrop

Posted: 2012-04-30T13:40:09-07:00
by breedy256
I am having problem with Multicrop a script from Fred I am not sure what I am doing wrong but I have read all the old message posts and searched Google and I am unable to find the answer to my problem so I figured it is time to ask. I am trying to scan multiple photos in a flatbed scanner and then take that single image and separate them it into individual photo’s.

To execute the script I am typing the following lines.
Convert test3.jpg -trim +repage test3_trim.jpg
./multicrop –b black –f 0 –g 3 test3_trim.jpg test3_trim_crop.jpg
I am not sure if I am typing the wrong attributes or if I need to update an application or something.

Version: ImageMagick 6.6.9-7 2012-02-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

Ubuntu Desktop 11.4
Multicrop - April 20, 2012


http://www.aprilreedy.com/test3.jpg

Re: How do i use Multicrop

Posted: 2012-04-30T15:26:18-07:00
by fmw42
Several problems

1) In your command

multicrop –b black –f 0 –g 3 test3_trim.jpg test3_trim_crop.jpg

You are not using proper minus signs. They are long hyphens and not simple hyphens.

2) Your background is white and not black. But it is easier to use this command. You don't have to trim it first. Your grid can be much coarser, so take the default of 10 (note that is 10 percent of the image size).

multicrop -f 10 -m save test3.jpg test3_trim_crop.jpg


2) After fixing that, the script does not function properly. I will have to look more carefully why your image fails. It seems to work fine for me to reproduce at least one of my examples. That should be the first thing you try so as to get used to the script.

I will get back once I have figured out why your image is failing.

Re: How do i use Multicrop

Posted: 2012-04-30T16:03:11-07:00
by fmw42
The last issue is that the script cannot handle pure black "images" on a white background. The script reserves black for its internal use in masking. Thus when you mask your black on white image you get all black.

Try testing with gray images or some other color or real images.

Try this:


convert 1test3.jpg -fuzz 10% -fill gray -opaque black 1test3a.jpg
multicrop -f 10 -m save 1test3a.jpg 1test3a_crop.jpg

Re: How do i use Multicrop

Posted: 2012-05-01T09:01:03-07:00
by breedy256
Thanks for your help,

I’ve been trying your examples but it is not working for me I suspect because the actual image is different than the example photo I gave you. I did not know I need to scan them on a black background that’s good to know. Would you look at the attacked URL and give me suggestions on how to accomplish this with real images? I’ll find a sheet of black plastic to stick on the white cover.

I was trying but my convert options I was trying was changing the pictures inside the image. I’ll play with it more tonight and see if I can figure it out. Thanks again for your help and fast response.

http://www.aprilreedy.com/Image0001.JPG

Re: How do i use Multicrop

Posted: 2012-05-01T10:00:28-07:00
by fmw42
breedy256 wrote:Thanks for your help,

I’ve been trying your examples but it is not working for me I suspect because the actual image is different than the example photo I gave you. I did not know I need to scan them on a black background that’s good to know. Would you look at the attacked URL and give me suggestions on how to accomplish this with real images? I’ll find a sheet of black plastic to stick on the white cover.

I was trying but my convert options I was trying was changing the pictures inside the image. I’ll play with it more tonight and see if I can figure it out. Thanks again for your help and fast response.

http://www.aprilreedy.com/Image0001.JPG
You do not need a black background. What you do not want is an all black image.

Your problem with this image is two-fold.

First you have a black border around the outside. If you can avoid that, then it should work better. If not, then you need to shave off the black border around the outside.

Second your images have shadows around them. This will prevent the script from cropping exactly at the image borders. You will get some of the shadow. However, it still separates the images.

So try this:

convert Image0001.JPG -shave 50x50 Image0001_shave.JPG
multicrop -f 12 -m save Image0001_shave.JPG Image0001_crop.jpg


You can try increasing the -f value to see if you can get more of the shadow removed. I tried as much as 15, but not sure it was much better. You can add -m save and be able to look at the mask that separates the images to help judge what -f value might be best. I have added it above so that I could look at it and then adjust the -f value. But you can remove it if things start working well for your images.

Re: How do i use Multicrop

Posted: 2012-05-01T11:44:42-07:00
by breedy256
Fred,

That is working pretty good, I am still fairly new to ImagemagicK and Linux for that matter I've just been winging it. It appears to crop 37 images that are 1x1 and the three real images i wanted cropped. and it displays a warning on each of the small images. -f 12 looks like the best one I will try a few more scans and see how they turn out.

convert: geometry does not contain image './multicrop_1_12300.mcp' @ warning/attribute.c/GetImageBoundingBox/239.

Is there a way to tell it to look for a box that is pretty big? to avoid 1x1 images, or does that cause more problems? If nothing I'll just make a script that looks for supper small files and erases them.

Again thanks so much for your help.

Re: How do i use Multicrop

Posted: 2012-05-01T12:02:57-07:00
by breedy256
Fred,

Nevermind i figured it out, I looked a little deeper and noticed your -g option, Which is should have looked for before posting.

Thanks a ton for your help.