小编dag*_*dag的帖子

使用 R 的图像颜色组合

我试图获得构成给定图片的每种颜色的百分比。我使用此代码获得 RGB 矩阵:

library(jpeg)
img <- readJPEG("C:/Users/Pictures/img.jpg")
dim(img)
#145 371   3
img<-img*255
#this operation is necessary to obtain an RBG scale
Run Code Online (Sandbox Code Playgroud)

在这一步,我不确定哪种方法是正确的。无论如何,我想获得这样的东西:

Count    RGB vector

200614   (255,255,255) 

4758     (253,253,218) 

4312     (250,250,229) 

1821     (235,237,242) 

1776     (212,214,226)

...
Run Code Online (Sandbox Code Playgroud)

然后我可以计算每种颜色的百分比。最后,我将尝试将标签与每个 RGB 向量相关联。

任何人都可以帮助我吗?

rgb r image colors image-processing

1
推荐指数
1
解决办法
989
查看次数

标签 统计

colors ×1

image ×1

image-processing ×1

r ×1

rgb ×1