Scripting Resources for DigitalMicrograph™ |
Acquire Rotate and Crop |
|
Function |
Acquires an image from a CCD camera, then rotates the image and crops it to eliminate the black space introduced by rotation. |
Version |
version:20181004, v1.2 |
Author |
D. R. G. Mitchell |
Acknowledgements |
Thanks to Udit Sharma for suggesting and testing this script. |
Comments |
Engineered microstructures, such as transistors, gates etc are geometrically aligned. When acquiring images of such features using a CCD in TEM mode, the orientation of the features is often inclined relative to the image frame. Post-acquisition rotation and cropping (to eliminate the black space added by rotation) is time consuming. This script automates the acquisition, rotation and cropping process. An image of a representative feature is acquired. The image feature which is required to be either horizontal or vertical is then marked with a line annotation. The script's Measure button will then measure the angle of that line (relative to horizontal). The script allows rotation which would bring that feature to either horizontal or vertical, and the image can also be flipped through 180 degrees. Once set up, all subsequent images acquired through the script will have the same rotation applied. The option to crop out the black space introduced by rotation is given, as is the display of the raw (unrotated) image. |
System Requirements |
Tested on GMS 2.3 but should work with all versions from GMS 2 onwards. Tested on Gatan Orius and Gatan Ultrascan cameras. The script will automatically source the camera size and should work with all modern Gatan cameras. |
Known Issues |
This script works fine on my Orius camera. However, when using it with an Ultrascan (under GMS 2.32), it is flakey if a live View image is open and updating. It occassionally returns a time out error. It works fine if the live View image is not acquiring. The script does not control the low level functions of the camera. Normally, a request for a single frame will stop any live view, then restart the live view after the single frame has been acquired. This is handled by the camera firmware - over which the script has no influence. This error seems to be a firmware issue, rather than a scripting problem since none of several variants of scripts I have tried, using old-style camera commands and current camera manager commands gets around this. The workaround I did find would work was to set the script to capture a 1x binned image from the camera. This image is then software binned after acquisition, according to the binning setting in the dialog. This seems to work flawlessly. The only downside is that 1x binned images are a little slower to acquire. When you download this script it is a zip archive containing 2 scripts - use only one. In the first instance try 'Acquire Rotate and Crop', and see if that will work reliably when you have a live View image updating on the screen. If it works fine - stick with that script. If you find you get timeout errors from the camera and the image will not acquire, abandon the first script and instead try the 'Acquire Rotate and Crop Workaround' script. This is the one which captures at 1x from the camera and then software bins to match the dialog setting. When the Crop option is selected, the script excises the largest square region from the image which excludes the black space introduced by rotation. For small angles of rotation, the excised region will be quite large. However, as the rotation angle increases the excised region shrinks. For this reason it is better to always choose the smaller of the rotation angles needed to bring the feature of interest to either vertical or horizontal. For example, rotate 20 degrees to horizontal, rather than 70 degrees to vertical. If this results in an orientation which you do no you want, then use DigitalMicrograph to rotate the image 90 degrees. |
Supported |
Yes, but please be aware, if I do not have the same camera as you, my ability to troubleshoot is very limited. |
Included Files |
Source code in a zip archive containing two scripts. Use only one of these scripts - see above for detail. |
Source Code |
See attached script |