imageBinary: Segmentation and Binarization

Description Usage Arguments Details Value Examples

View source: R/imageBinary.R

Description

This function uses the Double-Criterion Thresholding method (DCT) to segment the object of study from the background of an image, and tranform the image to a binary image, i.e., a black and white image.

Usage

1
2
imageBinary(image, weight = c(-1, 2, -1), threshold1 = 30 / 255,
threshold2 = 0.075)

Arguments

image

an array of pixels of the image for processing.

weight

a 3 by 1 vector. The three elements indicate the weight of the pixel intensities of R,G,B, respectively. In default, it takes the value of c(-1, 2, -1), which helps to construct a relative green ratio.

threshold1,threshold2

Values between 0 and 1. threshold1 is applied to the sum of the RGB intensities. threshold2 is applied on the contrast intensity by the specified weight in the function.

Details

The plant pixels are classified as the intersection of sum of RGB intensities larger than threshold 1 and green intensities larger than threshold 2.

Value

A matrix of the processed image.

Examples

1
2
3
4
5
6
7
#read an RGB image
library(png)
image = readPNG(system.file("extdata", "image1.png",
                             package = "implant",
                             mustWork = TRUE))[ , ,c(1:3)]
imageB = imageBinary(image,  weight = c(-1, 2, -1),
threshold1 = 30 / 255, threshold2 = 0.05)

rwang14/implant documentation built on Sept. 6, 2020, 3:21 a.m.