Tuesday, April 23, 2019

Epipolar Rectification 9c (ER9c)

ER9c is a variant of Epipolar Rectification 9b (ER9b). ER9c is far less aggressive as ER9b in rectifying images, so if you use ER9b and see a lot of distortion in the rectified images (when compared to the original images), I invite you to use ER9c instead.

In the ugosoft3d-9-x64.rar which you can download at the 3D Software page, you will find the manual for ER9c (er9c_manual.pdf) and a test case for ER9c under er9c_test.

Here is an example:


Input left and right images.

You can clearly see in this animated gif that switches between left and right image that the pair is not aligned. There is quite a bit of rotation, which is not good for automatic depth map generation.


Output left and right images.

The output left and right images are now aligned. This is good news for the automatic depth map generator that will generate the depth maps.

It should be noted that ER9c like ER9b gives the minimum and maximum disparity of the rectified stereo pair in the console window printout. These disparities can be used as input to the automatic depth map generators that are available here for download. Unlike ER9, there's no need to manipulate those values.

The windows executable (guaranteed to be virus free) is available for free via the 3D Software Page.

Monday, April 22, 2019

2d to 3d conversion - Bruce Lee

This post is an example that shows how to use 2d to 3d Image Conversion - The 3d Converter to create a depth map semi-automatically. I have uploaded on dropbox the gimp file which contains all the layers and the paths: bruce_lee.xcf. See 2d to 3d Image Conversion - The 3d Converter for how to use "The 3d Converter".

This is what the3dconverter_input.txt looks like:
reference_rgb_image.png
sparse_depthmap_rgba_image.png
dense_depthmap_image.png
gimp_paths.svg
ignored_gradient_rgba_image.png
emphasized_gradient_rgba_image.png
edge_rgba_image.png
0.0

All you need is a reference image (layer reference_rgb_image saved as reference_rgb_image.png), an "edge image" (layer edge_rgba_image saved as edge_rgba_image.png), a sparse depth map (layer sparse_depthmap_rgba_image saved as sparse_depthmap_rgba_image.png), and a bunch of equal_depth and relative_depth paths (saved as gimp_paths.svg).

Don't worry about ignored_gradient_rgba_image.png and emphasized_gradient_rgba_image.png as those are not used and therefore don't need to exist.


Reference image.


Dense depth map produced by The 3d Converter.


Wiggle/wobble created by Wiggle Maker.

Sunday, April 21, 2019

2d to 3d conversion - The Shawshank Redemption

This post is an example that shows how to use 2d to 3d Image Conversion - The 3d Converter to create a depth map semi-automatically. I have uploaded on dropbox the gimp file which contains all the layers and the paths: shawshank.xcf. See 2d to 3d Image Conversion - The 3d Converter for how to use "The 3d Converter".

Step 1:

Create an "edge image" (as a layer) using the "Pencil Tool" (using smallest possible hard-edge brush). All you have to do is trace along object borders (depth discontinuities). Depths in the dense depth map will not propagate across depth discontinuities symbolized by the edges in the "edge image".

Step 2:

Create a sparse depth map. Here, I simply put one white dot to indicate where the depth of my scene begins (going from foreground to background). You could put more depth clues in the sparse depth map but I find it easier to control depth clues using gimp paths.

Step 3:

Create equal_depth and relative_depth paths. In the case of an equal_depth path, all points in the path will have the same depth. Note that you can have a single path made up of multiple components. In the case of a relative_depth path, if the depth variation is positive, the 2nd point is farther in the scene by an amount corresponding to the depth variation. If the depth variation is negative, the 2nd point is closer. Note that a relative_depth path can only be defined by 2 points. I routinely run "The 3d Converter" with what I currently have and use Depth Player to check the produced depth map. If it's not too good, I go back to my gimp paths, fix them up, and re-run "The 3d Converter". I do this back and forth dance until the depth map looks good enough (doesn't have to be perfect). Note that I did some modeling for the prison warden that's peeking into the hole in the wall but I am not even sure you need to do that (for a wiggle/wobble). Do not spend any time modeling stuff that's not in the foreground (the other 2 guys peeking in), just model them as if they were cardboard props (meaning, give them a single uniform depth). That's what view-master did with their cartoon reels.

Step 4:

Once you are happy with how the 3d scene looks in "Depth Player" (doesn't have to be perfect), you can use Wiggle Maker to create a wiggle/wobble for sharing on social media.


Reference image.


Dense depth map obtained with "The 3d Converter".


Wiggle/wobble obtained with "Wiggle Maker".

Saturday, April 20, 2019

Painting Software - The Scribbler

"The Scribbler" simulates the scribbling effect where one kinda draws circles following a tracing path. This is an implementation of "Tone- and Feature-Aware Circular Scribble Art" by Chun-Chia Chiu, Yi-Hsiang Lo, Ruen-Rone Lee and Hung-Kuo Chu.

The software (for the windows 64 bit operating system) is available to download on dropbox at thescribbler-x64.rar.

After having extracted the archive, I invite you to go to the "jimi_hendrix" folder. There you will see a file named "thescribbler.bat" which needs to be edited (using notepad or wordpad or whatever editor you like) so that the path to the executable, thescribbler.exe, is the correct one for your installation. The software is run by double-clicking on "thescribbler.bat". The output from The Scribbler is an image showing black scribbles over a white background.

The Scribbler's behavior is controlled by the input file named "thescribbler_input.txt". The following shows what's in "thescribbler_input.txt" in the "jimi_hendrix" directory:

source image = source_image.png
tracing path points = sample.tsp
tracing path segments = sample.cyc
minimum disk radius = 2
maximum disk radius = 16
minimum center velocity = 0.2
maximum center velocity = 8
scribble rotation increment = 80
output image = output_image.png

The source image is the reference photograph. It can be either tiff, png, or jpg. It can be either grayscale or full color.

The file containing the tracing path points (sample.tsp) is the output from Painting Software - The Stippler.

The file containing the tracing path segments (sample.cyc) is the output from linkern. See Painting Software - The Path Maker.

The minimum disk radius, maximum disk radius, minimum center velocity, and maximum center velocity control the density of the scribbles. Imagine following the tracing path (the one generated by Painting Software - The Path Maker) and drawing circles without lifting the pen. Clearly, you can draw small or large circles. The minimum disk radius and maximum disk radius control that. About as clearly, you can go slow or fast drawing those circles. The minimum center velocity and maximum center velocity control that.

The scribble rotation increment is a bit hard to explain, to be honest. It's an angle in degrees that should be between 0 and 360. I guess you'll just have to try changing it and see what happens. I think that values between 20 and 80 are good values to try out.

The output image contains the scribbles in image form. It can be either tiff, png, or jpg.


Source image.


Output image.


Here is a tutorial video:



Source code: thescribbler on github.

Painting Software - The Path Maker

"The Path Maker" takes in a stippled image (produced by Painting Software - The Stippler) and outputs an image showing the shortest path that connects all these stipples. The path solves (approximately) the Traveling Salesman Problem (TSP), that is, it is the shortest possible route that visits each city (stipple point) and returns to the origin city (stipple point). At some point somebody figured out that solving the TSP on a stippled image creates a cool effect, mainly, because there is supposed to be no intersection. That's how "TSP art" was born.

Now, the crux of the problem is the (approximate) solution of the Traveling Salesman Problem (TSP) given a set of points (in our case, a whole bunch of stipples). I didn't code that part (it's a tough one) but the guys at Concorde TSP Solver did, and very well. Linkern is an implementation of the Chained-Lin-Kernighan heuristic for the TSP. The Path Maker uses the cycle/tour generated by linkern to produce the output image.

The software (for the windows 64 bit operating system) is available to download on dropbox at thepathmaker-x64.rar. It contains both linkern and The Path Maker. Concorde's linkern is used to get the tracing path as a cycle/tour (in text file form) and The Path Maker is used only to get the output image representing that tracing path.

