Commit 43f793d3 authored by Chris Evenhuis's avatar Chris Evenhuis
Browse files

Merge branch 'master' of code.research.uts.edu.au:MIF/Workflows/lut-creation

parents 470ef3b4 345428bc
......@@ -34,6 +34,13 @@ def create_LUT(fi=None):
rs = [0, 0, 0, 0, 0, 0,175,255,255]
gs = [0, 78,150,240,255,240,175,125, 0]
bs = [0, 0, 0, 0, 0, 0, 0, 0, 0]
#black green orange
# | | | red
# | | | |
rs = [0, 0, 0, 0, 0, 0,255,255, 255]
gs = [0, 78,150,240,255, 255,255,125, 0]
bs = [0, 0, 0, 0, 0, 0, 64, 0, 0]
ip = [ int(f*256) for f in fs]
r = []
g = []
......@@ -49,9 +56,9 @@ def create_LUT(fi=None):
b = b + [ b0+db*j/di for j in range(di) ]
return r,g,b
imp = IJ.getImage()
imp = IJ.getImage()
lut = imp.getLuts()[0]
bytes = lut.getBytes()
......@@ -71,14 +78,14 @@ def plat( x, Pm, a, b ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if( isinstance(x,list) ):
#print("here")
return [ Pm*(1.-math.exp(-I*a))*math.exp(-I*b) for I in x ]
return [ Pm*(1.-math.exp(-I*a/Pm))*math.exp(-I*b/Pm) for I in x ]
else:
return Pm*(1.-math.exp(-x*a))*math.exp(-x*b)
return Pm*(1.-math.exp(-x*a/Pm))*math.exp(-x*b/Pm)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def plat_max(Pm, a, b ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Iop = -math.log( b/(a+b))/a
return [Iop,plat(Iop,Pm,a,b),]
Iop = -math.log( b/(a+b))*Pm/a
return [Iop,plat(Iop,Pm,a,b)]
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def find_root( f, x0s, v, *args ):
......@@ -99,25 +106,34 @@ if( True):
rs,gs,bs = create_LUT()
lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) )
# create the ETR plot
I = [ 10000*i/200 for i in range(201)]
Imax = 7500.
Pm = 135.2
a = 0.87
b = 0.05
a = 1./1000.
b = 1./2000.
Imax = 10000.
# create the ETR plot
I = [ Imax*i/200 for i in range(201)]
pmax = plat_max(1,a,b)
pmax = plat_max(Pm,a,b)
print(pmax)
I2 = pmax[0]
I1= find_root(plat, [0.,I2 ],0.5*pmax[1], 1.,a,b)
I3= find_root(plat, [I2,I2*2 ],0.8*pmax[1], 1.,a,b)
I4= find_root(plat, [I3,I3*2 ],0.5*pmax[1], 1.,a,b)
I1= find_root(plat, [0.,I2 ],0.5*pmax[1], Pm,a,b)
I3= find_root(plat, [I2,I2*2 ],0.95*pmax[1], Pm,a,b)
I4= find_root(plat, [I3,I3*2 ],0.5*pmax[1], Pm,a,b)
<<<<<<< HEAD
fs = [0., 0.5*I1/I4, I1/I4,0.5*(I1+I2)/I4, I2/I4, 0.5*(I2+I3)/I4, I3/I4, 0.5*(I3+I4)/I4, 1.]
=======
print(I1,I2,I3,I4)
fs = [0., 0.5*I1/I4, I1/I4,0.5*(I1+I2)/I4, I2/I4, I3/I4, I3/I4, 0.5*(I3+I4)/I4, 1.]
>>>>>>> 345428bc9fabd5f3d21977483345cd0aa9128604
print(fs)
rs,gs,bs = create_LUT(fi=fs)
lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) )
xs = [I1,I2,I3,I4]
Vs = plat(I,1.,a,b)
Vs = plat(I,Pm,a,b)
plot = Plot("Plat","Light","ETR",I,Vs)
for j in range(1,len(I)):
i =I[j]
......@@ -130,9 +146,19 @@ if( True):
plot.add("filled",[I[j-1],I[j]],[Vs[j-1],Vs[j]])
print(xs)
plot.setColor(Color(0,0,0))
plot.add('circles', xs, plat( xs,1,a,b) )
plot.add('circles', xs, plat( xs,Pm,a,b) )
plot.show()
ip = imp.getProcessor().duplicate()
ip.setMinAndMax(0.,I1)
from ij.plugin.filter import ThresholdToSelection as TS
mask = ip.createMask()
print(type(mask))
dfjk
roi = TS().convert(mask)
#imp.setRoi(roi)
imp.setLut(lut)
\ No newline at end of file
imp.setLut(lut)
imp.setDisplayRange(0,I4)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment