我想读取 RGB 值,但我得到的只是 0 - 255 个灰度值
I want to read RGB values, but all i get is 0 - 255 values in grey-scale
我一直在读取双指针数组中的图像文件。
BMP(char *fn, int no )
{
ifstream in(fn,ios::binary);
in.read((char*)&header,sizeof(header));
width=(int)(header[21]<<24|header[20]<<16|header[19]<<8|header[18]);
height=(int)(header[25]<<24|header[24]<<16|header[23]<<8|header[22]);
cout<<"Height:"<<height<<" Width:"<<width<<'n';
in.read((char*)&plt,sizeof(plt));
clrs=new unsigned char[width*height];
in.read((char*)clrs,width*height);
in.close();
rollNo = no;
}
我面临的问题是,它根据灰度读数读取从 0 到 255 的颜色值。
void showOne ()
{
for ( int i = 0 ; i < width*height ; i++ )
{
int val1 = clrs[i];
cout << "tt index : " << i << " :tt" << val1 << endl;
}
}
谁能告诉我如何将该读数转换为十六进制值,或者任何其他方法才能区分 RGB 值?
当图像编码每像素 24 位数据(真彩色(时,标头的字段 biBitCount 设置为 24(您必须检查(。
然后像素数据由三元组 BGR 字节组成。根据要对颜色值执行的操作,将保留原始字节或将它们转换为其他表示形式,三三个。
相关文章:
- 在 C++ 中将 RGB 更改为灰度
- OpenCV - 如何在灰度图像上应用 Kmeans?
- OpenCV - 如何将灰度转换为彩色(CV_8UC3)?
- C++灰度图像处理
- 如何显示具有 opengl 纹理的灰度图像
- C++ Gdi+将图像转换为灰度
- 将 BMP 图像转换为灰度
- 如何使用Canny到32位灰度
- 颜色到灰度转换
- (C++)(Visual Studio) 将高斯模糊滤镜应用于 RGB 中的灰度图像
- 使用 SSE 以最快的速度缩小 8 位灰度图像
- 使用 OpenCV 和 C++将 16 位灰度图像更改为彩色图像
- 有没有办法使用 glDrawPixel 渲染单通道灰度图像?
- goodFeaturesToTrack() 只适用于灰度?
- 如何在OpenCV中减去两个不同尺寸的图像和灰度图像
- 用C或C++读取/写入BMP/PNG灰度图像
- 我想读取 RGB 值,但我得到的只是 0 - 255 个灰度值
- 如何以灰度格式读取视频文件
- QImage:读取16位灰度TIFF (Qt, c++)
- 在不使用外部库的情况下在c++中读取灰度.jpeg图像