Click here to Skip to main content
15,906,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ?

Posted
Updated 2-Nov-10 7:14am
v2
Comments
CPallini 2-Nov-10 11:01am    
Why are you redefining BITMAPFILEHEADER, BITMAPINFOHEADER in your code?
Chasan KIOUTSOUK MOUSTAFA 2-Nov-10 11:27am    
Where am i redefining them ? I use them to get headers to structs to use the necessary values.
CPallini 2-Nov-10 15:11pm    
Why don't you include 'windows.h' to get such declarations?

1 solution

Have a look at these lines of your code.
C#
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));
}


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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900