Skip to content

Commit

Permalink
Option for extracting the original shape
Browse files Browse the repository at this point in the history
  • Loading branch information
YuhangTom committed May 1, 2024
1 parent 45e5175 commit 2602f2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions R/x3p_insidepoly_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @param x3p An `x3p` object representing a topographic scan.
#' @param mask_col A string representing the color to be used for the polygon.
#' @param concavity A strictly positive number used in `concaveman::concaveman` to influence the shape of the polygon.
#' @param concavity A strictly positive number used in `concaveman::concaveman` to influence the shape of the polygon. If `NULL`, the shape is taken to be the whole scan.
#' @param b A positive integer representing the block size for `x3ptools::x3p_average`.
#' @param ifplot A Boolean flag indicating whether to save ggplot lists in the output attributes.
#' @return A data frame summarizing the inner polygon. The data frame includes the following columns:
Expand Down Expand Up @@ -56,8 +56,14 @@ x3p_insidepoly_df <- function(x3p, mask_col = "#FF0000", concavity = 1.5, b = 10
n_discrete <-
NULL

x3p <- x3p %>%
x3p_surface_polygon(colour = mask_col, concavity = concavity)
if (!is.null(concavity)) {
x3p <- x3p %>%
x3p_surface_polygon(colour = mask_col, concavity = concavity)
} else {
x3p <- x3p %>%
x3p_add_mask()
x3p$mask <- mask_col
}

### Extract inner part as x3p based on mask
x3p_inner <- x3p_extract(x3p, mask_vals = mask_col)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Last-changedate](https://img.shields.io/badge/last%20change-2024--04--28-yellowgreen.svg)](https://github.com/YuhangTom/wire/commits/main)
[![Last-changedate](https://img.shields.io/badge/last%20change-2024--04--30-yellowgreen.svg)](https://github.com/YuhangTom/wire/commits/main)
[![CRAN
status](https://www.r-pkg.org/badges/version/wire.png)](https://CRAN.R-project.org/package=wire)
[![Codecov test
Expand Down
2 changes: 1 addition & 1 deletion man/x3p_insidepoly_df.Rd

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

0 comments on commit 2602f2e

Please sign in to comment.