Commit 51770119 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

packing data, initial

parent c76092fa
#!/usr/bin/env python3
from PIL import Image
import xml.etree.ElementTree as ET
import numpy as np
import matplotlib.pyplot as plt
import imagej_tiff as ijt
#tiff = ijt.imagej_tiff('test.tiff')
#print(tiff.nimages)
#print(tiff.labels)
#print(tiff.infos)
#tiff.show_images(['X-corr','Y-corr',0,2])
#plt.show()
import json
import xml.etree.ElementTree as ET
import xml.dom.minidom as minidom
import ast
def calc_packed_value(layer,index,tile):
t = tile.flatten()
a = layer[index]
res = 0
for i in a:
res += t[i[0]]*i[1]
return res
def iterate_tile(lut,tile):
# hard coded layers names
lst = ['diagm-pair','diago-pair']
#lut['diagm-pair']
#stack = ijt.getstack(lst)
e = ET.parse('tile_packing_table.xml').getroot()
#print(ET.tostring(e))
#reparsed = minidom.parseString(ET.tostring(e,""))
#print(reparsed.toprettyxml(indent="\t"))
# LUT is a dict
LUT = {}
for table in e:
layer = table.get('layer')
LUT[layer] = []
for row in table:
LUT[layer].append(ast.literal_eval(row.text))
print(LUT)
print("Done")
<Document>
<table layer='diagm-pair'>
<tr row='0' >[(2,1.0), (3,1.0), (4,1.0), (5,1.0), (6,1.0)]</tr>
<tr row='1' >[(10,1.0), (11,1.0), (19,1.0), (20,1.0)]</tr>
<tr row='2' >[(12,1.0), (13,1.0), (14,1.0)]</tr>
<tr row='3' >[(15,1.0), (16,1.0), (24,1.0), (25, 1.0)]</tr>
<tr row='4' >[(18,1.0), (27,1.0), (36,1.0), (45,1.0), (54,1.0)]</tr>
<tr row='5' >[(21,1.0), (22,1.0), (23,1.0)]</tr>
<tr row='6' >[(26,1.0), (35,1.0), (44,1.0), (53,1.0), (62,1.0)]</tr>
<tr row='7' >[(28,1.0), (37,1.0), (46,1.0)]</tr>
<tr row='8' >[(29,1.0), (38,1.0), (47,1.0)]</tr>
<tr row='9' >[(30,1.0)]</tr>
<tr row='10'>[(31,1.0)]</tr>
<tr row='11'>[(32,1.0)]</tr>
<tr row='12'>[(33,1.0), (42,1.0), (51,1.0)]</tr>
<tr row='13'>[(34,1.0), (43,1.0), (52,1.0)]</tr>
<tr row='14'>[(39,1.0)]</tr>
<tr row='15'>[(40,1.0)]</tr>
<tr row='16'>[(41,1.0)]</tr>
<tr row='17'>[(48,1.0)]</tr>
<tr row='18'>[(49,1.0)]</tr>
<tr row='19'>[(50,1.0)]</tr>
<tr row='20'>[(55,1.0), (56,1.0), (64,1.0), (65,1.0)]</tr>
<tr row='21'>[(57,1.0), (58,1.0), (59,1.0)]</tr>
<tr row='22'>[(60,1.0), (61,1.0), (69,1.0), (70,1.0)]</tr>
<tr row='23'>[(66,1.0), (67,1.0), (68,1.0)]</tr>
<tr row='24'>[(74,1.0), (75,1.0), (76,1.0), (77,1.0), (78,1.0)]</tr>
</table>
<table layer='diago-pair'>
<tr row='0' >[(2,1.0), (3,1.0), (4,1.0), (5,1.0), (6,1.0)]</tr>
<tr row='1' >[(10,1.0), (11,1.0), (19,1.0), (20,1.0)]</tr>
<tr row='2' >[(12,1.0), (13,1.0), (14,1.0)]</tr>
<tr row='3' >[(15,1.0), (16,1.0), (24,1.0), (25, 1.0)]</tr>
<tr row='4' >[(18,1.0), (27,1.0), (36,1.0), (45,1.0), (54,1.0)]</tr>
<tr row='5' >[(21,1.0), (22,1.0), (23,1.0)]</tr>
<tr row='6' >[(26,1.0), (35,1.0), (44,1.0), (53,1.0), (62,1.0)]</tr>
<tr row='7' >[(28,1.0), (37,1.0), (46,1.0)]</tr>
<tr row='8' >[(29,1.0), (38,1.0), (47,1.0)]</tr>
<tr row='9' >[(30,1.0)]</tr>
<tr row='10'>[(31,1.0)]</tr>
<tr row='11'>[(32,1.0)]</tr>
<tr row='12'>[(33,1.0), (42,1.0), (51,1.0)]</tr>
<tr row='13'>[(34,1.0), (43,1.0), (52,1.0)]</tr>
<tr row='14'>[(39,1.0)]</tr>
<tr row='15'>[(40,1.0)]</tr>
<tr row='16'>[(41,1.0)]</tr>
<tr row='17'>[(48,1.0)]</tr>
<tr row='18'>[(49,1.0)]</tr>
<tr row='19'>[(50,1.0)]</tr>
<tr row='20'>[(55,1.0), (56,1.0), (64,1.0), (65,1.0)]</tr>
<tr row='21'>[(57,1.0), (58,1.0), (59,1.0)]</tr>
<tr row='22'>[(60,1.0), (61,1.0), (69,1.0), (70,1.0)]</tr>
<tr row='23'>[(66,1.0), (67,1.0), (68,1.0)]</tr>
<tr row='24'>[(74,1.0), (75,1.0), (76,1.0), (77,1.0), (78,1.0)]</tr>
</table>
</Document>
\ 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