Extract depth map from a 3D anaglyph image - algorithm

Suppose we have a generic red/cyan 3D anaglyph photo. How can it be processed so a depth map is extracted?

An anaglyph is just a superposition of a left-eye and right-eye image, using different colours for each.
Assuming you can use the colour components to extract the original greyscale left and right images, the problem is no different to any stereo vision problem. You need to determine the epipolar geometry, perform rectification on one of the images, then create a disparity map to derive relative depth information.

Related

Using RGB images and PointCloud, how to generate depth map from the PointClouds? (python)

I am working on fusing Lidar and Camera images in order to perform a classification object algorithm using CNN.
I want to use the KITTI Dataset which provide synchronized lidar and rgb image data. Lidar are 3D-scanners, so the output is a 3D Point Cloud.
I want to use depth information from point cloud as a channel for the CNN. But I have never work with point cloud so I am asking for some help. Is projecting the point cloud into the camera image plane (using projection matrix provide by Kitti) will give me the depth map that I want? Is Python libray pcl useful or I should move to c++ libraries?
If you have any suggestions, thanks you in advance
I'm not sure what projection matrix provide by Kitti includes, so the answer is it depends. If this projection matrix only contains a transformation matrix, you cannot generate depth map from it. The 2D image has distortion that comes from the 2D camera and the point cloud usually doesn't have distortion, so you cannot "precisely" map point cloud to rgb image without intrinsic and extrinsic parameters.
PCL is not required to do this.
Depth map essentially is mapping depth value to rgb image. You can treat each point in point cloud(each laser of lider) as a pixel of the rgb image. Therefore, I think all you need to do is finding which point in point cloud corresponding to the first pixel(top left corner) of the rgb image. Then read the depth value from point cloud based on rgb image resolution.
You have nothing to do with camera. This is all about point cloud data. Lets say you have 10 million of points and each point has x,y,z in meters. If the data is not in meters first convert it. Then you need the position of the lidar. When you subtract position of car from all the points one by one, you will take the position of lidar to the (0,0,0) point, then you can just print the point on a white image. The rest is simple math, there may be many ways to do it. First that comes to my mind: think rgb as binary numbers. Lets say 1cm is scaled to change in 1 blue, 256cm change equals to change in 1 green and 256x256 which is 65536 cm change equals change in 1 red. We know that cam is (0,0,0) if rgb of the point is 1,0,0 then that means 256x256x1+0x256+0x1=65536 cm away from the camera. This could be done in C++. Also you can use interpolation and closest point algorithms to fill blanks if there are

what's the use of Edge Detection of image?

After getting edge image using canny, what's the use of edge image?
Is there any use case of edge image?
find object and Segment it from image? or get the sharp,area and perimeter of the object?
As in the wikipedia,
Edge detection is the name for a set of mathematical methods which
aim at identifying points in a digital image at which the image
brightness changes sharply or, more formally, has discontinuities. The
points at which image brightness changes sharply are typically
organized into a set of curved line segments termed edges.
You can use this to find the interested area of an image by programmatically. For example, you have a lazer image of a indoor floor map and you want to detect the actual area a robot can visit, this will be useful. You can refer google more on this. It's just an example in real world usage.

Map image/texture to a predefined uneven surface (t-shirt with folds, mug, etc.)

Basically I was trying to achieve this: impose an arbitrary image to a pre-defined uneven surface. (See examples below).
-->
I do not have a lot of experience with image processing or 3D algorithms, so here is the best method I can think of so far:
Predefine a set of coordinates (say if we have a 10x10 grid, we have 100 coordinates that starts with (0,0), (0,10), (0,20), ... etc. There will be 9x9 = 81 grids.
Record the transformations for each individual coordinate on the t-shirt image e.g. (0,0) becomes (51,31), (0, 10) becomes (51, 35), etc.
Triangulate the original image into 81x2=162 triangles (with 2 triangles for each grid). Transform each triangle of the image based on the coordinate transformations obtained in Step 2 and draw it on the t-shirt image.
Problems/questions I have:
I don't know how to smooth out each triangle so that the image on t-shirt does not look ragged.
Is there a better way to do it? I want to make sure I'm not reinventing the wheels here before I proceed with an implementation.
Thanks!
This is called digital image warping. There was a popular graphics text on it in the 1990s (probably from somebody's thesis). You can also find an article on it from Dr. Dobb's Journal.
Your process is essentially correct. If you work pixel by pixel, rather than trying to use triangles, you'll avoid some of the problems you're facing. Scan across the pixels in target bitmap, and apply the local transformation based on the cell you're in to determine the coordinate of the corresponding pixel in the source bitmap. Copy that pixel over.
For a smoother result, you do your coordinate transformations in floating point and interpolate the pixel values from the source image using something like bilinear interpolation.
It's not really a solution for the problem, it's just a workaround :
If you have the 3D model that represents the T-Shirt.
you can use directX\OpenGL and put your image as a texture of the t-shirt.
Then you can ask it to render the picture you want from any point of view.

Extracting texture features from a co-occurrence matrix

I am attempting to create a content based image retrieval system (CBIR) in MATLAB for colour images, and am using a k-means algorithm to extract the feature vectors for images in my database. Each image has four clusters, and each cluster has information about the colour (R,G,B) and position (X,Y).
I am now trying to add a texture feature to my clusters, and need to use grey level co-occurrence matrices (GLCM) for this. I know that GLCM is just an indicator of probability that a certain grey level will appear next to another, and have created the GLCM for my images.
I am unclear about how to map the GLCM to the original image (and thus its clusters), since GLCM talks about pairs of pixels, and I would like each X,Y position to have texture information. How does one go about translating GLCM to pixels?
The output of GLCM seems to be a T-by-T matrix where T is the number of distinct grayscale levels in the image. Therefore, the size of this matrix does not really depend on the size of your image. The matrix also describes the texture of the whole image, so it isn't especially meaningful to associate GLCM data with a single pixel.
It sounds like you could compute GLCM for the individual clusters, since this would describe the texture within that cluster? I think graycomatrix requires a rectangular image, but you could find the bounding box for each cluster and extract GLCM from them separately.
If you wanted to get some more meaningful information out of a GLCM matrix (i.e. something that is appropriate as a 'feature'), you could use graycoprops which returns 4 summary statistics.

image smoothing in opengl?

Does opengl provide any facilities to help with image smoothing?
My project converts scientific data to textures, each of which is a single line of colored pixels which is then mapped onto the appropriate area of the image. Lines are mapped next to each other.
I'd like to do simple image smoothing of this, but am wondering of OGL can do any of it for me.
By smoothing, I mean applying a two-dimensional averaging filter to the image - effectively increasing the number of pixels but filling them with averages of nearby actual colors - basically normal image smoothing.
You can do it through a custom shader if you want. Essentially you just bind your input texture, draw it as a fullscreen quad, and in the shader just take multiple samples around each fragment, average them together, and write it out to a new texture. The new texture can be an arbitrary higher resolution than the input texture if you desire that as well.

Resources