Documentation ¶
Index ¶
- type CTOpts
- type Effect
- func NewBrightness(offset int) Effect
- func NewCartoon(opts CTOpts) Effect
- func NewGaussian(kernelSize int, sigma float64) Effect
- func NewGrayscale(algo GSAlgo) Effect
- func NewOilPainting(filterSize, levels int) Effect
- func NewPencil(blurFactor int) Effect
- func NewPixelate(blockSize int) Effect
- func NewSobel(threshold int, invert bool) Effect
- type GSAlgo
- type Image
- type Pipeline
- type Rect
- type SaveOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CTOpts ¶
type CTOpts struct { // BlurKernelSize is the gaussian blur kernel size. You might need to blur // the original input image to reduce the amount of noise you get in the edge // detection phase. Set to 0 to skip blur, otherwise the number must be an // odd number, the bigger the number the more blur BlurKernelSize int // EdgeThreshold is a number between 0 and 255 that specifies a cutoff point to // determine if an intensity change is an edge. Make smaller to include more details // as edges EdgeThreshold int // OilFilterSize specifies how bold the simulated strokes will be when turning the // style towards a painting, something around 5,10,15 should work well OilFilterSize int // OilLevels is the number of levels that the oil painting style will bucket colors in // to. Larger number to get more detail. OilLevels int // DebugPath is not empty is assumed to be a path where intermediate debug files can // be written to, such as the gaussian blured image and the sobel edge detection. This // can be useful for tweaking parameters DebugPath string }
CTOpts options to pass to the Cartoon effect
type Effect ¶
type Effect interface { // Apply applies the effect to the input image and returns an output image Apply(img *Image, numRoutines int) (*Image, error) }
Effect interface for any effect type
func NewBrightness ¶
NewBrightness returns an effect that can lighten of darken an image. To lighten an image set offset as a positive value between 0 and 255, to darken, set it as a negative number
func NewCartoon ¶
NewCartoon returns an effect that renders images as if they are drawn like a cartoon. It works by rendering the input image using the OilPainting effect, then drawing lines ontop of the image based on the Sobel edge detection method. You will probably have to play with the opts values to get a good result. Some starting values are: BlurKernelSize: 21 EdgeThreshold: 40 OilFilterSize: 15 OilLevels: 15
func NewGaussian ¶
NewGaussian is an effect that applies a gaussian blur to the image
func NewGrayscale ¶
NewGrayscale renders the input image as a grayscale image. numRoutines specifies how many goroutines should be used to process the image in parallel, use 0 to let the library decide
func NewOilPainting ¶
NewOilPainting renders the input image as if it was painted like an oil painting. numRoutines specifies how many goroutines should be used to process the image in parallel, use 0 to let the library decide. filterSize specifies how bold the image should look, larger numbers equate to larger strokes, levels specifies how many buckets colors will be grouped in to, start with values 5,30 to see how that works.
func NewPencil ¶
NewPencil renders the input image as if it was drawn in pencil. It is simply an inverted Sobel image. You can specify the blurFactor, a value that must be odd, to blur the input image to get rid of the noise. This is the gaussian kernel size, larger numbers blur more but can significantly increase processing time.
func NewSobel ¶
NewSobel the input image should be a grayscale image, the output will be a version of the input image with the Sobel edge detector applied to it. A value of -1 for threshold will return an image whos rgb values are the sobel intensity values, if 0 <= threshold <= 255 then the rgb values will be 255 if the intensity is >= threshold and 0 if the intensity is < threshold
type GSAlgo ¶
type GSAlgo int
GSAlgo the type of algorithm to use when converting an image to it's grayscale equivalent
type Image ¶
Image wrapper around internal pixels
func LoadImage ¶
LoadImage loads the specified image from disk. Supported file types are png and jpg
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline allows multiple effects to be composed together easily
type Rect ¶
Rect used for image bounds
func (Rect) ToImageRect ¶
ToImageRect returns an image.Rectangle instance initialized from this Rect
type SaveOpts ¶
type SaveOpts struct { // JPEGCompression a value between 1 and 100, if 0 specified, defaults to 95. // Higher values are better quality. Only applicable if the file ends with a // .jpg or .jpeg extension JPEGCompression int // ClipToBounds if true only the image inside the region specified by the bounds is // saved. Sometimes aftere running an image effect you may have outer bands that are // dead pixels, setting this to true crops them out. ClipToBounds bool }
SaveOpts specifies some save parameters that can be specified when saving an image