3D Texture#
Replication of Groen et al., 2012
from deadleaves import LeafGeometryGenerator, LeafAppearanceSampler, ImageRenderer
model = LeafGeometryGenerator(
leaf_shape="circular",
shape_param_distributions={
"area": {"powerlaw": {"low": 1000.0, "high": 10000.0, "k": 1.5}},
},
image_shape=(512, 731),
)
leaf_table, segmentation_map = model.generate_segmentation()
colormodel = LeafAppearanceSampler(leaf_table=leaf_table)
colormodel.sample_color(
color_param_distributions={"gray": {"constant": {"value": 0.0}}}
)
colormodel.sample_texture(
texture_param_distributions={
"source": {
"image": {"dir": "../../examples/textures/sphere"}
}, # this folder only contains a single file which will be used for all leaves
"alpha": {"constant": {"value": 1.0}},
}
)
renderer = ImageRenderer(
leaf_table=colormodel.leaf_table, segmentation_map=segmentation_map
)
renderer.render_image()
renderer.show()