Skip to main content

Programming module for wave front data processing

Project description

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()

png

png

#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])
<matplotlib.image.AxesImage at 0x2781c39aa90>

png

Крупная сетка хасвеченная диагонально

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")

png

png

Мелкая сетка полностью засвеченная

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))
{'border': 8.0, 'cell_width': 32.0, 'start_point': [139, 99]}

png

[0. 0.]

Точки

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()
134.0
210.5

png

png

Bims

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)
<matplotlib.image.AxesImage at 0x2781c113b70>

png

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()
{'border': 4.0, 'cell_width': 76.0, 'start_point': [185, 167]}

png

png

Разные функции качества

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()
240.66666666666666
317.0

png

wfs.qualitative_function = qualitative_sub_median
wfs.show_geometry()

png

wfs.qualitative_function = qualitative_sub_std
wfs.show_geometry()

png

Cмотрим смещения

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()

png

wfs[0].offsets()
array([[-28., -23.],
       [-25.,  -0.],
       [-30.,  -0.],
       [-29.,  -1.],
       [-28., -43.],
       [-25., -47.],
       [-28.,  -0.],
       [  1.,  -0.],
       [ 45.,  -0.],
       [-30., -43.],
       [-25., -37.],
       [ -0.,  -0.],
       [ 24.,  -0.],
       [ -0.,  -0.],
       [-26.,  -1.],
       [ 46., -35.],
       [ 38.,  -0.],
       [ 42.,  -0.],
       [-30.,  -0.],
       [ 41., -31.],
       [ 34., -40.],
       [ 31.,  -0.],
       [ 41.,  -0.],
       [ 37., -36.],
       [ 34., -39.],
       [ 29., -45.],
       [ 24., -32.]])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wfslib-0.1.152.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

wfslib-0.1.152-py3-none-any.whl (11.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page