# Problem with combining RGB binary images

**URL:** <https://forum.kirupa.com/t/problem-with-combining-rgb-binary-images/318454>\
**Category:** Uncategorized\
**Created:** [January 20, 2011, 5:27pm UTC](https://forum.kirupa.com/t/problem-with-combining-rgb-binary-images/318454 "2011-01-20T17:27:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![meth](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@meth](https://forum.kirupa.com/u/meth)\
**Post date:** [January 20, 2011, 5:27pm UTC](https://forum.kirupa.com/t/problem-with-combining-rgb-binary-images/318454/1 "2011-01-20T17:27:34Z")

</div>

hi, im trying to combine 3 binary images taken from each rgb channel. however, after i combine them the output is not in binary image form which is black and white, instead it has some color on it. my combine code is as follow:

```auto
for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                int clr = inputbuff.getRGB(y, x);

                int red = (clr & 0x00ff0000) >> 16;
                int green = (clr & 0x0000ff00) >> 8;
                int blue = clr & 0x000000ff;
                int grey = (11 * red + 16 * green + 5 * blue) / 32;

                red = freq_red[red] & 0xFF;
                green = freq_green[green] & 0xFF;
                blue = freq_blue[blue] & 0xFF;
                grey = freq_grey[grey] & 0xFF;

                int alpha = 0xff000000;
             
             
		int combine = alpha | (red <<16) | (green <<8) | blue;

                process_red[x * height + y] = (0xFF<<24)|(red<<16)|(red<<8)|red;
                process_green[x * height + y] = (0xFF<<24)|(green<<16)|(green<<8)|green;
                process_blue[x * height + y] = (0xFF<<24)|(blue<<16)|(blue<<8)|blue;
                process_grey[x * height + y] = (0xFF<<24)|(grey<<16)|(grey<<8)|grey;
                process_rgb[x * height + y] = clr;
                process_combine[x * height + y] = combine;

            }
        }

```

and it gives me output as follow:  
 ![](http://img593.imageshack.us/i/basicrgbsample.png/)  
(in case you cant see the output please go to [http://img593.imageshack.us/i/basicrgbsample.png/](http://img593.imageshack.us/i/basicrgbsample.png/))

can anyone please help me how to get the correct output image? thanks in advance.
