Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel based concentration analysis #230

Closed
wants to merge 198 commits into from
Closed
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
59377c7
MAINT: Light restructuring of image base class.
jwboth Feb 22, 2023
0bb80b8
ENH: Init image reader, reading DICOM format.
jwboth Feb 23, 2023
cdd124d
ENH: Add empty routines to read from other formats.
jwboth Feb 28, 2023
bb0701b
MAINT: Rename file.
jwboth Feb 28, 2023
f723dfa
ENH: Generalize color correction to inputs of type array and Image.
jwboth Mar 2, 2023
db30853
MAINT: Remove redundant argument from method.
jwboth Mar 2, 2023
71afee2
MAINT: Restructure test environment.
jwboth Mar 3, 2023
1430685
TST: Add basic test for intialization of images.
jwboth Mar 3, 2023
81d2705
TST: Remove testing correction in the initialization test.
jwboth Mar 3, 2023
11c40c3
TST: Add test for color correction of general images.
jwboth Mar 3, 2023
1431850
ENH: Add utils functionality to convert matrix and Cartesian indexing.
jwboth Mar 3, 2023
f0949fb
ENH: Init a general image class.
jwboth Mar 3, 2023
f689d0a
ENH: Init a coordinate system operating on general images.
jwboth Mar 3, 2023
4b5ca24
ENH: Add new base correction.
jwboth Mar 4, 2023
ba7efe9
MAINT: Make experimental color correction inherit from base correction.
jwboth Mar 4, 2023
49c21fc
MAINT: Make color correction inherit from base correction.
jwboth Mar 4, 2023
94ac69b
MAINT: Make drift correction inherit from base correction.
jwboth Mar 4, 2023
255248d
MAINT: Make translation correction inherit from base correction.
jwboth Mar 4, 2023
fea8e2c
MAINT: Make curvature correction inherit from base correction.
jwboth Mar 4, 2023
fd5eacd
TST: Add unit tests for correction curvature and drift correction.
jwboth Mar 4, 2023
c8c3942
MAINT: Add missing headers.
jwboth Mar 4, 2023
926221d
MAINT: Remove dependence on a soon to be deprecated argument.
jwboth Mar 5, 2023
4ef0831
ENH: Add more conversions for indexing axes.
jwboth Mar 5, 2023
5c161f5
MAINT: Rename orientation to indexing.
jwboth Mar 5, 2023
67a2b53
EX: Extend image registration example to use general images.
jwboth Mar 6, 2023
c09cbbe
TST: Add test for image registration using general images.
jwboth Mar 6, 2023
6388b82
ENH: Name changes, and provide functionality to extract metadata - al…
jwboth Mar 6, 2023
8a76854
ENH: Extend subregions routines to general images.
jwboth Mar 6, 2023
80e0687
ENH: Introduce general patches, operating on general images.
jwboth Mar 6, 2023
d51e2b3
MAINT: Update coordinate system according to recent chenages, and rem…
jwboth Mar 6, 2023
9183006
ENH: Introduce general piecewise perspective transform.
jwboth Mar 6, 2023
b4ce979
MAINT: Extend deformation correction to inherit from BaseCorrection.
jwboth Mar 6, 2023
4c16176
ENH: Extend translation analysis to work with both general and old im…
jwboth Mar 6, 2023
ecb6de6
ENH: Extend image regstration to work with both old and general images.
jwboth Mar 6, 2023
8c8a5e1
STY: black
jwboth Mar 6, 2023
ee701f5
EX: Make color correction example work with general images.
jwboth Mar 6, 2023
2eb0481
MAINT: Add typing to allow for general images.
jwboth Mar 6, 2023
72f1e0f
MAINT: Add typing to allow for general images.
jwboth Mar 6, 2023
4d8cd02
MAINT: Extend segmentation comparison to work with old and general im…
jwboth Mar 6, 2023
656bf36
BUG: Use correct access to metadata.
jwboth Mar 6, 2023
85932a8
MAINT: Extend concentration analysis to allow for general images.
jwboth Mar 6, 2023
bdb6ab1
MAINT: Remove wrong typing.
jwboth Mar 6, 2023
ec2bae5
MAINT: Generalize typing to include general images.:
jwboth Mar 6, 2023
ba1ff02
MAINT: Fix typing.
jwboth Mar 6, 2023
177c855
EX: Make concnetration analysis example work for general images.
jwboth Mar 6, 2023
af6200b
STY: black, isort, flake8
jwboth Mar 6, 2023
e1c7b64
ENH: Make emd work with general images.
jwboth Mar 6, 2023
d2fa166
EX: Make distances example work with general images.
jwboth Mar 6, 2023
70dcc6f
STY: black, isort
jwboth Mar 6, 2023
00ca554
MAINT: Make resize work with general images.
jwboth Mar 6, 2023
53ab559
MAINT: Simplify some Image constructions, and add plotting routine.
jwboth Mar 6, 2023
82623dd
ENH: Add specific scalar image object.
jwboth Mar 6, 2023
616c520
ENH: Add specific optical image object.
jwboth Mar 6, 2023
5bdbb58
EX: Demonstrate the use of the different image classes for photographs.
jwboth Mar 6, 2023
c6477ae
MAINT: Make use of simpler plotting functions for images.
jwboth Mar 6, 2023
045e040
MAINT: Only enable plotting for 2d, time-independent images.
jwboth Mar 6, 2023
616a271
TST: Add simple test for initializing optical images.
jwboth Mar 6, 2023
efd6878
TST: Add test of monochromatic and scalar images.
jwboth Mar 6, 2023
f9a9a7c
MAINT: Rename imagereader.
jwboth Mar 7, 2023
7b1cd95
MAINT: Include imread into header.
jwboth Mar 7, 2023
4d571e9
MAINT: Reorganization of initialization of metadata enabling earlier …
jwboth Mar 7, 2023
5207a0c
ENH: Add possibility to extract a single time slice.
jwboth Mar 7, 2023
36cd471
MAINT: Make arithmetics of images more general (use correct time, and…
jwboth Mar 7, 2023
2ac8f2a
ENH: Extend plotting routine to time series.
jwboth Mar 7, 2023
50eab86
MAINT: Fix types.
jwboth Mar 7, 2023
7c96c5d
MAINT: Shorten color space conversions and enable time series.
jwboth Mar 7, 2023
704922c
MAINT: Keep time in the loop.
jwboth Mar 7, 2023
3b73e98
EX: Adapt new conversion of color spaces.
jwboth Mar 7, 2023
d7c8f92
EX: Add example on how to initialize images from file with imread.
jwboth Mar 7, 2023
364f969
ENH: Enable reading from file to OpticalImage, also for series.
jwboth Mar 7, 2023
a1144ff
ENH: include tif as optical image.
jwboth Mar 7, 2023
86738c1
FIX: conversion for 3d differs from 2d. add this.
jwboth Mar 8, 2023
c3fb0eb
MAINT: Adapt to changes in indexing conversion.
jwboth Mar 8, 2023
86b0db8
EX: Adapt description.
jwboth Mar 8, 2023
d8a06e4
ENH: Extend general interface of corrections to space time images.
jwboth Mar 8, 2023
4ea7ca2
STY: black
jwboth Mar 8, 2023
d58386b
MAINT: Finalize dicom reader.
jwboth Mar 8, 2023
f52020a
ENH: Enable reading images from folder.
jwboth Mar 8, 2023
ca3429e
STY: black.
jwboth Mar 8, 2023
d3a42c5
EX: Init example on dicom images - start with reading.
jwboth Mar 8, 2023
5fe24ec
ENH: Allow returning space time and list of DICOM images.
jwboth Mar 9, 2023
2a38481
EX: Demonstrate difference between 3d and 4d dicom images.
jwboth Mar 9, 2023
6261faf
ENH: Add functionality to glue together images through appending.
jwboth Mar 9, 2023
03b2cfb
MAINT: Add safety checks for appending images.
jwboth Mar 9, 2023
06cfc55
ENH: Add functionality to extract subregion from general images.
jwboth Mar 9, 2023
bb816a6
MAINT: Remove obsolete utils functionality for general images to extr…
jwboth Mar 9, 2023
a4e5afc
ENH: Generalize imread for dicom to allow for 2d and non-spacetime im…
jwboth Mar 10, 2023
c3348e0
MAINT: Generalize safety checks.
jwboth Mar 10, 2023
a3a2df1
ENH: Allow for more diverse input in imread.
jwboth Mar 10, 2023
f410b6f
MAINT: Always return image in base correction.
jwboth Mar 11, 2023
755d5c4
ENH: Add rotation correction of 2d and 3d images.
jwboth Mar 11, 2023
2d8f2f9
TST: Add test for rotation correction.
jwboth Mar 11, 2023
d6fc7d8
ENH: Add generalized vertical averaging.
jwboth Mar 11, 2023
0eb7952
EX: Adapt DICOM example according to the newest updates.
jwboth Mar 11, 2023
bf92802
MAINT: Restructure imread, update typing, add doc.
jwboth Mar 12, 2023
c15be97
ENH: Add imread for 2d vtu files.
jwboth Mar 12, 2023
78c7d9b
ENH: Extend imread to handle vtu images corresponding to lower dimens…
jwboth Mar 12, 2023
d7760ec
MAINT: Update of dimensions needed when embedding vtu data.
jwboth Mar 12, 2023
f13880b
MAINT: Add fast access to opposite corner for general images.
jwboth Mar 12, 2023
026c88e
FIX: Wrong definition of domain.
jwboth Mar 12, 2023
abffb22
MAINT: Add absolute and relative time, and make it part of standard m…
jwboth Mar 21, 2023
e5cf789
MAINT: Simplify time treatment when reading images.
jwboth Mar 21, 2023
ae14f55
MAINT: Rename datetime->date.
jwboth Mar 21, 2023
3237065
FIX: Correct use of subregions for general images.
jwboth Mar 21, 2023
119dfa1
BUG: Fix extraction of subregions, providing coordinates.
jwboth Mar 21, 2023
9fe2ca6
MAINT: Utilize that time is part of meta.
jwboth Mar 21, 2023
38a56c2
TST: Make correct logical comparison.
jwboth Mar 21, 2023
01ce4f8
TST: Update interface to general images, and update (important) refer…
jwboth Mar 21, 2023
80d51b9
EX: Rm series keyword for reading spacetime optical images, and remov…
jwboth Mar 21, 2023
681f848
MAINT: Allow over-steering dimensions via more common keywords.
jwboth Mar 21, 2023
ab43946
DOC: Move documentation of relative time.
jwboth Mar 21, 2023
e3dc407
BUG: Fix retrieving box of voxels from coordinates.
jwboth Mar 21, 2023
cffa77b
EX: Use solely general images in distance computations.
jwboth Mar 21, 2023
30ac99a
EX: Remove use of old Image class.
jwboth Mar 21, 2023
aec03ae
EX: Get rid of old Image from image registration example.
jwboth Mar 21, 2023
f8b0a0a
EX: Use solely general images in co2 and tracer example.
jwboth Mar 21, 2023
7afd19b
STY: black
jwboth Mar 22, 2023
57e7944
MAINT: Add robustness and convert input to unique format.
jwboth Mar 22, 2023
b9aa006
DOC: Improve documentation.
jwboth Mar 22, 2023
af22c68
MAINT: Adapt AnalysisBase to general images.
jwboth Mar 22, 2023
5d439d8
MAINT: Add error messages for robustness.
jwboth Mar 22, 2023
e7d4aad
MAINT: Deactivate drift correction, if config empty.
jwboth Mar 22, 2023
4ec6195
EX: Example for analyzing CO2 using the TracerAnalysis manager.
jwboth Mar 22, 2023
6e0e0b7
MAINT: Add robustness and apply transformations only if applicable.
jwboth Mar 22, 2023
af5c0be
MAINT: Continue transition from orginal image to general image.
jwboth Mar 22, 2023
6b2b31f
MAINT: Ignore npy files on git.
jwboth Mar 23, 2023
ca4febb
MAINT: Improve I/O, add more options, and tailor to image types.
jwboth Mar 23, 2023
d48764f
MAINT: Remove storing of images from analysisbase - part of image class.
jwboth Mar 23, 2023
7c7323b
MAINT: Fix dimensionality of concentrations to scalar output.
jwboth Mar 23, 2023
aa40dcc
MAINT: Adapt presets to GeneralImage.
jwboth Mar 23, 2023
71889d2
MAINT: Major name change. GeneralImage -> Image.
jwboth Mar 23, 2023
3a1ad03
MAINT: Depracate several subregions routines.
jwboth Mar 23, 2023
8f57bf4
MAINT: Upgrade coordinatesystem.
jwboth Mar 23, 2023
a0bda4b
MAINT: Remove deprecated coordinate system.
jwboth Mar 23, 2023
f31501f
MAINT: Move conversion of indexing for arrays to indexing module.
jwboth Mar 23, 2023
9def449
MAINT: Remove deprecated patches class, upgrade.
jwboth Mar 23, 2023
213c928
MAINT: Deprecate and upgrade piecewise perspective transforms.
jwboth Mar 23, 2023
7551bd2
MAINT: Use only Image in translation.
jwboth Mar 23, 2023
23d9e52
MAINT: Use Image in deformation.
jwboth Mar 23, 2023
cd4ca6c
MAINT: Use Image in drift.
jwboth Mar 23, 2023
90d600b
MAINT: Use Image in base correction.
jwboth Mar 23, 2023
68ebe54
MAINT: Use Image in imread.
jwboth Mar 23, 2023
9143a1f
DOC: Improve documentation.
jwboth Mar 23, 2023
c850558
MAINT: Use Image in emd.
jwboth Mar 23, 2023
3fa1ae4
MAINT: Use Image in translation analysis.
jwboth Mar 23, 2023
254242e
MAINT: Use Image in balancing calibration.
jwboth Mar 23, 2023
878a2b0
MAINT: Use Image in concentration analysis.
jwboth Mar 23, 2023
2ed1b51
MAINT: Use Image in image registration.
jwboth Mar 23, 2023
b84bff0
MAINT: Use Image in segmentation comparison.
jwboth Mar 23, 2023
bade2d4
STY: isort, flake8
jwboth Mar 23, 2023
6600f11
MAINT: Use Image in presets.
jwboth Mar 23, 2023
e967736
MAINT: Use Image in resize.
jwboth Mar 23, 2023
4056e31
MAINT: Use Image in dimension reduction.
jwboth Mar 23, 2023
561a339
TST: Use Image in unit tests.
jwboth Mar 23, 2023
2fe8efa
MAINT: Use Image in model calibration.
jwboth Mar 23, 2023
53b0fb3
MAINT: Apapt use of DriftCorrection.
jwboth Mar 24, 2023
abf90fd
BUG: Distinguish between array and patch input.
jwboth Mar 24, 2023
e9cb36d
MAINT: Adapt to updated interface of images.
jwboth Mar 24, 2023
1c0676f
MAINT: Use updated image class in examples.
jwboth Mar 24, 2023
530bbb7
STY: black, isort, flake8
jwboth Mar 24, 2023
9f4141f
MAINT: Remove obsolete subregions routines.
jwboth Mar 24, 2023
c9549fb
MAINT: Remove obsolete Image class, now fully replaced with an upgrad…
jwboth Mar 24, 2023
2c533ed
MAINT: Use positive conditional statement
jwboth Mar 24, 2023
c9ac714
MAINT: Remove obsolete file.
jwboth Mar 25, 2023
bed0b82
MAINT: Use _ instead of space in keywords.
jwboth Mar 25, 2023
a5a6a67
MAINT: Only define details when active.
jwboth Mar 25, 2023
fd855c4
MAINT: Fix typing.
jwboth Mar 28, 2023
761e8b5
ENH: Simple output of metadata to define geometries.
jwboth Mar 28, 2023
efb0159
MAINT: Restructure, remove redundant I/O file.
jwboth Mar 28, 2023
1396182
TST: Unit test for geometry.
jwboth Mar 28, 2023
6b22324
TST: Add unit tests for extruded geometry.
jwboth Mar 28, 2023
d13f93e
MAINT: Overhaul and extension of integration and geometries.
jwboth Mar 28, 2023
435eda6
TST: Add unit tests for geometries.
jwboth Mar 28, 2023
41dfb84
TST: Add unit test for EMD.
jwboth Mar 28, 2023
9facc85
ENH: Support imread for numpy files.
jwboth Mar 29, 2023
c7d7836
TST: Add test for imread from numpy
jwboth Mar 29, 2023
b42e4b2
EX: Add example for imread of numpy arrays.
jwboth Mar 29, 2023
8066c38
MAINT: timestamp -> date
jwboth Mar 29, 2023
924d0b3
TST: Add imread examples as test.
jwboth Mar 29, 2023
7d535c8
ENH: Add possibility to define a reference time for computing relativ…
jwboth Mar 29, 2023
f333135
MAINT: Make folder before writing data.
jwboth Mar 29, 2023
ba9b8b7
MAINT: Include a reference date
jwboth Mar 29, 2023
698b33a
MAINT: Simplify use of relative times in model calibration
jwboth Mar 29, 2023
a036dfc
MAINT: Separate interpolaton functionality independent of depths.
jwboth Mar 30, 2023
5e2215e
DOC: Remove redundant doc.
jwboth Mar 30, 2023
1931072
MAINT: Add missing typing.
jwboth Mar 30, 2023
a2f72f9
MAINT: Replace error with warning.
jwboth Mar 30, 2023
12c4f28
BUG: Restructure corrections and base relative correction on uncorrec…
jwboth Mar 30, 2023
76ce116
MAINT: Replace old code standard (subregions).
jwboth Mar 30, 2023
4a04ba4
MAINT: Update plotting of translation analysis accordint to recent up…
jwboth Mar 31, 2023
41b33b6
MAINT: Add robustness and clip away non-relevant value for plotting o…
jwboth Mar 31, 2023
733130e
MAINT: Add default origin based on matrix indexing.
jwboth Mar 31, 2023
4e26e58
MAINT: Allow non-list objects as argument for batch analyses.
jwboth Mar 31, 2023
1db6dd7
Merge branch 'main' of https://github.com/pmgbergen/DarSIA
moritzmarquardt Mar 31, 2023
8c5228e
Merge branch 'main' of https://github.com/pmgbergen/DarSIA
moritzmarquardt Apr 2, 2023
4856973
Merge branch 'main' of https://github.com/pmgbergen/DarSIA
moritzmarquardt Apr 19, 2023
8bdd878
Merge branch 'main' of https://github.com/pmgbergen/DarSIA
moritzmarquardt Oct 16, 2023
d1500df
kernel example
moritzmarquardt Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 229 additions & 0 deletions examples/kernel_interpolation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import numpy as np
import darsia
import skimage
import matplotlib.pyplot as plt
from pathlib import Path
import matplotlib.patches as patches
import string

# import matplotlib.patches as patches

folder = Path("images")
baseline_path = folder / Path("20220914-142404.TIF")
image_path = folder / Path("20220914-151727.TIF")
# image_path = Path(".data/test/singletracer.JPG")

# Setup curvature correction (here only cropping)
curvature_correction = darsia.CurvatureCorrection(
config={
"crop": {
# Define the pixel values (x,y) of the corners of the ROI.
# Start at top left corner and then continue counterclockwise.
"pts_src": [[300, 600], [300, 4300], [7600, 4300], [7600, 600]],
# Specify the true dimensions of the reference points
"width": 0.92,
"height": 0.5,
}
}
)
transformations = [curvature_correction]

# Read-in images
baseline = darsia.imread(baseline_path, transformations=transformations).subregion(
voxels=(slice(2300, 2500), slice(2200, 5200))
)
image = darsia.imread(image_path, transformations=transformations).subregion(
voxels=(slice(2300, 2500), slice(2200, 5200))
)


# baseline_full = darsia.imread(baseline_path, transformations=transformations)
# image_full = darsia.imread(image_path, transformations=transformations)


# LAB
diff_LAB = (
(skimage.color.rgb2lab(image.img) - skimage.color.rgb2lab(baseline.img))
+ [0, 128, 128]
) / [100, 255, 255]

# RGB
diff_RGB = skimage.img_as_float(image.img) - skimage.img_as_float(baseline.img)

# HSV
# diff = skimage.color.rgb2hsv(baseline.img) - skimage.color.rgb2hsv(image.img)

# Regularize
smooth_RGB = skimage.restoration.denoise_tv_bregman(
diff_RGB, weight=0.025, eps=1e-4, max_num_iter=100, isotropic=True
)
smooth_LAB = skimage.restoration.denoise_tv_bregman(
diff_LAB, weight=0.025, eps=1e-4, max_num_iter=100, isotropic=True
)

samples = [
(slice(50, 150), slice(100, 200)),
(slice(50, 150), slice(400, 500)),
(slice(50, 150), slice(600, 700)),
(slice(50, 150), slice(800, 900)),
(slice(50, 150), slice(1000, 1100)),
(slice(50, 150), slice(1200, 1300)),
(slice(50, 150), slice(1400, 1500)),
(slice(50, 150), slice(1600, 1700)),
(slice(50, 150), slice(2700, 2800)),
]

letters = list(string.ascii_uppercase)


def extract_support_points(signal, samples):
# visualise patches
fig, ax = plt.subplots()
ax.imshow(np.abs(signal)) # visualise abs colours, because relative cols are neg
ax.set_xlabel("horizontal pixel")
ax.set_ylabel("vertical pixel")

# double check number of patches
n = np.shape(samples)[0] # number of patches
print("number of support patches: " + str(n))

# init colour vector
colours = np.zeros((n, 3))
# enumerate through all patches
for i, p in enumerate(samples):
# visualise patches on image
rect = patches.Rectangle(
(p[1].start, p[0].start),
p[1].stop - p[1].start,
p[0].stop - p[0].start,
linewidth=1,
edgecolor="w",
facecolor="none",
)
# ax.text(
# p[1].start + 130, p[0].start + 100, letters[i], fontsize=15, color="white"
# )
ax.text(p[1].start + 5, p[0].start + 95, letters[i], fontsize=12, color="white")
ax.add_patch(rect)

# histo analysis
patch = signal[p]
flat_image = np.reshape(patch, (10000, 3)) # all pixels in one dimension
# patch visualisation
# plt.figure("patch" + letters[i])
# plt.imshow(np.abs(patch))
H, edges = np.histogramdd(
flat_image, bins=100, range=[(-1, 1), (-1, 1), (-1, 1)]
)
print(H.shape)
index = np.unravel_index(H.argmax(), H.shape)
col = [
(edges[0][index[0]] + edges[0][index[0] + 1]) / 2,
(edges[1][index[1]] + edges[1][index[1] + 1]) / 2,
(edges[2][index[2]] + edges[2][index[2] + 1]) / 2,
]
colours[i] = col

c = np.abs(colours)
plt.figure()
ax = plt.axes(projection="3d")
ax.set_xlabel("R*")
ax.set_ylabel("G*")
ax.set_zlabel("B*")
ax.scatter(colours[:, 0], colours[:, 1], colours[:, 2], c=c)
for i, c in enumerate(colours):
ax.text(c[0], c[1], c[2], letters[i])

print("characteristic colours: " + str(colours))
return n, colours


n, colours_RGB = extract_support_points(signal=smooth_RGB, samples=samples)
n, colours_LAB = extract_support_points(signal=smooth_LAB, samples=samples)
concentrations = np.append(np.linspace(1, 0.99, n - 1), 0)


def color_to_concentration(
k, colours, concentrations, signal: np.ndarray
) -> np.ndarray:
# signal is rgb, transofrm to lab space because it is uniform and therefore
# makes sense to interpolate in
# signal = skimage.color.rgb2lab(signal)
# colours = skimage.color.rgb2lab(colours)

x = np.array(colours) # data points / control points / support points
y = np.array(concentrations) # goal points
X = np.ones((x.shape[0], x.shape[0])) # kernel matrix
for i in range(x.shape[0]):
for j in range(x.shape[0]):
X[i, j] = k(x[i], x[j])

alpha = np.linalg.solve(X, y)

# Estimator / interpolant
def estim(signal):
sum = 0
for n in range(alpha.shape[0]):
sum += alpha[n] * k(signal, x[n])
return sum

# estim = scipy.interpolate.LinearNDInterpolator(colours, concentrations, 0)

ph_image = np.zeros(signal.shape[:2])
for i in range(signal.shape[0]):
for j in range(signal.shape[1]):
ph_image[i, j] = estim(signal[i, j])
return ph_image


# define linear kernel shifted to avoid singularities
def k_lin(x, y, a=0):
return np.inner(x, y) + a


# define gaussian kernel
def k_gauss(x, y, gamma=9.73): # rgb: 9.73 , lab: 24.22
return np.exp(-gamma * np.inner(x - y, x - y))


# Convert a discrete ph stripe to a numeric pH indicator.
ph_image = color_to_concentration(
k_gauss, colours_RGB, concentrations, smooth_RGB
) # gamma=10 value retrieved from ph analysis kernel calibration war bester punk für c=0.95
# was
# physikalisch am meisten sinn ergibt

plt.figure("cut ph val")
plt.plot(np.average(ph_image, axis=0))
plt.xlabel("horizontal pixel")
plt.ylabel("concentration")

ph_image[ph_image > 1] = 1 # für visualisierung von größer 1 values
ph_image[ph_image < 0] = 0
fig = plt.figure()
fig.suptitle("evolution of signal processing in a subregion")
ax = plt.subplot(212)
ax.imshow(ph_image)
# calibration patch for the kernel calibration visualization if needed
# rect = patches.Rectangle(
# (1000, 80),
# 40,
# 40,
# linewidth=1,
# edgecolor="black",
# facecolor="none",
# )
# ax.add_patch(rect)
ax.set_ylabel("vertical pixel")
ax.set_xlabel("horizontal pixel")

ax = plt.subplot(211)
ax.imshow(skimage.img_as_ubyte(image.img))
ax.set_ylabel("vertical pixel")
ax.set_xlabel("horizontal pixel")

# plt.figure("indicator")
# indicator = np.arange(101) / 100
# plt.axis("off")
# plt.imshow([indicator, indicator, indicator, indicator, indicator])
plt.show()
Loading