Commit a4d7c70b authored by 137410's avatar 137410
Browse files

Update lut-creation.py

parent 80dec9c0
...@@ -34,6 +34,13 @@ def create_LUT(fi=None): ...@@ -34,6 +34,13 @@ def create_LUT(fi=None):
rs = [0, 0, 0, 0, 0, 0,175,255,255] rs = [0, 0, 0, 0, 0, 0,175,255,255]
gs = [0, 78,150,240,255,240,175,125, 0] gs = [0, 78,150,240,255,240,175,125, 0]
bs = [0, 0, 0, 0, 0, 0, 0, 0, 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] ip = [ int(f*256) for f in fs]
r = [] r = []
g = [] g = []
...@@ -49,9 +56,9 @@ def create_LUT(fi=None): ...@@ -49,9 +56,9 @@ def create_LUT(fi=None):
b = b + [ b0+db*j/di for j in range(di) ] b = b + [ b0+db*j/di for j in range(di) ]
return r,g,b return r,g,b
imp = IJ.getImage()
imp = IJ.getImage()
lut = imp.getLuts()[0] lut = imp.getLuts()[0]
bytes = lut.getBytes() bytes = lut.getBytes()
...@@ -71,14 +78,14 @@ def plat( x, Pm, a, b ): ...@@ -71,14 +78,14 @@ def plat( x, Pm, a, b ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if( isinstance(x,list) ): if( isinstance(x,list) ):
#print("here") #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: 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 ): def plat_max(Pm, a, b ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Iop = -math.log( b/(a+b))/a Iop = -math.log( b/(a+b))*Pm/a
return [Iop,plat(Iop,Pm,a,b),] return [Iop,plat(Iop,Pm,a,b)]
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def find_root( f, x0s, v, *args ): def find_root( f, x0s, v, *args ):
...@@ -99,26 +106,30 @@ if( True): ...@@ -99,26 +106,30 @@ if( True):
rs,gs,bs = create_LUT() rs,gs,bs = create_LUT()
lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) ) 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. # create the ETR plot
b = 1./2000. I = [ Imax*i/200 for i in range(201)]
Imax = 10000.
pmax = plat_max(1,a,b) pmax = plat_max(Pm,a,b)
print(pmax)
I2 = pmax[0] I2 = pmax[0]
I1= find_root(plat, [0.,I2 ],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.8*pmax[1], 1.,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], 1.,a,b) I4= find_root(plat, [I3,I3*2 ],0.5*pmax[1], Pm,a,b)
print(I1,I2,I3,I4) print(I1,I2,I3,I4)
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.] 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.]
print(fs) print(fs)
rs,gs,bs = create_LUT(fi=fs) rs,gs,bs = create_LUT(fi=fs)
lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) ) lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) )
xs = [I1,I2,I3,I4] xs = [I1,I2,I3,I4]
Vs = plat(I,1.,a,b) Vs = plat(I,Pm,a,b)
plot = Plot("Plat","Light","ETR",I,Vs) plot = Plot("Plat","Light","ETR",I,Vs)
for j in range(1,len(I)): for j in range(1,len(I)):
i =I[j] i =I[j]
...@@ -131,9 +142,19 @@ if( True): ...@@ -131,9 +142,19 @@ if( True):
plot.add("filled",[I[j-1],I[j]],[Vs[j-1],Vs[j]]) plot.add("filled",[I[j-1],I[j]],[Vs[j-1],Vs[j]])
print(xs) print(xs)
plot.setColor(Color(0,0,0)) 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() 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) imp.setLut(lut)
\ No newline at end of file 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