find_edges_2D: find_edges_2D

View source: R/RcppExports.R

find_edges_2DR Documentation

find_edges_2D

Description

Finds edges in an evenly spaced 2D grid.

Arguments

c_search

Logical vector

n_col

x direction of the matrix

Details

find_edges_2D

Checks all neighbour indices in a vector c_search for TRUE. If all neighbours are TRUE it is not an edge, else it is.

Value

logical vector if edge was found

Examples

n_col <- 7
n_row <- 4
c_search <- c(
  0,1,0,0,0,1,0,
  1,1,1,1,1,1,1,
  0,1,0,1,1,1,1,
  0,0,1,1,1,1,1
  )
m_grid <- expand.grid(x = 0:(n_col-1), y = 0:(n_row-1))|>
  as.matrix()|>
  cbind(c_search)
m_grid|>
head()
m_grid|>
plot(col = m_grid[,"c_search"],
  xlim=c(0,n_col-1), ylim=c(0,n_row-1),
  pch = 19,
  cex = 2.5,
  main = "Input: c_search")

m_grid <- cbind(m_grid,
                edge = find_edges_2D(m_grid[,"c_search"], n_col))

m_grid|>
  head()
m_grid|>
  plot(col = m_grid[,"edge"],
       xlim=c(0,n_col-1), ylim=c(0,n_row-1),
       pch = 19,
       cex = 2.5,
       main = "Edge")

wagnius-GmbH/slvwagner documentation built on Jan. 19, 2025, 7:10 a.m.