This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/fix-issue-24' into dev
- Loading branch information
Showing
16 changed files
with
421 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: duflor.gui | ||
Title: Frontend for duflor-package | ||
Version: 0.0.1.9014 | ||
Version: 0.0.1.9015 | ||
Author: Claudius Appel | ||
Authors@R: c( | ||
person("Claudius", "Appel", email = "[email protected]" , role = c("aut", "cre")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#' restrict area in which `identifier`-pixels are considered "valid" | ||
#' | ||
#' This function is only applied to the `identifier`-range. | ||
#' The intention is to exclude random pixels which **definitely** should not be | ||
#' attributed to the identifier-data. | ||
#' | ||
#' | ||
#' @param spectrums_object return object of [extract_pixels_HSV()] | ||
#' @param image_dimensions dimensions of image | ||
#' @param identifiersearch_x0 respective coordinate of the search bounding rectangle | ||
#' @param identifiersearch_x1 respective coordinate of the search bounding rectangle | ||
#' @param identifiersearch_y0 respective coordinate of the search bounding rectangle | ||
#' @param identifiersearch_y1 respective coordinate of the search bounding rectangle | ||
#' | ||
#' @return modified `spectrums_object` | ||
#' @keywords internal | ||
#' | ||
limit_identifier_coordinates <- function(spectrums_object, image_dimensions, identifiersearch_x0, identifiersearch_x1, identifiersearch_y0, identifiersearch_y1) { | ||
if (length(spectrums_object)==1) { # single image | ||
current_identifier_idx <- spectrums_object[[1]]$pixel.idx | ||
condition <- ((current_identifier_idx[,1] >= identifiersearch_x0) | ||
& (current_identifier_idx[,1]<=identifiersearch_x1) | ||
& (current_identifier_idx[,2]>=identifiersearch_y0) | ||
& (current_identifier_idx[,2]<=identifiersearch_y1) | ||
) | ||
# update pixel.count, img.fraction & pixel.idx, | ||
# as they are inserted into the `current_results` | ||
# and the `spectrums_objectobject` | ||
spectrums_object[[1]]$pixel.count <- sum(condition) | ||
spectrums_object[[1]]$img.fraction <- spectrums_object[[1]]$pixel.count/(prod(image_dimensions)) | ||
spectrums_object[[1]]$pixel.idx <- current_identifier_idx[condition,] | ||
} else { # multiple images | ||
for (name in names(spectrums_object)) { | ||
if (any(grep("identifier",names(spectrums_object)))) { # get position of identifier-object | ||
idx <- grep("identifier",names(spectrums_object)) | ||
if (names(spectrums_object)[[idx]]==name) { | ||
current_identifier_idx <- spectrums_object[[idx]]$pixel.idx | ||
condition <- ((current_identifier_idx[,1] >= identifiersearch_x0) | ||
& (current_identifier_idx[,1]<=identifiersearch_x1) | ||
& (current_identifier_idx[,2]>=identifiersearch_y0) | ||
& (current_identifier_idx[,2]<=identifiersearch_y1) | ||
) | ||
# update pixel.count, img.fraction & pixel.idx, | ||
# as they are inserted into the `current_results` | ||
# and the `spectrums_objectobject` | ||
spectrums_object[[name]]$pixel.count <- sum(condition) | ||
spectrums_object[[name]]$img.fraction <- spectrums_object[[name]]$pixel.count/(prod(image_dimensions)) | ||
spectrums_object[[name]]$pixel.idx <- current_identifier_idx[condition,] | ||
} | ||
} | ||
} | ||
} | ||
return(spectrums_object) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#' render mask based on input data | ||
#' | ||
#' @param input - `input` respective shiny-component | ||
#' @param DATA - `DATA` respective shiny-component | ||
#' @param FLAGS - `FLAGS` respective shiny-component | ||
#' | ||
#' @keywords internal | ||
render_selected_mask <- function(input, DATA, FLAGS) { | ||
if (is.null(input$tbl_results_filtered_rows_selected)) { | ||
showNotification( | ||
ui = "No row selected.", | ||
duration = DATA$notification_duration * 4, | ||
type = "warning" | ||
) | ||
return() | ||
} | ||
if (!(input$reinspected_spectrums %in% names(DATA$spectrums$lower_bound))) { | ||
showNotification( | ||
ui = "This spectrum was not analysed for this image.", | ||
duration = DATA$notification_duration * 4, | ||
type = "warning" | ||
) | ||
return() | ||
} | ||
if (FLAGS$analyse_single_image) { | ||
file <- DATA$results$results$full_path | ||
} else { | ||
file <- DATA$r__tbl_dir_files$images_filtered[[input$tbl_results_filtered_rows_selected]] | ||
} | ||
image_dimensions <- as.integer(get_image_dimensions(file)) | ||
## LOAD IMAGE | ||
if (is.na(DATA$last_masked_image) || (DATA$last_masked_image!=file)) { | ||
if (input$do_crop_image) { | ||
im <- load_image( | ||
image.path = file, | ||
subset_only = T, | ||
return_hsv = T, | ||
crop_left = input$x0, | ||
crop_right = image_dimensions[[1]] - input$x1, | ||
crop_top = input$y0, | ||
crop_bottom = image_dimensions[[2]] - input$y1 | ||
) | ||
DATA$last_masked_image <- file | ||
DATA$last_im <- im | ||
} else { | ||
im <- load_image( | ||
image.path = file, | ||
subset_only = F, | ||
return_hsv = T | ||
) | ||
DATA$last_masked_image <- file | ||
DATA$last_im <- im | ||
} | ||
} else { | ||
im <- DATA$last_im | ||
} | ||
mask <- input$reinspected_spectrums | ||
|
||
# get the spectrum's HSV scope | ||
lower_bound <- DATA$spectrums$lower_bound[[mask]] | ||
upper_bound <- DATA$spectrums$upper_bound[[mask]] | ||
|
||
# extract the spectrum & get its coordinates | ||
hsv_results <- extract_pixels_HSV( | ||
pixel.array = im, | ||
lower_bound = lower_bound, | ||
upper_bound = upper_bound, | ||
fast_eval = T, | ||
bundle_pixelarray = F, | ||
check_value = T, | ||
use_single_iteration_cpp = T | ||
) | ||
# LIMIT RANGE OF IDENTIFIER-HITS FROM CROPPED SEARCH REGION FOR ID-DOT | ||
if (input$do_crop_identifier_range) { | ||
hsv_results <- limit_identifier_coordinates( | ||
spectrums_object = hsv_results, | ||
image_dimensions = image_dimensions, | ||
identifiersearch_x0 = input$identifiersearch_x0, | ||
identifiersearch_x1 = input$identifiersearch_x1, | ||
identifiersearch_y0 = input$identifiersearch_y0, | ||
identifiersearch_y1 = input$identifiersearch_y1 | ||
) | ||
# # update the repackaged pixel.counts, so that the area's are updated properly | ||
# repackaged_pixel_counts[[idx]] <- sum(condition) | ||
# repackaged_pixel_counts[[idx]] <- current_identifier_idx[condition,] | ||
} | ||
# make a mask | ||
mask <- apply_HSV_color_by_mask( | ||
pixel.array = im, | ||
pixel.idx = hsv_results[[1]]$pixel.idx, | ||
target.color = "red", | ||
mask_extreme = input$mask_extreme | ||
) | ||
# display the mask | ||
display(HSVtoRGB(mask)) | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.