pixel_index {pliman} | R Documentation |
Get the pixel indices for a given row of a binary image
Description
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.
Usage
pixel_index(bin, row = NULL, direction = "updown")
Arguments
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 |
Value
A numeric vector containing the row index, the minimum pixel index, the median pixel index, and the maximum pixel index.
Examples
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)