################################################### ### chunk number 1: ################################################### #line 32 "vignettes/CRImage/inst/doc/CRImage.Rnw" library(CRImage) ################################################### ### chunk number 2: ################################################### #line 38 "vignettes/CRImage/inst/doc/CRImage.Rnw" f = system.file("extdata", "exImg2.jpg", package="CRImage") exImgB=readImage(f) #find white pixels and exclude them from thresholding(if white is background) indexWhitePixel=which(exImgB[,,1]>0.85 & exImgB[,,2]>0.85 & exImgB[,,3]>0.85) #convert to grayscale exImgB=channel(exImgB,"gray") #calculate threshold t=calculateThreshold(as.vector(exImgB[-indexWhitePixel])) #create binary image exImgB[which(exImgB>=t)]=1 exImgB[which(exImgB