[Ilugc] [X-POST]: Reading an image file
List, I have been trying to search on reading an image file via C. I haven't been able to find code without libraries. However, being aware of the 'binary' mode in Windows (Turbo C++), I had read it using fopen, fread and fseek to read the header and then the contents. However, this reading was done reading individual bytes and not reading it using structures. Apologies, ahead, because, I suspect I may be using wrong 'terms' or may have some incorrect information. (Correct me, thanks) For example, a .bmp (grayscale image) file has first 54 bytes as header (IIRC, correct me, if I'm wrong). Somewhere within that, there's the height and width of the image. Following the 54 bytes are the pieces of image data containing integers between 0 - 255 representing grayscale colors. This seemed to work in Windows because I could see the results. Now, I do know that there are libraries that make this task easier in various distributions of Linux but the purpose (or requirements, If I may say) here it to read it in the same way as it was done in Windows. Though I also do see 'b' mode in the manual page of 'man fread', but I'm doubtful about the results. If anyone has tried to read an image file or has good sample code that I can lookup, would like to have links to it. Alternately, if someone can put in a few details regarding this in a little more 'easy-to-understand' way, that would be helpful. Thanks in advance for any help. -- Roshan Baladhanvi ___ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
Re: [Ilugc] [X-POST]: Reading an image file
> Though I also do see 'b' mode in the manual page of 'man fread', but > I'm doubtful about the results. any specific reasons? Could there be a difference in the size of the data types? Can you mask for the bits and see if that makes sense? Just guessing too loud :-) Abishek ___ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
Re: [Ilugc] [X-POST]: Reading an image file
On Tue, Dec 29, 2009 at 10:50 AM, Roshan wrote: > Though I also do see 'b' mode in the manual page of 'man fread', but > I'm doubtful about the results. If anyone has tried to read an image > file or has good sample code that I can lookup, would like to have > links to it. Alternately, if someone can put in a few details > regarding this in a little more 'easy-to-understand' way, that would > be helpful. There is no binary mode in Unix, or rather the default is binary mode. It would be easier to know what you're talking about if you post your code. -- Roshan Mathews http://teamtalk.im ___ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
Re: [Ilugc] [X-POST]: Reading an image file
> There is no binary mode in Unix, or rather the default is binary mode. > It would be easier to know what you're talking about if you post your > code. +1. or perhaps it is the open/read functions that you need as opposed to fopen and fread. again, just thinking aloud. Abishek ___ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
Re: [Ilugc] [X-POST]: Reading an image file
On Tue, Dec 29, 2009 at 10:50 AM, Roshan wrote: > List, > > I have been trying to search on reading an image file via C. I haven't > been able to find code without libraries. Why are you looking code without library? I request you to use OpenCV .Intel has created an open-source (free!) image processing library (OpenCV)that can be used by programmers who are writing their own imaging application software. OpenCV will Support the following image formats: BMP, DIB, JPEG, JPG, JPE, PNG, PBM, PGM, PPM,SR, RAS, TIFF, TIF. http://opencv.willowgarage.com/wiki/ http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/index.html If you still want code without library . Take a look at cvLoadImage OpenCV function source code. The core libraries (cv, cvaux) are *written* in *C*/C++ . Thanks & Rg Mohan L ___ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc