4 from gimpfu_numpy_converter
import *
5 from anaglyph_algorithm
import Anaglyph
6 from depth_algorithm
import DepthAlgo
8 def run(timg, tdrawable, mindisp, maxdisp,f1,f2,swap_lr):
9 """! Plugin main function. Combines layers to form an anaglyph.""" 12 depthalgo =
DepthAlgo(timg, mindisp, maxdisp)
16 for layer
in reversed(timg.layers):
18 if not depthalgo.is_depth_map(layer):
23 d = depthalgo.get_disparity(layer)
26 if (depthalgo.has_map(layer)):
27 print(
"%s --> special"%(layer.name))
28 anaglyph.update_ext(mf,d)
30 print(
"%s --> %f"%(layer.name,d))
33 pdb.gimp_progress_update(float(n)/float(nmax))
37 new_image = pdb.gimp_image_new(timg.width, timg.height, RGB);
38 new_layer = pdb.gimp_layer_new(new_image, timg.width, timg.height, RGB,
"main", 100.0, NORMAL_MODE)
39 pdb.gimp_layer_add_alpha(new_layer)
40 new_image.add_layer(new_layer)
46 display = pdb.gimp_display_new(new_image)
48 print(
"registering create_anaglyph plugin.")
51 """Create an anaglyph from layers (generates a new image) 52 Layers named depth=<float> specify a fixed depth from 0 (near) to 1(far). Values outside 0..1 are also possible.""",
"",
"",
"",
"",
53 "<Toolbox>/Xtns/Goto40/Create Anaglyph From Layers",
56 (PF_IMAGE,
"image",
"Input image",
None),
57 (PF_DRAWABLE,
"drawable",
"Input drawable",
None),
58 (PF_FLOAT,
"mindisp",
"min disparity, percent width (near)", 0.0),
59 (PF_FLOAT,
"maxdisp",
"max disparity, percent width (far)", 2.0),
60 (PF_FLOAT,
"left_factor",
"luminance correction left (0.0..1.0)", 1.0),
61 (PF_FLOAT,
"right_factor",
"luminance correction right (0.0..1.0)", 0.8),
62 (PF_BOOL,
"swap_lr",
"swap left/right",
False),
def copy_array_into_layer(data, layer)
copies an array into a layer.
This class is responsible to compute the depth of a layer.
This class represents an algorithm to compute two stereo images from gimp layers and to combine them ...
def run(timg, tdrawable, mindisp, maxdisp, f1, f2, swap_lr)
Plugin main function.
def layer2array(layer, dtype=None)
converts a layer to an array.