Read, Resize and Write Image

Hello,

My task is to read an image (with any kind of format), resize it and write it back to the disk (with a specific format, such as BitMap) without using any specialized read/write/process library. I just wonder if anybody can help me with the starting point like providing me with any concept of how I should go about to do so, any algorithm or so that I can research since at this moment, I have no clue how to start.

Thank you.
You are in over your head.

There are literally thousands of image formats. If you can narrow it down to less than ten, then it might be fun to write your own image reading functions...

Writing image files is often hairier than reading them... depending on your chosen format.

BMP files are relatively straight-forward, if you want to mess with them.
+1 Duoas for every image format in this list.
http://en.wikipedia.org/wiki/Comparison_of_graphics_file_formats

-Albatross
I am sure this is not an easy task. I will take your, Duoas, advice to identify the most common format to work with. However, even though with a specific format, I still don't have a basic point of how to solve the problem. I was searching on Google for any kind of algorithm, methods that have been used before or so... but still not used. My question is that what is the systematic way to, for example, read an image? Like finding a cosine of an angle, we need to divide the length of the triangle's adjacent divided by the length of the triangle's hypothenuse. This mean, I have to find these length... and so on. I try to find a road map like that for this problem, though, I don't know where to start looking.
I recommend you read up on the type of file you're going to be using (BMPs are, as Duoas said, one of the easier ones to deal with), and then figure out how to extract modifiable and workable data from that file based on the structure of that file. The definition of workable can be tailored to fit your needs, though for resizing expect needing to copy and/or delete pixels. A cector<vector <pixel> > might be useful, where pixel is a type you define.

-Albatross
Like Albatross and Duoas have said you need to identify which format you'll be working with and read up on how their specification. Typically googling for the specification of an image format gives reasonable results. Generally the image file(like many files) is made up of header info first them. data specific to the image. What the header and data parts look like is very specific to each format. Looking up the specification will tell you what these look like and lead you on how to parse, encode and decode the files
OK then, once you get past loading and saving image data, you need to learn a lot about digital image processing. Here's a link to get you started
http://en.wikipedia.org/wiki/Image_scaling

For what you are doing, you might want to consider something simple like a bilinear resampler.

If you want to get fancy, mess with lanczos resampling.

Good luck!
I would just like to advocate the use of 3rd party libraries (particularly open source, peer-reviewed, libraries). There is simply no way one developer can compete with the quality of an existing (possibly high-version) collaborative, and thoroughly-tested library. In addition to quality, consider maintenance of the library.

The last thing a project should do is take over the maintenance of a library (or reinvent the wheel) when there is already a well-supported solution available. Think about it: when you use a library, you are free from maintenance, bug submissions, and headaches! You get to periodically reap the benefits of upgrades and bug-fixes without doing the work. Now, who wouldn't want better quality and free maintenance?

I guess if you really just want to gain some experience playing with files and images, consider writing your own format with out compression to start.
Last edited on
Thanks everybody.

Tomorrow, I will actually plan to discuss the benefit of writing my own read/write function as opposed to using a pre-written library with my advisor. And to see if I can verify any more confusion regarding the project. It is very likely that I still need to complete the task this way, if so, I will definitely look into what you all recommend.

Thanks again.
If this is not a school project, it is a waste of company time to write your own routines to do everything...
It seems to me like that up till now since it will take me longer time to figure out this problem rather than actually coding for something useful. Though, I don't really know the justification behind this decision so I can't say. I, however, will raise this issue up for better understanding.

For now, thanks everybody for helping me. I will mark this as a solved thread till further information.
Topic archived. No new replies allowed.