4.6 Gradients and Normals

► |  | Images

1 | Icons
2 | Logos
3 | Embedding Bitmaps in Compiled Files
4 | Floating-Point Bitmaps

▼ | 4 | Floating-Point Bitmaps

4.1 | Overview
4.2 | Struct Type and Accessors
4.3 | Conversion and Construction
4.4 | Component Operations
4.5 | Pointwise Operations
4.6 | Gradients and Normals
4.7 | Blur
4.8 | Resizing
4.9 | Compositing
4.10 | Spatial Transformations
4.11 | Effects

On this page:

flomap-gradient-x
flomap-gradient-y
flomap-gradient
flomap-gradient-normal

Racket
top contents ← prev up next →

### 4.6 Gradients and Normals🔗ℹ

> procedure (flomap-gradient-x fm) → flomap
> fm : flomap

> procedure (flomap-gradient-y fm) → flomap
> fm : flomap

These return, per-component, estimates of the local x- and y-directional derivatives using a 3×3 Scharr operator.

> > procedure
> > (flomap-gradient fm) |  | → |  |
> > flomap |  | flomap
> fm : flomap

Equivalent to (values (flomap-gradient-x fm) (flomap-gradient-y fm)).

Examples:

> > (define-values (dx-fm dy-fm)
> (flomap-gradient (flomap-drop-components fm 1)))
> > (values (flomap->bitmap (fm* 0.5 (fm+ 1.0 dx-fm)))
> (flomap->bitmap (fm* 0.5 (fm+ 1.0 dy-fm))))

> procedure (flomap-gradient-normal fm) → flomap
> fm : flomap

Given a one-component flomap, returns a 3-component flomap containing estimated normals. In other words, flomap-normal converts height maps to normal maps.

Examples:

> > (flomap->bitmap sine-fm)
> > (flomap->bitmap (flomap-gradient-normal sine-fm))
> > (flomap-gradient-normal fm)
> flomap-gradient-normal: expected argument of type <flomap
> with 1 component>; given: (flomap (flvector 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0...

top contents ← prev up next →