Reputation:
I am having a jpeg file, for which I want to find the color of each pixel. So I thought to convert the jpg to bitmap first, then apply threshold onto the bitmap file[ to convert each pixel either black or white], and then write a C code, that eliminates first 54 bytes of the file for the header, and after that get bytes in chunk of three [RGB] and check for the colour.
Now, how do I convert from jpeg to bitmap, and how do I apply threshold to it using imagemagick? What commands shall I use?
Also, do I stand corrected on the processing the pixels part for my C code? i.e. I will reject the first 54 bytes from the bitmap FILE and then get the bytes , three at a time, and store each differently. and do the same for all other 'chunk of three bytes'. Thanks
Upvotes: 0
Views: 1506
Reputation: 479
convert <jpgfile> -threshold xx% <bmpfile>
As for the BMP header info, I don't think it is as simple as that... I'm weak in C, but take a look at http://en.wikipedia.org/wiki/BMP_file_format for your header info. It says that it is variable in length. I would suggest searching google for example code on reading BMP files in C.
Or ==> "read bitmap file into structure"
Upvotes: 1