Version 0.60.0

img_to_solid

Creates a solid relief structure by extruding an image.

Signatures

  •   img_to_solid( image img )
  •   img_to_solid( image img, float scale, float minbase )
  •   img_to_solid( image img, float scale, float minbase, color sublayer )

Details

The function extrudes the gray scale of the image pixel colors a solid relief object. A gray scale of the form sqrt( r² + g² + b² ) is applied to interprete the image as height map.

Example

 make img_to_solid( image( "australia.jpg" ), 15.0, 25.0 )
 

The scaling can be in positive direction (i.e. creation of elevated regions) or negativ (creation of depressions).

A minimum thickness of the base plate can be given via the minbase parameter. If the scaling is positive this means that this is exactly the base plate thickness below a black pixel. If the scaling is negative, this is the thickness under the brightest pixel of the image.

The left and right figures show the constructions of a solid from a white-black two-pixel image (shown on top) using the img_to_solid() function. On the left image, a positive value was used for the scale parameter. A negative value was used for scale on the right. An inverted behavior can be achieved by using the invert() member of the image data type.

Note

The current version of img_to_solid() does not support the usage of image files with active alpha channel (i.e. images containing transparency) in combination with one of the first two constructors. Images with transparency require to provide a sublayer parameter (e.g. rgb(0,0,0)).

Return value

A solid that is the extruded version of the image.

Parameters

img

The image that is extruded.

scale

Defines how far a fully white pixel is extruded. If this value is positive, bright areas are elevated, if it is negative, bright areas are sunk-in. Default value is 1.0.

minbase

Minimum thickness of the plate. This value should be larger than 0.0. Default value is 1.0.

sublayer

If this parameter is given, pixels with partial or full transparency are interpreted as if blended with an opaque sublayer of this color.

See also

🗙

Search results for