--- In [email protected], "John Matthews" <jm5...@...> wrote:
>
> --- In [email protected], Jos Timanta Tarigan <jos_t_tarigan@> wrote:
> >
> > the problem is i want to merge two image and merging the value of each
> > pixel. so basically pixel1 + pixel2 / 2.0;
> > the problem is each of these pixels is char. how can I convert it to float
> > and then convert it back to char again?
>
> Why do you need to convert to float? How about:
>
> char pixel1, pixel2, newPixel;
>
> newPixel = (pixel1 + pixel2) / 2;
Correction: this doesn't work for all values if char is signed; the following
does (I believe):
newPixel = ((unsigned char)pixel1 + (unsigned char)pixel2) / 2;
I'm assuming your pixel values are in the range 0..n where n < 256.