Skip to content

Commit

Permalink
Partial fix of image alignment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
elbee99 authored and ml-evs committed Oct 15, 2024
1 parent ffe6e4a commit 4ba00f3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pydatalab/src/pydatalab/apps/raman_map/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ def plot_raman_map(self, location: str | Path):
x_span = float(data[0]["original_metadata"]["WHTL_0"]["FocalPlaneXResolution"])
y_span = float(data[0]["original_metadata"]["WHTL_0"]["FocalPlaneYResolution"])
# converts image to vector compatible with bokeh
image_data = np.array(image, dtype=np.uint8)
image_data = np.flip(image_data, axis=0)
image_data = np.dstack((image_data, 255 * np.ones_like(image_data[:, :, 0])))
img_vector = image_data.view(dtype=np.uint32).reshape(
(image_data.shape[0], image_data.shape[1])
image_array = np.array(image, dtype=np.uint8)
image_array = np.flip(image_array, axis=0)
image_array = np.dstack((image_array, 255 * np.ones_like(image_array[:, :, 0])))
img_vector = image_array.view(dtype=np.uint32).reshape(
(image_array.shape[0], image_array.shape[1])
)

# generates numbers for colours for points in linear gradient
col = [
i / (len(x_coordinates) * len(y_coordinates))
Expand All @@ -118,6 +117,13 @@ def plot_raman_map(self, location: str | Path):
x_range=(origin[0], origin[0] + x_span),
y_range=(origin[1] + y_span, origin[1]),
)
p.image_rgba(image=[img_vector], x=origin[0], y=origin[1], dw=x_span, dh=y_span)
p = bokeh.plotting.figure(
width=image_array.shape[1],
height=image_array.shape[0],
x_range=(origin[0], origin[0] + x_span),
y_range=(origin[1] + y_span, origin[1]),
)
p.image_rgba(image=[img_vector], x=origin[0], y=origin[1] + y_span, dw=x_span, dh=y_span)
# plot scatter points and colorbar
p.circle("x", "y", size=10, source=source, color={"field": "col", "transform": exp_cmap})
Expand Down

0 comments on commit 4ba00f3

Please sign in to comment.