View source: R/utils_polygon.R
pixel_index | R Documentation |
This function finds the first row in the bin matrix that has a value greater than 0 (TRUE). It then calculates the minimum, median, and maximum values for the pixels in that row and creates an array containing the row index, the minimum pixel index, the median pixel index, and the maximum pixel index.
pixel_index(bin, row = NULL, direction = "updown")
bin |
A logical matrix representing a binary image |
row |
An optional row index. If not provided, the function selects the first non-zero row. |
direction |
The direction for row selection when row is not provided.
If set to |
A numeric vector containing the row index, the minimum pixel index, the median pixel index, and the maximum pixel index.
library(pliman)
leaf <- image_pliman("sev_leaf.jpg")
bin <- image_binary(leaf, "NB")[[1]]
# first row with leaf (17)
pixel_index(bin)
# index at the row 100
pixel_index(bin, row = 100)
plot(leaf)
points(x = 248, y = 17, pch = 16, col = "red", cex = 2)
points(x = 163, y = 100, pch = 16, col = "red", cex = 2)
points(x = 333, y = 100, pch = 16, col = "red", cex = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.