Skip to content

Commit

Permalink
fix the mirror reflection
Browse files Browse the repository at this point in the history
Ideally I should find a better place to do this.
  • Loading branch information
dilawar committed Jul 30, 2024
1 parent 756f406 commit cc4c95d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 5 deletions.
Binary file modified figures/ECGImage.result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/graph_with_grid.result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/graphs_1.result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/trimmed.result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions plotdigitizer/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def trajectories(self, cache_key: T.Optional[str] = None):
save_img_in_cache(img, f"{cache_key}.final.png")
return traj


def find_trajectory(self, img: np.ndarray, pixel: int, T):
logger.info(f"Extracting trajectory for color {pixel}")
assert (
Expand All @@ -90,7 +89,7 @@ def find_trajectory(self, img: np.ndarray, pixel: int, T):

assert traj, "Empty trajectory"

# this is a simple fit using median.
# this is a simple approximation using median.
new = np.zeros_like(img)
res = fit_trajectory_using_median(traj, T, new)
return res, np.vstack((img, new))
Expand Down Expand Up @@ -238,9 +237,11 @@ def ask_user_to_locate_points(points, img) -> list:
logger.info("You clicked %s" % common.locations_)
return common.locations_


def _valid_px(val: int) -> int:
return min(max(0, val), 255)


def _find_center(vec):
return np.median(vec)

Expand Down Expand Up @@ -275,7 +276,9 @@ def fit_trajectory_using_median(traj, T, img):
cv.circle(img, (x, int(y)), 1, 255, -1)
x1 = (x - offX) / sX
y1 = (r - y - offY) / sY
res.append((x1, y1))

# opencv and numpy coordinate systems are not the same!!
res.append((-x1, -y1))

# sort by x-axis.
return sorted(res)
1 change: 0 additions & 1 deletion plotdigitizer/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def plot_images(images_with_title):


def plot_traj(traj, img, outfile: T.Optional[Path] = None):

x, y = zip(*traj)
plt.figure()
plt.subplot(211)
Expand Down
2 changes: 1 addition & 1 deletion plotdigitizer/plotdigitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def digitize_plot(
typer.Option(
"--location",
"-l",
help="Location of a points on figure in pixels (integer)[."
help="Location of a pixels corresponding to `data-points` on the figure."
" These values should appear in the same order as -p option."
" If not given, you will be asked to click on the figure.",
),
Expand Down

0 comments on commit cc4c95d

Please sign in to comment.