34 lines
960 B
Python
34 lines
960 B
Python
import java.awt.Rectangle as Rectangle
|
|
|
|
import ch.psi.pshell.imaging.Data as Data
|
|
class Exposure(Writable):
|
|
def write(self,pos):
|
|
#cam.setExposure(pos)
|
|
img.camera.setExposure(pos)
|
|
exposure=Exposure()
|
|
|
|
|
|
class Contrast(Readable):
|
|
def read(self):
|
|
data = img.getData()
|
|
#roi = Data(data.getRectSelection(500,300,700,600), False)
|
|
#return data.getGradientVariance(False, Rectangle(480,0,600,670))
|
|
return data.getGradientVariance(False, None)
|
|
contrast=Contrast()
|
|
|
|
|
|
#a= lscan(exposure,img.getContrast(), 0.5, 1.0, 0.01, 0.5)
|
|
#a= lscan(exposure,contrast, 0.2, 0.4, 0.01, 0.7)
|
|
ret= lscan(exposure,contrast, 10.0, 150.0, 5.0, 0.5)
|
|
y, x = ret.getReadable(0), ret.getPositions(0)
|
|
|
|
#(n, m, s) = fit(a.getReadable(0), xdata=a.getPositions(0))
|
|
#if m is None:
|
|
# m=max(a.getReadable(0))
|
|
m=x[y.index(max(y))]
|
|
p=get_plots()[0]
|
|
p.addMarker(m, p.AxisId.X, str(m), Color.RED)
|
|
|
|
print "Setting exposure = ", m
|
|
exposure.write(m)
|