Scripting Resources for DigitalMicrograph™ |
Zoom to ROI |
|
Function |
Zooms the region defined by a region of interest (ROI) to fill the current bounds of the image window. Click on the maximise button (top right of the image window) to restore. |
Version |
version:20050408, v1.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
Thanks to Douglas Hague (Gatan) for tips on using the various co-ordinate systems of DM. |
Comments |
This functionality has been built into the DisplayTools suite of scripts. |
System Requirements |
Should be compatible with all recent versions of DigitalMicrograph. |
Known Issues |
Needs an image with a ROI fitted to be foremost. |
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
// A simple script which will zoom the foremost image to the // region of interest (ROI). The ROI will be zoomed as large as possible to fit // into the current window. To restore the image, click on the // square box button at the top right of the image.
// D. R. G. Mitchell, adminnospam@dmscripting.com (remove the nospam to make this email address work)
// version:20050408 // Thanks to D. Hague (Gatan) for the tips on using the various co-ordinate systems.
// Variables
number top, left, bottom, right number i2voffx, i2voffy, i2vscalex, i2vscaley number vleft, vright, vtop, vbottom
// Source the foremost image
image front:=getfrontimage() imagedocument imgdoc=getfrontimagedocument()
number zoom=getzoom(front) imagedisplay imgdisp=imagegetimagedisplay(front,0) number roinumber=imgdisp.imagedisplaycountrois()
// Check for an ROI
if(roinumber!=1) { beep() okdialog("A rectangular Region Of Interest (ROI) must be present in the foremost image for this script to work!") exit(0) }
// Source the position of the ROI in image co-ordinates
roi theroi=imgdisp.imagedisplaygetroi(0) roigetrectangle(theroi, top, left, bottom, right)
// Get the transform for the image to view co-ordinate transformation and generate the view co-ordinates for the zoom
imgdisp.ComponentGetChildToviewTransform(i2voffx, i2voffy, i2vscalex, i2vscaley) objecttransformtransformrect(i2voffx, i2voffy, i2vscalex, i2vscaley, top, left, bottom, right,vtop, vleft, vbottom, vright)
// Use the view co-ordinates to zoom the image
ImageDocumentMaximizeRectInView( imgDoc, vtop, vleft, vbottom, vright ) |