我是Android中图像处理的初学者。我正在尝试构建一个应用程序,我需要将颜色通道与图像分开并对它们执行计算。
我已成功从图像中提取RGB通道。我正在使用这些教程中提供的代码片段:https://xjaphx.wordpress.com/2011/06/21/image-processing-filter-color-channels/
这是代码片段:
public static Bitmap doColorFilter(Bitmap src, double red, double green, double blue) {
int width = src.getWidth();
int height = src.getHeight();
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
int A, R, G, B;
int pixel;
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
pixel = src.getPixel(x, y);
A = Color.alpha(pixel);
R = (int)(Color.red(pixel) * red);
G = (int)(Color.green(pixel) * green);
B = (int)(Color.blue(pixel) * blue);
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
}
return bmOut;
}
}
但我无法弄清楚从图像中提取NIR通道的方法。我提取这个NIR通道的目的是因为我需要在图像上应用NDVI(归一化差异植被指数)指标进行分析。
此外,在这段代码中,运行多个for循环已经使用了暴力方法。因此,程序变得非常慢,复杂度为-O(宽度*高度)。什么是计算这些独立渠道的有效方法?
图像属性的屏幕截图:
请帮我解决这个问题。
答案 0 :(得分:1)
来自制造商网站:
NDVI Red + NIR
此相机具有双波段滤波器,可捕获反射的红光 在RGB传感器的红色通道和反射的近红外光中 RGB传感器的蓝色通道。因此,您可以使用此单一相机 计算NDVI指数,尽管结果指数的对比度 图像不像使用单独的红色和近红外线那样“准确” 相机型号。