import numpy as np
import matplotlib.pyplot as plt
from wfslib.geometry import Geometry
from wfslib.wfs import WFSData
from PIL import Image
path = "../data/bad_img3.tiff"
arr = np.array(Image.open(path))[500:1500, 500:1500]
arr = np.expand_dims(arr, 0)
wfs = WFSData(arr)
wfs.geometry.set_options(shift=(-22, -36))
wfs.reference = 27
wfs.good_only = True #отображать только качественные субапертуры
plt.imshow(arr[0])
wfs.show_geometry()
#print(str (wfs[0].get_offset(43)))
wfs.mask = True
plt.subplot(1,2,1)
plt.imshow(wfs[0][17])
plt.subplot(1,2,2)
plt.imshow(wfs[0][1])
path = "../data/bad_img1.tiff"
Geometry.only_wavelets = 0
arr = np.array(Image.open(path))[500:1500, 500:1500]
arr = np.expand_dims(arr, 0)
wfs = WFSData(arr)
wfs.geometry.set_options(shift=(-65, -15))
wfs.reference = 27
plt.imshow(arr[0])
wfs.show_geometry(show_type = "offsets")
wfs = WFSData('../data/file.h5', dataset_name = "data")
#wfs.close_stream()
p = wfs.geometry.options
print(p)
wfs.geometry.set_options( shift = (-1,1), border = 6)
wfs.reference = 87
#wfs.domask = True
wfs.show_geometry()
wfs[0].offsets()
# plt.imshow(wfs[0][172])
print(wfs[1].get_offset(130))
path = "../data/bad_img2.tiff"
arr = np.array(Image.open(path))
arr = np.expand_dims(arr, 0)
plt.imshow(arr[0])
wfs = WFSData(arr)
wfs.geometry.set_options(shift=(64, -38),swap = True, rotate = 1)
#plt.imshow(arr[0])
wfs.show_geometry()
def read_bim(path):
with open(path, "rb") as f:
ny = int.from_bytes(f.read(4), "little")
nx = int.from_bytes(f.read(4), "little")
return np.frombuffer(f.read()).reshape(ny, nx)
bim_img = read_bim("../data/bims/lsvt-z2=-2.bim").copy()
plt.imshow(bim_img)
Geometry.only_wavelets = 0
wfs = WFSData(bim_img)
p = wfs.geometry.options
print(p)
wfs.geometry.set_options(shift=(-56, -38))
wfs.good_only = True
wfs.reference = 0
#plt.imshow(arr[0])
wfs.show_geometry(show_type = "offsets")
wfs.show_geometry()
def qualitative_sub_std(cell, std, mean_val):
return np.mean(cell) > std
def qualitative_sub_mean(cell, std, mean_val):
return np.mean(cell) > mean_val
def qualitative_sub_median(cell, std, mean_val):
return np.median(cell) > mean_val
path = "../data/bad_img3.tiff"
arr = np.array(Image.open(path))[500:1500, 500:1500]
arr = np.expand_dims(arr, 0)
wfs = WFSData(arr)
wfs.geometry.set_options(shift=(-22, -36))
wfs.qualitative_function = qualitative_sub_mean
wfs.reference = 27
wfs.show_geometry()
wfs.qualitative_function = qualitative_sub_median
wfs.show_geometry()
wfs.qualitative_function = qualitative_sub_std
wfs.show_geometry()
path = "../data/bad_img3.tiff"
arr = np.array(Image.open(path))[500:1500, 500:1500]
arr = np.expand_dims(arr, 0)
wfs = WFSData(arr)
wfs.geometry.set_options(shift=(-22, -36))
wfs.qualitative_function = qualitative_sub_mean
wfs.reference = 13
wfs.good_only = True
wfs.show_geometry()
wfs[0].offsets()