Skip to content

Commit

Permalink
Task 2: Handle downsampling of different resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
erichare committed Nov 7, 2024
1 parent 5259015 commit 0b9881e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ server <- function(input, output, session) {
bull$x3p <- lapply(bull$x3p, x3p_rotate, angle = -90)
}

# Check if we need to down-sample the bullet
# Calculate the closest integer `n` that samples reference resolution to match incrementX
if (nrow(bulldata$allbull) > 0) {
reference_resolution <- x3p_get_scale(bulldata$allbull$x3p[[1]]) / 1e6
target_resolution <- x3p_get_scale(bull$x3p[[1]])

if (reference_resolution != target_resolution) {
alert("Detected different resolutions, down-sampling to match reference resolution...")
m <- round(reference_resolution / target_resolution)

bull$x3p <- lapply(bull$x3p, x3p_sample, m = m)
}
}

cond_x3p_m_to_mum <- function(x3p)
{
scale <- x3p %>% x3p_get_scale()
Expand Down

0 comments on commit 0b9881e

Please sign in to comment.