3

I have two images that I want to display on top of each other. one image a single channel image and the second image is a RGB image but with most of the area being transparent.

How these two images are generated in different functions. I know to just display these on top of each other, i can use the same window name when calling cvShowImage() but this doesn't work when they are drawn from different functions. When trying this, I used cvCvtcolor() to convert he binary image from single channel to RGB and then displaying the second image from another function. But this didn't work. Both images are same dimension, depth and number of channels (after conversion).

I want to avoid passing in one image into the second function and then draw them. So I'm looking for a quick dirty trick to display these two images overlapped.

Thank you

EDIT: alt text

AtharvaI
  • 1,160
  • 3
  • 16
  • 27
  • Are you trying to add/blend 2 images? http://stackoverflow.com/questions/3459960/blending-two-images-by-opencv/3460287#3460287 – karlphillip Jan 05 '11 at 15:06
  • not exactly, my first image is a binary image showing blobs, and my second image contains the bounding boxes for these blobs. So I just want to display them on to of each other literally. I'll edit my above post to show the two images. – AtharvaI Jan 05 '11 at 15:28

3 Answers3

1

There is no way to "overlay" images. cvShowImage() displays a single image from memory. You'll need to blend/combine them together. There are several ways to do this.
You can copy one into 1 or 2 channels of the other, you can use logical operations like AND, OR or XOR, you can use arithmetic operations like Add, Multiply and MultiplyScale (these operations will saturate values larger than 255). All these can also be done with an optional mask image like your blob image.
Naturally, you may want to do this into a third buffer so as not to overwrite your originals.

Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
1

I don't think that's possible. You'll have to create a new image or modify an existing one. Here's an article that shows how to do this: Transparent image overlays in OpenCV

Utkarsh Sinha
  • 3,295
  • 4
  • 30
  • 46
0

Apparently now it can be done using OpenCV 2.1 version http://opencv.willowgarage.com/documentation/cpp/highgui_qt_new_functions.html#cv-displayoverlay

hAcKnRoCk
  • 1,118
  • 3
  • 16
  • 30
  • thanks. but I believe only Text can be overlayed on the image. Check out the marked answer for the solution. thanks – AtharvaI Jan 29 '11 at 10:08