问题描述
我想读取一个8位灰度bmp文件,重建它的像素矩阵,然后使用sobel运算符对其进行处理.但是程序无法构造像素矩阵,它会分割原始的pitcure块.当我像这样运行程序时;
./sobel cube.bmp输出.bmp处理.bmp输出.txt
cube.bmp是输入
output.bmp是构造的像素矩阵的输出.
proccessed.bmp是使用sobel运算符处理的输出.
代码和示例照片
缺少的地方是什么?
I want to read a 8 bit grayscale bmp file, reconstruct it''s pixel matrix, then process it with sobel operator. However program can not construct pixel matrix, it divides the original pitcure blocks. When I run the program like that;
./sobel cube.bmp output.bmp processed.bmp output.txt
cube.bmp is the input
output.bmp is the output of constructed pixel matrix.
proccessed.bmp is the output of processed with sobel operator.
Code and Sample photos
What''s the missing point ?
推荐答案
PIXEL **pixelArray = (PIXEL **)malloc(sizeof(PIXEL*)*(bitmapInfoHeader.biWidth*M));
PIXEL **pixelArray1 = (PIXEL **)malloc(sizeof(PIXEL*)*(bitmapInfoHeader.biWidth*M));
for(i = 0; i < (bitmapInfoHeader.biWidth*M); i++)
{
pixelArray[i] = (PIXEL *)malloc(sizeof(PIXEL)*(bitmapInfoHeader.biHeight*N));
pixelArray1[i] = (PIXEL *)malloc(sizeof(PIXEL)*(bitmapInfoHeader.biHeight*N));
}
您确定高度应乘以像素大小吗? RGB信息是水平存储还是垂直存储的? :confused:
祝你好运!
Are you sure the height should be multiplied by the size of a pixel? Is the RGB information stored horizontal and also vertical? :confused:
Good luck!
这篇关于在C中读取8位灰度bmp文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!