Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MIF
Workflow
LUT-creation
Commits
a4d7c70b
Commit
a4d7c70b
authored
Nov 19, 2018
by
137410
Browse files
Update lut-creation.py
parent
80dec9c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
lut-creation.py
View file @
a4d7c70b
...
...
@@ -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,26 +106,30 @@ 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
)
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
)
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
]
...
...
@@ -131,9 +142,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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment