views:

56

answers:

4

Hi guys,

I have an image which is representative of an Array2D:

template<class T = uint8_t>
Array2D<T> mPixData[4];  ///< 3 component channels + alpha channel.

The comment is in the library. I have no clues about the explanation.

Could anybody please help me to?

  1. Explain what are the 3 component channels + alpha channel are about?

  2. How would I resize this image based on the mPixData?

Thanks in advance and I am very appreciated about your help!

+2  A: 

Without know what library this is, here is a stab in the dark:

  1. The type definition implies that it is creating a 2D array of unsigned chars (allowing you to store values up to 255.

    template<class T = uint8_t> Array2D<T>

  2. Then, mPixData itself is an array, which implies that at each co-ordinate, you have four values (bytes to contend with), 3 for the colours (let's say RGB, but could be something else) and 1 for Alpha.

  3. The "image" is basically this three dimensional array. Presumably when loading stuff into it, it resizes to the input - what you need to do is to find some form of resizing algorithm (not an image processing expert myself, but am sure google will reveal something), which will then allow you to take this data and do what you need...

Nim
+1  A: 

1) 3 component channels - Red Green Blue channels. alpha channel tells about image transparency

2) There are many algorithms you can use to resize the image. The simplest would be to discard extra pixels. Another simple is to do interpolation

VJo
+1  A: 

The 3 component channels represent the Red Green Blue (aka RGB) channels. The 4th channel, ALPHA, is the transparency channel.

A pixel is defined by mPixData[4]

mPixData[0] -> R
mPixData[1] -> G
mPixData[2] -> B
mPixData[3] -> A

Therefore, an image can be represented as a vector or array of mPixData[4]. As you already stated, in this case is Array2D<T> mPixData[4];

Resize/rescale/resample an image is not a trivial process. There are lots of materials available on the web about it and I think you should consider using a library to do this. Check CxImage (Windows/Linux).

There are some code here but I haven't tested it. Check the resample() function.

karlphillip
+1  A: 

Hi the 3 channels are the rgb + alpha channel. So red green and blue channels and the alpha channel. There are several methods to downscaling. You could take for example every 4 pixel, but the result would look quite bad, take a look at different interpolation methods e.g.: http://en.wikipedia.org/wiki/Bilinear_interpolation.

Or if you want to use a library use: http://www.imagemagick.org/Magick++/

or as mentioned by karlphillip: http://www.xdp.it/cximage.htm

inf.ig.sh