Save image in C - c

I'm just learning C language, so I apologize in advanced if my question is not clear or if I'm asking the wrong question (or a dummy question).
I wrote a code in C that produces the fractal fern points and then plots them using openGL.
My code is similar to the one found here (http://www.cs.csubak.edu/~marc/code/opengl/fern.c).
Now I want to save the image that I obtained to a file. I've been searching about this and most of the answers suggest to use a library for this, but I'd like to write my own function. I understand that the first step is to use glreadpixels to read the pixel, but I'm not sure what should be the next step.
Thanks for your time and help

libbmp is a very good choice.
http://code.google.com/p/libbmp/

Related

How to store data from a .TIFF file to then modify it with my C program

I know few about this and i'm trying to keep building upon it. My goal is to do image stacking with some criteria using C language, as i came upon some cool ideas i think i should be capable of doing with my photos. My C background should be enough to understand what i may need. That being said...
So far i've learned how to read an existing .TIFF file and save it into a char array. The problem is i don't know in which way its data is contained so that i can then be able to analize individual pixels and modify them, or build another .TIFF file from data i previously read.
I've read some things about (a so called) libtiff.h which may be usefull but i can't find where to get it, neither how to install it.
Does anyone know how a .TIFF file data is stored so that i can read it and apply changes to it?
Also,
Does anyone have any experience with handling image files and editing in C? Where did you learn it from?
Do you know of any place i could search for information/tutorials?
Any help will be very usefull,
Thanks in advance.
You can do an enormous amount of very sophisticated processing on TIFFs, or any one of 190+ other formats with ImageMagick without any need to understand TIFF format or write any C. Try searching on Stack Overflow for [imagemagick]
If you want to do processing yourself, consider https://cimg.eu
Another option might be to convert your TIFFs to NetPBM which is much, much simpler to read and write in C. That would be as follows with ImageMagick:
magick INPUT.TIFF -compress none OUTPUT.PPM

Load a PNG image from a USB stick with stb_image

I'm asking here because the documentation concerning the aforementioned library is horribly lacking. As written in the title, I want to load a PNG image from a USB stick and then decode it using stb_image but I don't know how to go about it.
To add a bit of context, I'm using a discovery board from ST, the STM32F769I and running FreeRTOS.
I thought first that simply calling "stbi_load" with the full path ("0:MYIMAGE.PNG") would suffice but it doesn't.
Therefore, I suppose another function must be used for that purpose but which one ? stbi_load_from_memory ? I don't have it very clear. Or should I first call a FatFS function like f_open() before being able to call any decoding function?
Any help is more than appreciated. It'd be very helpful if you could write here a simple example that does the job.
Thanks in advance.

Simple file compression in C

I'm new to programming with C, and I need somewhere that I can read up on file compression in C. I only need a simple recognised method. An example would help but mostly somewhere I can read to understand.
maybe a good starting point is RLE which is extremely simple but not so trivial to implement. Check it out: http://en.wikipedia.org/wiki/Run-length_encoding
The first method I learned in school is Huffman Encoding. Here is a link: http://en.wikipedia.org/wiki/Huffman_coding
Here is a link to a C implementation: http://scanftree.com/Data_Structure/huffman-code

Computed Tomography: Matlab to C/OpenCV code conversion error

I am working on a Computed Tomography problem, in which I have to simulate the generation of the raw data or sinogram that a CT apparatus generates.
Matlab has an in-built function "radon()" to simulate the same. I have successfully written a custom code in Matlab to generate the sinogram (ie: without using radon() ).
I have converted this code into C, using the OpenCV library to handle the loading/display/saving of images.
The problem is that though my matlab output generates the sinogram as expected, my C code does not. I have merely translated the Matlab code into C but the C output is oriented differently as well has black strips in between. The gray levels in the C output kind of resemble the Sinogram gray levels and pattern generated by the matlab code. Only thing it appears segmented in C.(I will send the images across if you gimme your mail id since i cannot attach them here.)
Could someone help me out as to why this is happening? I have peer-reviewed my code and checked for type cast errors, memory allocations etc. But They all seem correct.
Does matlab handle data that differently than C? What could be the explanation for the tilt?
Please Help me out. Do let me know if you need any more clarification regarding the problem statement or need to see the algorithm.
Thanks!
Very hard to help with a question like this, when we don't see either code, the output, or the expected output.
Perhaps you can upload the images to some public image hosting, and add links from the question?
If you're doing trigonometric function calls (sin() and friends), I would pay extra attention to the arguments used, and also check if maybe Matlab is delivering more precision in the result, somehow. Of course, this is a stab in the dark since I'm not familiar with your domain.
Here are the images related to the doubt I asked in the original post
The expected output:
http://www.photoshop.com/users/pyridot/albums/a40e3f7326d942ff821fc00612e6b458/view#e027c2b94bfd4210870bc6c57b1f1a03
The C Output:
http://www.photoshop.com/users/pyridot/albums/a40e3f7326d942ff821fc00612e6b458/view#ff529abedb3e49aa8865276f2c2bc625

steganography library in C or Obj-C

Does anyone know of a good steganography library I can use thats written in C or Objective-C? It would need to be used in a Mac OS X application.
My provocative answer will be that you should try to implement/learn some algorithms for image hiding/unhiding yourself. Sample algorithm of 3-bit image hiding into 24-bit image is very simple and consists of about 10 Python lines or so (of course it may be a bit more with C/Obj-C). And you will get not bad quality of stego image - about 87.5% of original quality. So check my blog article about this steganography method.
This stego decoding method is done in GPU pixel shader program for fast decoding procedure.
However encoding was done with Python script which after use was deleted ;P
But i think that encoding procedure is very straightforward and can be understood from my blog article. If any questions about my stego algorithm- feel free to ask.

Resources