【发布时间】:2018-01-04 16:53:25
【问题描述】:
我在处理脚本 (.pde) 中以数组形式存储了 50 张航拍图像。
我想根据 RGB 颜色空间计算每个图像的每个像素中“绿色”的数量,以与单独的目标图像进行比较。目的是找出阵列中的 50 张图像中哪一张与目标图像最相似(它们是城市和乡村环境的航拍图像)。我根据每个像素的绿色 RGB 值进行比较。
到目前为止,我编写的代码使用PImage 加载目标图像和比较图像,并使用green 方法计算每个图像的每个像素中“绿色”的数量。 draw 中的输出仅供我在处理过程中可视化:
//declare variables for outputting images
PImage p,p1;
//declare test image array
PImage [] q;
//declare naming convention for images
String pre = "Image_";
void setup(){
size(850,800);
p = loadImage("LDN.jpg");
p.resize(width/2, height/2);
p1 = green(p);
//load array of comparison images
q = new PImage[51];
for(int i = 1; i<q.length; i++)
{
q[i]=loadImage(pre+(i) + ".jpg");
}
//calculate green value of every pixel in every comparison image in the the array
for(int j=1; j<q.length; j++)
{
q[j].resize(width/2, height/2);
q[j] = green(q[j]);
}
}
void draw(){
image(p,0,0);
image(p1,0,height/2);
image(q[13],width/2,0);
image(q[37],width/2,height/2);
}
PImage green(PImage pin)
{
pin.loadPixels();
PImage pout = createImage(pin.width, pin.height, RGB);
pout.loadPixels();
for(int i = 0; i<pout.pixels.length; i++)
{
pout.pixels[i] = color(0, green(pin.pixels[i]),0);
}
pout.updatePixels();
return pout;
}
我在处理帮助页面或更广泛的讨论中没有找到任何建议存储这些值以进行比较的方法。理想情况下,我想稍后使用Manhattan 或chamfer 距离比较器(如果我使用边缘检测)来比较它们。
【问题讨论】:
-
我不太确定你在问什么。您可以将它们存储在您想要的任何数据结构中。也许是一个二维数组?
-
@KevinWorkman - 我需要做的是将给定图像的每个像素中的绿色量与目标图像的相应像素中的绿色量进行比较 - 处理(和一般编码)是对我来说是新手,如果我没有很好地解释技术细节,请道歉。
标签: arrays image-processing processing rgb image-comparison