tags:

views:

79

answers:

1
+1  Q: 

Image scaling in C

Hi, I am designing a jpeg to bmp decoder which scales the image. I have been supplied with the source code for the decoder so my actual work is to design a scaler . I do not know where to begin. I have scouted the internet for the various scaling algorithms but am not sure where to introduce the scaling. So should I do the the scaling after the image is converted into bmp or should I do this during the decoding at the MCU level. am confused :(

If you guys have some information to help me out, its appreciated. any material to read, source code to analyse etc....

Oh I forgot to mention one more thing, this is a porting project from the pc platform to a fpga, so, not all the library files are available on the target platform.

+2  A: 

There are many ways to scale an image.

The easiest way is to decode the image and then scale using a naive scaling algorithm, something like:

dest_pixel [x,y] = src_pixel [x * x_scale_factor, y * y_scale_factor]

where x/y_scale_factor is

src_size / dest_size

Once you have that working, you can look into more complex scaling systems, things like bilinear filter. For example, the destination pixel is the average of several source pixels when reducing the size and an interpolation of several source pixels when increasing the size.

Skizz
Scale factor should be the inverse of what you have there. Otherwise you will be accessing out-of-bounds pixels in the source image. (Imagine src_size is 1 and dest_size is 2 and what happens as a result.)
Jim Buck
@Jim: A case of not enough sleep there I think. Fixed it now.
Skizz
Thanks Skizz and jim, I did a simple array scaling and it worked. If you have some across complex scaling source codes, post it so i can study them. (any language, any platform).
Gan