开发者

Problems with reading a 8bit grayscale bmp file in c

I wan开发者_如何学JAVAt 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


possibly not the answer you are looking for but, take a look at openCV.

Assuming your interest is in the image processing steps not specifically BMP manipulation, this library takes care of all the file i/o, display etc for you. It also has a good sobel filter.


A couple of comments:

Your processed.bmp has the look of a bitmap written with an incorrect row size or pixel size. You can tell that, because each row is horizontally shifted.

You are processing grayscale bitmaps, but you are reading and writing pixels as though they have RGB components, i.e.:

pixelArray[i][j].red = pixel.red;
pixelArray[i][j].green = pixel.green;
pixelArray[i][j].blue = pixel.blue;

A grayscale pixel is just a single 8-bit value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