2 Macro AlignToP

Lets take a look at an example macro.

Example 1. AlignToP.txt


MacroName AlignToP
#  
# a macro to align to an image in buffer P
# 
# 2014-10-05 01:54:26

## get unbinned camera size
CameraProperties
SIZE_X = $reportedValue1
SIZE_Y = $reportedValue2

## get image parameters in buffer P
ImageProperties P

X = $reportedValue1
Y = $reportedValue2
bin = $reportedValue3
E = $reportedValue4
PixelSize = $reportedValue5
S = $reportedValue6

# figure out from which set the image was taken
#(0=view, 1=focus, 2=trial, 3=record, 4=preview)
If $S == 0 OR $S == 5
   shot = View
Elseif $S == 1
   shot = Focus
Elseif $S == 2
   shot = Trial
Elseif $S == 3
   shot = Record
Elseif $S == 4
   shot = Preview
Endif

# unbinned image sizes
# need to special treat for super-res mode

If $bin == 0.5
   x_unbin = $X 
   y_unbin = $Y 
# the actual camera sizes are doubled of physical
# camera size reported for Super-Res mode of K2
   SIZE_X = $SIZE_X / $bin
   SIZE_Y = $SIZE_Y / $bin
Else
   x_unbin = $X * $bin
   y_unbin = $Y * $bin
Endif

l = $SIZE_X - $x_unbin
L = $l / 2
R = $L + $x_unbin
t = $SIZE_Y - $y_unbin
T = $t / 2
B = $T + $y_unbin

SetExposure $S $E
SetBinning $S $bin
SetCameraArea $S $L $R $T $B

## align
Loop 2
$shot
AlignTo P
ResetImageShift 
EndLoop 

# reset camera
RestoreCameraSet
      

This macro is to obtain all the camera parameters of the images in buffer P and temporarily uses these parameters to take the shot and align it to buffer P which is a centered hole as template. You don't have to worry about adjusting the camera parameters back and forth. This macro can be run as standalone.