Scripting Resources for DigitalMicrograph™ |
Image Integration |
|
Function |
Acquires multiple images from a CCD camera and integrates them to increase the effective bit depth and signal/noise ratio. |
Version |
version:20030201, v3.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
Based on a script by P. Ahrenkiel. |
Comments |
|
System Requirements |
Should be compatible with all PC versions of DigitalMicrograph. Expects to find a 1k x 1k camera - has been tested with a GIF2001, and with minor editing a Gatan DualVision camera. |
Known Issues |
Expects to find a camera with 1024 x 1024 pixels. Other camera formats will require minor editing of the script. Instructions are provided in the script heading. |
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
// Image Integration. This script was based on a script by P. Ahrenkiel 7/28/2000 // It was subsequently modified by D. Mitchell to work on a GIF 2000 system with a 1024 x 1024 camera. // Adds multiple exposures into a single image to avoid CCD streaking.
// version:20030201
// If this script won't work with your camera, edit the lines beginning with // SSC. . . . to the command which your camera-type recognises. You will also have to change the // variables height and width if your camera is not a 1024 x 1024 format. // The binning may also be a problem for non-square cameras, if sub areas of the CCD are used. // Under these circumstances 1x binning may be the only setting which works - you can manually // rebin the images (Process/Re-bin by two) later.
// D. Mitchell, Feb 2003, adminnospam@dmscripting.com (remove the nospam to make this email address work)
// v3.0
If (shiftdown()) { documentwindow reswin reswin =getresultswindow(1) if(reswin.windowisvalid()) windowclose(reswin,0) reswin =getresultswindow(1) WindowSetFramePosition( reswin, 140, 400 ) WindowSetFrameSize( reswin, 780, 220 ) WindowSetTitle( reswin, "Instructions")
result("1 This script will collect several images and add them together."+"\n"\ +"2 This is particularly useful when you need greater effective bit depth from your camera."+"\n"\ +"3 For example if you are trying to record both weak and strong diffraction spots."+"\n"\ +"4 You will be asked for the binning - 1x is best for SADPs with very strong spots."+"\n"\ +"5 You will be asked for a cumulative exposure = no of images x individual exposure time."+"\n"\ +"6 The result is a real - 4 byte image. Press the SPACE bar to abort an acquisition."+"\n"\ +"7 If this script won't work with your camera see the script header for some suggestions."+"\n\n"\ +"D. Mitchell, drm@ansto.gov.au, February 2003"+"\n") exit(0) }
// Variables
number height = 1024, width =1024 number top,left,bottom,right number tottime, numexp, exptime, expcount number i number binning=2 image totimg number tempvar=0
// Prompt to obtain the desired binning
While(tempvar<1) { if(!getnumber("Enter required binning . . . 1x, 2x, 4x, 8x", 2, binning)) Exit(0) if (binning==1) tempvar=2 if (binning==2) tempvar=2 if (binning==4) tempvar=2 if (binning==8) tempvar=2 }
// Request the cumulative exposure time (eg 5 images at 1s each = cum exp time of 5s)
top=0 left=0 bottom=round(height/binning) right=round(height/binning)
while (1) { if( GetNumber("Enter cumulative exposure time:",1,tottime)) { if (tottime>= 0.01) break } else { Exit(0) } OKDialog("The exposure time must be at least 0.01 seconds.") }
// Request the total number of exposures
while (1) { if( GetNumber("Enter number of exposures:", 5,numexp)) { if ( numexp>0) break } else { Exit(0) } OKDialog("The number of exposures must be positive.") }
exptime=tottime/numexp
totimg := CreateLongImage("Frame", width/binning, height/binning) ClearImage(totimg) ShowImage(totimg) updateimage(totimg)
expcount=0 image tempimg := CreateShortImage("",width/binning, height/binning)
// Begin acquisition
for (i=1; i<=numexp; i++) { SSCGainNormalizedBinnedAcquireInPlace(tempimg, exptime, binning, top, left,bottom, right) totimg += tempimg UpdateImage(totimg) number numberofimages=expcount+1 openandsetprogresswindow("Image Integration Status","Image "+numberofimages+" of "+numexp,"Completed") expcount++ if( GetKey()==32) break }
SetStringNote(totimg,"number of exposures"," "+expcount) SetStringNote(totimg,"exposure time"," "+exptime+" seconds") openandsetprogresswindow("","","") okdialog("Exposure Complete") |