我想绘制图像的RGB强度图,如3种颜色的正弦波。任何人都可以提出任何想法吗?
答案 0 :(得分:2)
每种颜色分量(通常)有256级(8位)。如果图像具有Alpha通道,那么每个像素的整体图像位将为32,否则对于仅RGB的图像,它将为24。
我会在算法上推出这个以获得图像直方图,由你来编写绘图代码。
// Arrays for the histogram data
int histoR[256]; // Array that will hold the counts of how many of each red VALUE the image had
int histoG[256]; // Array that will hold the counts of how many of each green VALUE the image had
int histoB[256]; // Array that will hold the counts of how many of each blue VALUE the image had
int histoA[256]; // Array that will hold the counts of how many of each alpha VALUE the image had
// Zeroize all histogram arrays
for(num = 0 through 255){
histoR[num] = 0;
histoG[num] = 0;
histoB[num] = 0;
histoA[num] = 0;
}
// Move through all image pixels counting up each time a pixel color value is used
for(x = 0 through image width){
for(y = 0 through image height){
histoR[image.pixel(x, y).red] += 1;
histoG[image.pixel(x, y).green] += 1;
histoB[image.pixel(x, y).blue] += 1;
histoA[image.pixel(x, y).alpha] += 1;
}
}
您现在拥有直方图数据,由您来绘制它。请记住,上面只是一个算法描述,而不是实际代码