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.
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
"updown"
, the function starts scanning from the top of the image towards the bottom. If set to"downup"
, the function starts scanning from the bottom towards the top.
Value
A numeric vector containing the row index, the minimum pixel index, the median pixel index, and the maximum pixel index.
Examples
if (interactive() && requireNamespace("EBImage")) {
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)
}