Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python3-imagej-tiff
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
python3-imagej-tiff
Commits
2b76d3d7
Commit
2b76d3d7
authored
Jul 12, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tested
parent
f165ea44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
116 deletions
+12
-116
test_packing.py
test_packing.py
+12
-116
No files found.
test_packing.py
View file @
2b76d3d7
...
...
@@ -16,72 +16,18 @@ import itertools
import
pack_tile
as
pile
# hard coded layers names
#lst = ['diagm-pair','diago-pair']
#lut['diagm-pair']
#stack = ijt.getstack(lst)
#out = []
#for item in lst:
# layer = pack_layer(tile[labels.index(item)],lut[item])
# out.append(layer)
#return out
def
get_packed_square
(
tiles
,
values
,
lut
,
i
,
j
,
radius
):
out
=
np
.
array
([])
# max
Y
=
tiles
.
shape
[
0
]
X
=
tiles
.
shape
[
1
]
#print("Number of elements: "+str(2*radius+1))
#for k in range(1):
# print(k)
for
k
in
range
(
2
*
radius
+
1
):
y
=
i
+
k
-
radius
if
y
<
0
:
y
=
0
elif
y
>
(
Y
-
1
):
y
=
Y
-
1
for
l
in
range
(
2
*
radius
+
1
):
x
=
j
+
l
-
radius
if
x
<
0
:
x
=
0
elif
x
>
(
X
-
1
):
x
=
X
-
1
#print(str(k)+" "+str(l))
# tiles[y,x] and lut are with layers
packed_tile
=
pack_tile
(
tiles
[
y
,
x
],
lut
)
#packed_tile = np.array([])
out
=
np
.
append
(
out
,
packed_tile
)
return
out
# VARS
# tiff name
tiff_name
=
"1521849031_093189-ML_DATA-08B-O-OFFS1.0.tiff"
# packing table name
ptab_name
=
"tile_packing_table.xml"
# CONSTANTS
RADIUS
=
1
LAYERS_OF_INTEREST
=
[
'diagm-pair'
,
'diago-pair'
]
LAYERS_OF_INTEREST
=
[
'diagm-pair'
,
'diago-pair'
,
'hor-pairs'
,
'vert-pairs'
]
# MAIN
# get packing table
pt
=
pile
.
PackingTable
(
ptab_name
,
LAYERS_OF_INTEREST
)
.
lut
# get tiff
tiff
=
ijt
.
imagej_tiff
(
tiff_name
)
tiles
=
tiff
.
getstack
(
LAYERS_OF_INTEREST
,
shape_as_tiles
=
True
)
...
...
@@ -100,75 +46,25 @@ for y,x in itertools.product(range(l.shape[0]),range(l.shape[1])):
print
(
l
)
l_packed
=
pile
.
pack_layer
(
l
,
pt
[
0
])
l2
=
np
.
reshape
(
l
,(
1
,
1
,
9
,
9
))
l_stack
=
np
.
stack
((
l2
,
l2
,
l2
,
l2
),
axis
=-
1
)
#print(l_packed.shape)
#print(l_packed)
# a few assertions
assert
l_packed
[
0
]
==
(
l
[
0
,
2
]
*
1.0
+
l
[
0
,
3
]
*
1.0
+
l
[
0
,
4
]
*
1.0
+
l
[
0
,
5
]
*
1.0
+
l
[
0
,
6
]
*
1.0
)
assert
l_packed
[
1
]
==
(
l
[
1
,
1
]
*
1.0
+
l
[
1
,
2
]
*
1.0
+
l
[
2
,
1
]
*
1.0
+
l
[
2
,
2
]
*
1.0
)
assert
l_packed
[
15
]
==
(
l
[
4
,
4
]
*
1.0
)
print
(
"Test: pack_layer() ... ok"
)
l1
=
l
l2
=
l
*
2
print
(
l_stack
.
shape
)
l_packed
=
pile
.
pack
(
l_stack
)
ls
=
np
.
dstack
((
l1
,
l2
))
#equivalent: ls = np.stack((l1,l2),axis=2)
#print(ls)
#print(ls.shape)
print
(
l_packed
.
shape
)
l_packed
=
pile
.
pack_tile
(
ls
,
pt
)
l_packed
2
=
np
.
reshape
(
l_packed
,
l_packed
.
shape
[
-
1
]
)
#print(l_packed)
# a few assertions for layer 2
assert
l_packed
[
25
]
==
(
ls
[
0
,
2
,
1
]
*
1.0
+
ls
[
0
,
3
,
1
]
*
1.0
+
ls
[
0
,
4
,
1
]
*
1.0
+
ls
[
0
,
5
,
1
]
*
1.0
+
ls
[
0
,
6
,
1
]
*
1.0
)
assert
l_packed
[
26
]
==
(
ls
[
1
,
1
,
1
]
*
1.0
+
ls
[
1
,
2
,
1
]
*
1.0
+
ls
[
2
,
1
,
1
]
*
1.0
+
ls
[
2
,
2
,
1
]
*
1.0
)
assert
l_packed
[
40
]
==
(
ls
[
4
,
4
,
1
]
*
1.0
)
print
(
"Test: pack_tile() ... ok"
)
#for i in range(tiles.shape[0]):
# for j in range(tiles.shape[1]):
#print("tile: "+str(i)+", "+str(j))
# FEED = get_packed_square(tiles,values,pt,i,j,RADIUS)
#xy = [(x,y) for x in range(tiles.shape[0]) for y in range(tiles.shape[1])]
#for x,y in xy:
# FEED = get_packed_square(tiles,values,pt,x,y,RADIUS)
#def gps(i,j):
#a = i
#for k in range(3):
#for l in range(3):
#a += k+l
#return a
#for x,y in itertools.product(range(3*tiles.shape[0]),range(3*tiles.shape[1])):
# print(str(x)+" "+str(y))
#FEED = get_packed_square(tiles,values,pt,x,y,RADIUS)
#FEED = gps(x,y)
#for i in range(tiles.shape[0]):
# for j in range(tiles.shape[1]):
# b = gps(i,j)
# a few assertions
assert
l_packed2
[
0
]
==
(
l
[
0
,
2
]
*
1.0
+
l
[
0
,
3
]
*
1.0
+
l
[
0
,
4
]
*
1.0
+
l
[
0
,
5
]
*
1.0
+
l
[
0
,
6
]
*
1.0
)
assert
l_packed2
[
1
]
==
(
l
[
1
,
1
]
*
1.0
+
l
[
1
,
2
]
*
1.0
+
l
[
2
,
1
]
*
1.0
+
l
[
2
,
2
]
*
1.0
)
assert
l_packed2
[
15
]
==
(
l
[
4
,
4
]
*
1.0
)
#for i in range(tiles.shape[0]*tiles.shape[1]):
# b = gps(i,i)
# basic test
#print(tiles[150,100])
#print(values[150,100])
#FEED = get_packed_square(tiles,values,pt,150,100,RADIUS)
#print(FEED)
#print(FEED.shape)
print
(
"Test: pack() ... ok"
)
print
(
"Done"
)
...
...
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