Back to

Package carve

Latest Go to latest

The latest major version is .

Published: Mar 26, 2017 | License: MIT | Module:


Package carve implements the seam carving algorithm for dyanmic image resizing.


func GenerateCostMatrix

func GenerateCostMatrix(im image.Image) [][]float64

GenerateCostMatrix creates a matrix indicating the cumulative energy of the lowest cost seam from the left of the image to each pixel.

mat[x][y] is the cumulative energy of the seam that runs from the left of the image to the pixel at column x, row y.

func GenerateEnergyMap

func GenerateEnergyMap(im image.Image) image.Image

GenerateEnergyMap applies grayscale and sobel filters to the input image to create an energy map.

func ReduceHeight

func ReduceHeight(im image.Image, n int) (image.Image, error)

ReduceHeight uses seam carving to reduce height of given image by n pixels.

func ReduceWidth

func ReduceWidth(im image.Image, n int) (image.Image, error)

ReduceWidth uses seam carving to reduce width of given image by n pixels.

func RemoveSeam

func RemoveSeam(im image.Image, seam Seam) image.Image

RemoveSeam creates a copy of the provided image, with the pixels at the points in the provided seam removed.

type Point

type Point struct {
	X, Y int

Point defines an X Y point in an image.

type Seam

type Seam []Point

Seam defines a sequence of pixels through an image to be removed.

func FindLowestCostSeam

func FindLowestCostSeam(mat [][]float64) Seam

FindLowestCostSeam uses a cumulative cost matrix to identify the seam with the lowest total cumulative energy.

func GenerateSeam

func GenerateSeam(im image.Image) Seam

GenerateSeam returns the optimal horizontal seam for removal.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier