################################################### ### chunk number 1: ################################################### library(CRImage) ################################################### ### chunk number 2: ################################################### 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