Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何确定R中某一图像颜色的比例?_R_Image Processing - Fatal编程技术网

如何确定R中某一图像颜色的比例?

如何确定R中某一图像颜色的比例?,r,image-processing,R,Image Processing,我试图写一个脚本来区分彩色水滴的数量/表面积与图像的白色背景: 我刚开始定义颜色: red <- as.vector(image[,,1]) green <- as.vector(image[,,2]) blue <- as.vector(image[,,3]) white <- (red + green+ blue) red这不是一项简单的任务,也不是一项您应该尝试在BaseR中完成的任务,除非您有重新发明许多轮子的强烈愿望 幸运的

我试图写一个脚本来区分彩色水滴的数量/表面积与图像的白色背景:

我刚开始定义颜色:

   red   <- as.vector(image[,,1])
   green <- as.vector(image[,,2])
   blue  <- as.vector(image[,,3])  
   white <- (red + green+ blue)

red这不是一项简单的任务,也不是一项您应该尝试在BaseR中完成的任务,除非您有重新发明许多轮子的强烈愿望

幸运的是,有一些软件包可以提供帮助。由于您的任务与细胞显微图像分析中面临的任务相似,因此,最好从

在这里,您可以找到一些有用软件包的链接,包括
EBImage
,该软件包托管在Bioconductor上,而不是CRAN上,因此您必须使用以下软件包进行安装:

install.packages(“BioManager”)
BioManager::安装(“EBImage”)
我已经将中给出的示例改编为您的用例

首先,我们加载包,并确保我们可以读取您的图像:

库(EBImage)
点
   rcc <- red/white
   gcc <- green/white
   bcc <- blue/white
   excess_blue <- (2*bcc - (rcc+gcc))
par(mfrow = c(2, 2))
plot(dots)
text(140, 140, "All", cex = 3)
plot(getFrame(dots, 1))
text(140, 140, "Red", cex = 3, col = "red")
plot(getFrame(dots, 2))
text(140, 140, "Green", cex = 3, col = "green")
plot(getFrame(dots, 3))
text(140, 140, "Blue", cex = 3, col = "blue")
par(mfrow = c(1, 1))
display(thresh_dots)
length(which(nmask > 0.5))/length(nmask)
#> [1] 0.134278