Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio |PyJEM| Search

 

Remove or Restore Calibration
Function
Removes a calibration from an image temporarily. This can subsequently be restored.
Version
version:20030702, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments
Handy for those ocassions where image measurements are easiest in pixels rather than calibrated units.
System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
-
Supported
Yes
Included Files
Main script file.
Source Code

// Script to remove any calibration on an image

// The original calibration is written to the image as a note.

// This calibration can be restored at a later date if desired by this script.

// D. R. G. Mitchell, July 2003

// version:20030702, v1.0

// adminnospam@dmscripting.com (remove the nospam to make this email address work)

 

number scalex, scaley

string unitstring

 

image img:=getfrontimage()

 

if(twobuttondialog("Remove or Restore a Calibration", "Remove", "Restore"))

{

// Removes the current calibration

getscale(img, scalex, scaley)

getunitstring(img, unitstring)

if(unitstring!="")

{

setnumbernote(img,"Former Calibration:X Calibration", scalex)

setnumbernote(img,"Former Calibration:Y Calibration", scaleY)

setstringnote(img,"Former Calibration:Units", unitstring)

}

setscale(img, 1, 1)

setunitstring(img,"")

okdialog("Calibration Removed")

}

 

else

 

{

// Restores a previously removed calibration

 

if(!getnumbernote(img,"Former Calibration:X Calibration", scalex))

{

beep()

okdialog("There is no stored former calibration for this image!")

exit(0)

}

getnumbernote(img,"Former Calibration:Y Calibration", scaleY)

getstringnote(img,"Former Calibration:Units", unitstring)

deletenote(img, "Former Calibration")

 

setscale(img, scalex, scaley)

setunitstring(img, unitstring)

okdialog("Calibration Restored")

}