After having extracted the archive, I invite you to go to the "jimi_hendrix" folder. There you will see a file named "linkern.bat" which needs to be edited (using notepad or wordpad or whatever editor you like) so that the path to the executable, linkern.exe, is the correct one for your installation. The software is run by double-clicking on "linkern.bat". The output from linkern (sample.cyc) is a tour/cycle of the points contained in the file sample.tsp. The file sample.tsp is the output from Painting Software - The Stippler. In the "jimi_hendrix" directory, there is also a file named "thepathmaker.bat" which needs to be edited (using notepad or wordpad or whatever editor you like) so that the path to the executable, thepathmaker.exe, is the correct one for your installation. The software is run by double-clicking on "thepathmaker.bat". The output from The Path Maker is an image showing the cycle/tour in image form.

The Path Maker's behavior is controlled by the input file named "thepathmaker_input.txt". The following shows what's in "thepathmaker_input.txt" in the "jimi_hendrix" directory:

source image = source_image.png
tracing path points = sample.tsp
tracing path segments = sample.cyc
output image = output_image.png
dot radius = 1
dot radius 2 (antialiasing) = 3

The source image is the reference photograph. It can be either tiff, png, or jpg. It can be either grayscale or full color. It should be the same one you used when running Painting Software - The Stippler.

The file containing the tracing path points (sample.tsp) is the output from Painting Software - The Stippler.

The file containing the tracing path segments (sample.cyc) is the output from linkern.

The output image contains the tracing path (black over white). It can be either tiff, png, or jpg.

Dot radius controls the size of the stipple dots. Dot radius 2 controls the amount of antialiasing. Dot radius 2 has to be greater than or equal to dot radius. Note that if dot radius 2 is equal to dot radius, there is no antialiasing in the output image.


Source image.


Output image.

Because Concorde can not be used for commercial purposes (actually, it's supposed to be used for academic research only), The Path Maker cannot be used for commercial purposes either. At some point, if there is a lot of interest for TSP art (which I doubt very much), I might implement my own version of an approximate TSP solver (based on the Lin-Kernighan TSP heuristic) but not at the moment as linkern does an excellent job.

Here's a tutorial video:



Source code: thepathmaker on github.

Friday, April 19, 2019

Painting Software - The Stippler

"The Stippler" simulates the stippling painting effect where only relatively small black dots are used to render a grayscale image which hopefully is a realistic representation of something, in our case, a photograph. This is an implementation of "Adaptive Incremental Stippling using the Poisson-Disk Distribution" by Ignacio Ascencio-Lopez, Oscar Meruvia-Pastor, and Hugo Hidalgo-Silva.

The software (for the windows 64 bit operating system) is available to download on dropbox at thestippler-x64.rar.

After having extracted the archive, I invite you to go to the "jimi_hendrix" folder. There you will see a file named "thestippler.bat" which needs to be edited (using notepad or wordpad or whatever editor you like) so that the path to the executable, thestippler.exe, is the correct one for your installation. The software is run by double-clicking on "thestippler.bat". The output from The Stippler is an image showing the stipples as black dots on a white background.

The Stippler's behavior is controlled by the input file named "thestippler_input.txt". The following shows what's in "thestippler_input.txt" in the "jimi_hendrix" directory:

source image = source_image.png
minimum disk radius = 4
maximum disk radius = 16
output image = sample.png
output file = sample.tsp
dot radius = 1
dot radius 2 (antialiasing) = 3

The source image is the reference photograph. It can be either tiff, png, or jpg. It can be either grayscale or full color.

The minimum and maximum disk radii control the density of the stipples.

The output image contains the stipples in image form (black dots over white background). It can be either tiff, png, or jpg.

The output file contains the stipples in text form. This output file is the one that's used by "The Path Maker".

Dot radius controls the size of the stipple dots. Dot radius 2 controls the amount of antialiasing. Dot radius 2 has to be greater than or equal to dot radius. Note that if dot radius 2 is equal to dot radius, there is no antialiasing in the output image.


Source image.


Output image.


Here is a tutorial video for "The Stippler":



Source code: thestippler on github.