pedrofrodenas / anaglypher

Anaglypher Python script for making anaglyph-3D maps from mono images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anaglyph estimation from mono images

Anaglypher Python script for making anaglyph-3D maps from mono images.

Overview

Our study tries to estimate a depth map from a mono image. It is a difficult task and there are different ways to approach it. My approach uses outdoor images. The vanishing point is the place where two or more parallel lines (real or imaginary) converge towards infinity in an image. For example, the lines that generate the edges of a road and its projection towards infinity. The place where these lines intersect in a literal or imaginary way, is what we know as the vanishing point.

Data

This aproach needs outdoor images containing vanishing point.

Model

First convert image to grayscale and apply canny transform.

Then apply Hough transform to obtain the main lines in the image.

Transforming the parametric space (θ,ρ) to (x,y) and plot the lines.

Then we get the cut points between lines and select vanishing point as the cut point that have most cut points closer.

With the vanishing point coordinates, we build a Depth Map.

Finally, we construct with the depth map the parallax matrix and apply channel offset.

Example.py

import cv2
import anagliph
import string
from random import choices

# read 2D-Image input
shape = cv2.imread('images/carretera.jpg')

# Scale input image for less time computation
Image3D = anagliph.ConvertImageto3D(shape, xscale=0.3, yscale=0.3,
                                    cannymin=100, cannymax=200,
                                    nlines=4,threshold=0.7, nhood_size=80)

# Random output image name
name = ''.join(choices(string.ascii_uppercase + string.digits, k=5))

# Save 3D-Anaglyph Image
cv2.imwrite('results/{0}.jpg'.format(name),Image3D)

results/WICZG.jpg results/H1GF3.jpg results/LUK9B.jpg results/7SNE1.jpg

License

(c) 2013 Pedro Rodenas. MIT License

About

Anaglypher Python script for making anaglyph-3D maps from mono images.

License:MIT License


Languages

Language:Python 100.0%