mirror of
https://github.com/oDinZu/callirhoe.git
synced 2025-02-23 00:02:16 -05:00
new test operation: crop
git-svn-id: https://callirhoe.googlecode.com/svn/trunk@139 81c8bb96-aa45-f2e2-0eef-c4fa4a15c6df
This commit is contained in:
parent
04a62f5d8a
commit
cd1df2cdf9
20
calmagick.py
20
calmagick.py
@ -131,10 +131,11 @@ months are requested.""", version="calmagick " + _version)
|
|||||||
parser.add_option("--negative", type="float", default=100,
|
parser.add_option("--negative", type="float", default=100,
|
||||||
help="average luminosity (0-255) threshold of the overlaid area, below which a negative "
|
help="average luminosity (0-255) threshold of the overlaid area, below which a negative "
|
||||||
"overlay is chosen [%default]")
|
"overlay is chosen [%default]")
|
||||||
parser.add_option("--test", type="int", default=0,
|
parser.add_option("--test", type="choice", choices="none area quant print crop".split(), default='none',
|
||||||
help="test entropy minimization algorithm, without creating any calendar: 0=test disabled, "
|
help="test entropy minimization algorithm, without creating any calendar, TEST should be among "
|
||||||
"1=show area in original image, 2=show area in quantizer, 3=print minimum entropy area in STDOUT as X Y W H, "
|
"{none, area, quant, print, crop}: none=test disabled; "
|
||||||
"without generating any files at all [%default]")
|
"area=show area in original image; quant=show area in quantizer; print=print minimum entropy area in STDOUT as X Y W H, "
|
||||||
|
"without generating any files at all; crop=crop selected area [%default]")
|
||||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||||
help="print progress messages")
|
help="print progress messages")
|
||||||
|
|
||||||
@ -248,17 +249,20 @@ def compose_calendar(img, outimg, options, callirhoe_args, magick_args):
|
|||||||
dx = int(float(w*best[2])/pnm_entropy.size[0])
|
dx = int(float(w*best[2])/pnm_entropy.size[0])
|
||||||
dy = int(float(h*best[3])/pnm_entropy.size[1])
|
dy = int(float(h*best[3])/pnm_entropy.size[1])
|
||||||
|
|
||||||
if options.test:
|
if options.test != 'none':
|
||||||
if options.test == 1:
|
if options.test == 'area':
|
||||||
subprocess.call(['convert', img] + magick_args[0] + ['-region', '%dx%d+%d+%d' % (nw,nh,dx,dy),
|
subprocess.call(['convert', img] + magick_args[0] + ['-region', '%dx%d+%d+%d' % (nw,nh,dx,dy),
|
||||||
'-negate', outimg])
|
'-negate', outimg])
|
||||||
elif options.test == 2:
|
elif options.test == 'quant':
|
||||||
subprocess.call(['convert', img] + magick_args[0] +
|
subprocess.call(['convert', img] + magick_args[0] +
|
||||||
"-scale 512> -define convolve:scale=! -define morphology:compose=Lighten -morphology Convolve Sobel:> -colorspace Gray -normalize -unsharp 0x5 -scale".split() +
|
"-scale 512> -define convolve:scale=! -define morphology:compose=Lighten -morphology Convolve Sobel:> -colorspace Gray -normalize -unsharp 0x5 -scale".split() +
|
||||||
[resize, '-scale', '%dx%d!' % (w,h), '-region', '%dx%d+%d+%d' % (nw,nh,dx,dy),
|
[resize, '-scale', '%dx%d!' % (w,h), '-region', '%dx%d+%d+%d' % (nw,nh,dx,dy),
|
||||||
'-negate', outimg])
|
'-negate', outimg])
|
||||||
elif options.test == 3:
|
elif options.test == 'print':
|
||||||
print dx, dy, nw, nh
|
print dx, dy, nw, nh
|
||||||
|
elif options.test == 'crop':
|
||||||
|
subprocess.call(['convert', img] + magick_args[0] + ['-crop', '%dx%d+%d+%d' % (nw,nh,dx,dy),
|
||||||
|
outimg])
|
||||||
return
|
return
|
||||||
|
|
||||||
# measure luminance
|
# measure luminance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user