Question

I have extracted the depth map of 2 images and stored them as .tif file

now I would like to use openGL to join these two images depending on their depth

so I want to read the depth for each image from the .tif file and then use that depth to draw the pixel with the higher depth

to make it more clear the depth map are two images like this link

so say I have the pervious image and I want to join it with this image

link

my question is how to read this depth from the .tif file

Was it helpful?

Solution

Ok, I'll have a go ;-)

I see the images are just grayscale, so if the "depth" information is just the intensity of the pixel, "joining" them may be just a matter of adding the pixels. This is generally referred to as "blending", but I don't know what else you could mean.

So, you need to;

  1. Read the 2 images into memory
  2. For each pixel (assuming both images the same size):
    • read the intensity from image A[row,col]
    • read the intensity from image B[row,col]
    • write max(A[row,col],B[row,col]) to C[row,col]
  3. Save image C - this is your new "joined" image.

Now OpenGL doesn't have any built-in support for loading/saving images, so you'll need to find a 3rd party library, like FreeImage or similar.

So, that's a lot of work. I wonder if you really want an OpenGL solution or are just assuming OpenGL would be good for graphics work. If the algorithm above is really what you want, you could do it in something like C# in a matter of minutes. It has built-in support for loading (some formats) of image file, and accessing pixels using the Bitmap class. And since your created this images yourself, you may not be bound the the TIFF format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top