Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Merge branch 'feat/fix-issue-#87' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudius-Appel committed Nov 28, 2024
2 parents 6be9293 + 8b06e6e commit 7e3eabe
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 8 deletions.
14 changes: 9 additions & 5 deletions R/correct_distortion.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' correct for (barrel-) distortion
#'
#'
#' @param pixel.idx natrixmatrix of
#' @param pixel.idx matrix of pixel-coordinate pairs for matched pixels.
#' @param distortions list of distortion-factors to apply. Values must be numeric, on a scale from -100 <> +100
#' Currently, only `barrel`-distortion can be applied.
#' @param image_dimensions actual dimensions of the image, without cropping.
#' @param do_crop_image boolean to check if the image was cropped.
#' @param x0 coordinates of the cropping top left corner. Necessary to correct coordinate-space for cropping.
#' @param y0 coordinates of the
#' @param y0 ''
#'
#' @return sum of distortion-corrected pixels, rounded to the closest integer value.
#' @keywords internal
Expand All @@ -20,8 +20,12 @@ correct_distortion <- function(pixel.idx, distortions, image_dimensions, do_crop

# Image dimensions and center
center_coords <- c(round(image_dimensions[1] / 2), round(image_dimensions[2] / 2))
euclidean_distance_edge <- sqrt((image_dimensions[1] - center_coords[1])^2 +
(image_dimensions[2] - center_coords[2])^2)
corners <- matrix(c(0, 0,
0, image_dimensions[2],
image_dimensions[1], 0,
image_dimensions[1], image_dimensions[2]),
ncol = 2, byrow = TRUE)
euclidean_distance_edge <- max(euclidean_distance(center_coords, corners))

# correct coordinates if cropped
if (do_crop_image) {
Expand Down
2 changes: 1 addition & 1 deletion R/execute_single.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ execute_single <- function(file, input, DATA, DEBUGKEYS, FLAGS) {
}
## UNDISTORTED RESULTS
# if distortion-fixing is disabled, we skip this section; and inherit the entries in 'current_results' be 'NA'
if (isTRUE(do_correct_distortion)) {
if (isTRUE(input$do_correct_distortion)) {
if (repackaged_pixel_counts_undistorted[[grep("identifier",names(repackaged_pixel_counts_undistorted))]]==0) {

} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ articles:
parallelisation: parallelisation.html
raising-issues: raising-issues.html
saving-and-restoring-application-states: saving-and-restoring-application-states.html
last_built: 2024-11-25T14:26Z
last_built: 2024-11-28T12:37Z
urls:
reference: https://Claudius-Appel.github.io/duflor.gui/reference
article: https://Claudius-Appel.github.io/duflor.gui/articles
115 changes: 115 additions & 0 deletions docs/reference/correct_distortion.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<url><loc>https://Claudius-Appel.github.io/duflor.gui/LICENSE-text.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/LICENSE.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/reference/convert_pixels_to_area_gui.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/reference/correct_distortion.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/reference/dev_key_handler.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/reference/dot-main_args.html</loc></url>
<url><loc>https://Claudius-Appel.github.io/duflor.gui/reference/duflor_gui.html</loc></url>
Expand Down
36 changes: 36 additions & 0 deletions man/correct_distortion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e3eabe

Please sign in to comment.