dm script - How do I rotate an image by an arbitrary amount? -
i have digitalmicrograph image rotate amount (not 90 degree). can done menu item "process...\rotate" script. have script computes angle based on line-roi found on image. (see below), not know how can rotate image.
number kpi = 3.14159265359 image front end := getfrontimage() imagedisplay fdisp = front.imagegetimagedisplay(0) roi line = fdisp.imagedisplaygetroi(0) if ( line.roiisvalid() ) { if ( line.roiisline() ) { number sx,sy,ex,ey line.roigetline(sx,sy,ex,ey) number dy = ey - sy number dx = ex - sx number angle = atan( dy / dx ) * 180/kpi if ( dx < 0 ) angle = angle + 180 result("\n rotate image " + angle + " degree.") } }
nice thought tool , coding far.
the command looking called rotate()
. 've perchance missed in help documentation because (unfortunately) not listed in 'image' section. there dedicated "reference" section meant summarize "simple" script commands of everyday quick-scripting:
with command, script can modified 1 below. note i've replaced kpi
command pi()
. rotate()
command requires rotation angle given in radians. size of resulting image enlarged , image zero-padded. also: i've replaced if - statement abbreviated version.
image front end := getfrontimage() imagedisplay fdisp = front.imagegetimagedisplay(0) roi line = fdisp.imagedisplaygetroi(0) if ( line.roiisvalid() ) { if ( line.roiisline() ) { number sx, sy, ex, ey line.roigetline( sx, sy, ex, ey ) number dy = ey - sy number dx = ex - sx number angle = atan( dy / dx ) + ( dx < 0 ? pi() : 0 ) image out := front.rotate( angle ) out.showimage() } }
image-rotation dm-script
No comments:
Post a Comment