contour

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

README

go-image-contour

Opinionated Go package for working with the fogleman/contourmap package.

Documentation

Go Reference

Tools

$> make cli
go build -mod vendor -ldflags="-s -w" -o bin/contour cmd/contour/main.go
go build -mod vendor -ldflags="-s -w" -o bin/contour-svg cmd/contour-svg/main.go
contour

Generate contour data derived from an image and draws the results to a new image.

$> ./bin/contour -h
  -n int
    	The number of iterations used to generate contours. (default 12)
  -scale float
    	The scale of the final output relative to the input image. (default 1)
  -source-uri string
    	A valid gocloud.dev/blob.Bucket URI where images are read from. (default "file:///")
  -target-uri string
    	A valid gocloud.dev/blob.Bucket URI where images are written to. (default "file:///")
  -transformation-uri transform.Transformation
    	Zero or more additional transform.Transformation URIs used to further modify an image after resizing (and before any additional colour profile transformations are performed).

For example:

$> ./bin/contour -n 3 fixtures/tokyo.jpg

Will transform this:

In to this:

contour-svg

Generate contour data derived from an image and write the results as SVG path elements to a new file.

$> ./bin/contour-svg  -h
  -n int
    	The number of iterations used to generate contours. (default 12)
  -scale float
    	The scale of the final output relative to the input image. (default 1)
  -source-uri string
    	A valid gocloud.dev/blob.Bucket URI where images are read from. (default "file:///")
  -target-uri string
    	A valid gocloud.dev/blob.Bucket URI where images are written to. (default "file:///")
  -transformation-uri transform.Transformation
    	Zero or more additional transform.Transformation URIs used to further modify an image after resizing (and before any additional colour profile transformations are performed).

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContourImage

func ContourImage(ctx context.Context, im image.Image, n int, scale float64) (image.Image, error)

ContourImageSVG generate contour data derived from 'im' and draws it to a new `image.Image` instances. The scale and number of contours is adjusted relative to the 'scale' and 'n' values respectively.

func ContourImageSVG

func ContourImageSVG(ctx context.Context, wr io.Writer, im image.Image, n int, scale float64) error

ContourImageSVG generate contour data derived from 'im' and writes to 'wr' as SVG data. The scale and number of contours is adjusted relative to the 'scale' and 'n' values respectively.

func NewContourTransformation

func NewContourTransformation(ctx context.Context, uri string) (transform.Transformation, error)

NewContourWriter returns a new `ContourTransformation` instance configure by 'uri' in the form of:

contour://?n={N}&scale={SCALE}

Types

type ContourTransformation

type ContourTransformation struct {
	transform.Transformation
	// contains filtered or unexported fields
}

ContourTransformation is a struct that implements the `Transformation` interface for replacing the contents of an image with contours derived from its pixel values.

func (*ContourTransformation) Transform

func (tr *ContourTransformation) Transform(ctx context.Context, im image.Image) (image.Image, error)

Transform will derive the contours of 'im' and draw them to a new `image.Image` instance.

Directories

Path Synopsis
app
Package app for running a base image applications that can be imported alongside custom `transform.Transformation` and `gocloud.dev/blob` packages.
Package app for running a base image applications that can be imported alongside custom `transform.Transformation` and `gocloud.dev/blob` packages.
svg
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL