我想知道有人会如何裁剪8个不相等的图像 和尺寸是未知的(我可以尝试一些,但def不相同的大小)。
示例:http://i.imgur.com/YG92jJH.jpg
使用灰色框之间的空白区域。
基本上是转入,例如(原文的右上角):http://i.imgur.com/swKDTnn.jpg
答案 0 :(得分:2)
您应首先使用multicrop的imagemagick脚本开关。
$ bash multicrop multicrop: Revised by Anthony Thyssen to add -b option ... revised 8/24/2010 Developed by Fred Weinhaus 1/30/2010 .......... revised 7/7/2010 USAGE: multicrop [-c coords] [-b bcolor] [-f fuzzval] [-g grid] [-u unrotate] [-m mask] infile outfile USAGE: multicrop [-h or -help] OPTIONS: -c coords pixel coordinate to extract background color; may be expressed as gravity value (NorthWest, etc) or as "x,y" value; default is NorthWest=(0,0) -b bcolor background color to use instead of option -c; any valid IM color; default is to use option -c -f fuzzval fuzz value for separating background color; expressed as (integer) percent 0 to 100; default=0 (uniform color) -g grid grid spacing in both x and y as percent of image width and height; used to locate images; integer>0; default=10; -u unrotate unrotate method; choices are 1 for -deskew, 2 for unrotate script and 3 for no unrotate; default=1 -m mask mask presentation method; choices are view, save (to file) or output mask only; default is none of the above, just output the images NAME: MULTICROP PURPOSE: To crop and unrotate multiple images from a scanned image. DESCRIPTION: MULTICROP crops and unrotates multiple images from a scanned image. The images must be well separated so that background color shows between them. The process uses a floofill technique based upon a seed coordinate and a fuzz value to separate the individual images from the background of the scan. The correct choice of fuzz factor is very important. If too small, the images will not be separate. If too larger, parts of the outer area of the image containing similar colors will be lost and the image may be separated into multiple parts. There are two unrotate methods. The first uses the IM deskew function, but is limited to 5 degrees of rotate or less. The second uses my unrotate script. It allows much larger rotations, but will be slower. If using the second method, my unrotate script must be downloaded and installed. IMPORTANT: The images in the scanned file must be well separated in x and y so that their bounding boxes do not overlap. This is especially important if the images have a significant rotation. The output images will be named from the specified outfile and -0, -1, etc, will be appended before the .suffix. Arguments: -c coords ... COORDS is any location within the background (non-image) area for the algorithm to find the background color. It may be specified in terms of gravity parameters (NorthWest, North, NorthEast, East, SouthEast, South, SouthWest or West) or as a pixel coordinate "x,y". The default is the upper left corner = NorthWest = "0,0". -b bcolor ... BCOLOR is the background color to use for flood fill instead of extracting this color from the image. This is useful when an image has no borders with sub-images hard against the edges. Any valid IM color is allowed. The default is to use option -c. -f fuzzval ... FUZZVAL is the fuzz amount specified as an integer percent value between 0 to 100 (without the % sign). The correct choice of fuzz factor is very important. If too small, the images will not be separate. If too larger, parts of the outer area of the image containing similar colors will be lost and the image may be separated into multiple parts. Typical values are probably between 5 and 20 percent. The default=10 -g grid ... GRID is the grid spacing for testing points in the input image to see if they are background or image. The grid value is specified as an integer percent greater than 0 and less than 100 of the width and height of the input image. The default=10. -u unrotate ... UNROTATE is the unrotation method. Choices are: 1, 2 or 3. The default is unrotate=1, which is fast and uses the IM -deskew function, but is limited to images that are rotated no more than 5 degrees in the scan. Option unrotate=2 uses my unrotate script. It can handle larger rotations, but is slower. If using the latter method, my unrotate script must be downloaded and also installed so that it is available for this script to use. Option unrotate=3 makes no attempt to unrotate the images. -m mask ... MASK provides several options for reviewing the initial mask that is generated by the fuzz value. The choices are: view (display to X11 window), save (to disk) along with the images, or output (without processing the images). The default is to simply process the images without showing or saving the mask. If using the view mode, then processing will stop until the image is closed. But this allows you to then kill the script if the mask is not appropriate. A good approach is to use the output mode repeatedly with various fuzzvals until a reasonable mask is created. Note that the mask must separate the images, but the background can "eat" a little into the images so long as no full edge is lost or the images is split into multiple parts. NOTE: If using unrotate method 2, then my script, unrotate, is required as well. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.