Skip to content

Commit

Permalink
fix misspellings
Browse files Browse the repository at this point in the history
  • Loading branch information
disintegration committed Jun 13, 2017
1 parent 7230b78 commit 2712799
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ gift.New().DrawAt(dstImage, fgImage, image.Pt(100, 100), gift.OverOperator)
- Sepia(percentage float32)
- Sigmoid(midpoint, factor float32)
- Sobel()
- UnsharpMask(sigma, amount, thresold float32)
- UnsharpMask(sigma, amount, threshold float32)


### FILTER EXAMPLES
Expand Down
28 changes: 14 additions & 14 deletions convolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,19 @@ func GaussianBlur(sigma float32) Filter {
}

type unsharpMaskFilter struct {
sigma float32
amount float32
thresold float32
sigma float32
amount float32
threshold float32
}

func (p *unsharpMaskFilter) Bounds(srcBounds image.Rectangle) (dstBounds image.Rectangle) {
dstBounds = image.Rect(0, 0, srcBounds.Dx(), srcBounds.Dy())
return
}

func unsharp(orig, blurred, amount, thresold float32) float32 {
func unsharp(orig, blurred, amount, threshold float32) float32 {
dif := (orig - blurred) * amount
if absf32(dif) > absf32(thresold) {
if absf32(dif) > absf32(threshold) {
return orig + dif
}
return orig
Expand Down Expand Up @@ -424,10 +424,10 @@ func (p *unsharpMaskFilter) Draw(dst draw.Image, src image.Image, options *Optio
pxOrig := pixGetterOrig.getPixel(x, y)
pxBlur := pixGetterBlur.getPixel(x, y)

r := unsharp(pxOrig.R, pxBlur.R, p.amount, p.thresold)
g := unsharp(pxOrig.G, pxBlur.G, p.amount, p.thresold)
b := unsharp(pxOrig.B, pxBlur.B, p.amount, p.thresold)
a := unsharp(pxOrig.A, pxBlur.A, p.amount, p.thresold)
r := unsharp(pxOrig.R, pxBlur.R, p.amount, p.threshold)
g := unsharp(pxOrig.G, pxBlur.G, p.amount, p.threshold)
b := unsharp(pxOrig.B, pxBlur.B, p.amount, p.threshold)
a := unsharp(pxOrig.A, pxBlur.A, p.amount, p.threshold)

pixelSetter.setPixel(dstb.Min.X+x-srcb.Min.X, dstb.Min.Y+y-srcb.Min.Y, pixel{r, g, b, a})
}
Expand All @@ -439,7 +439,7 @@ func (p *unsharpMaskFilter) Draw(dst draw.Image, src image.Image, options *Optio
// The sigma parameter is used in a gaussian function and affects the radius of effect.
// Sigma must be positive. Sharpen radius roughly equals 3 * sigma.
// The amount parameter controls how much darker and how much lighter the edge borders become. Typically between 0.5 and 1.5.
// The thresold parameter controls the minimum brightness change that will be sharpened. Typically between 0 and 0.05.
// The threshold parameter controls the minimum brightness change that will be sharpened. Typically between 0 and 0.05.
//
// Example:
//
Expand All @@ -449,11 +449,11 @@ func (p *unsharpMaskFilter) Draw(dst draw.Image, src image.Image, options *Optio
// dst := image.NewRGBA(g.Bounds(src.Bounds()))
// g.Draw(dst, src)
//
func UnsharpMask(sigma, amount, thresold float32) Filter {
func UnsharpMask(sigma, amount, threshold float32) Filter {
return &unsharpMaskFilter{
sigma: sigma,
amount: amount,
thresold: thresold,
sigma: sigma,
amount: amount,
threshold: threshold,
}
}

Expand Down
10 changes: 5 additions & 5 deletions convolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ func TestGaussianBlur(t *testing.T) {
func TestUnsharpMask(t *testing.T) {

testData := []struct {
desc string
sigma, amount, thresold float32
srcb, dstb image.Rectangle
srcPix, dstPix []uint8
desc string
sigma, amount, threshold float32
srcb, dstb image.Rectangle
srcPix, dstPix []uint8
}{
{
"unsharp mask (0.3, 1, 0)",
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestUnsharpMask(t *testing.T) {
src := image.NewGray(d.srcb)
src.Pix = d.srcPix

f := UnsharpMask(d.sigma, d.amount, d.thresold)
f := UnsharpMask(d.sigma, d.amount, d.threshold)
dst := image.NewGray(f.Bounds(src.Bounds()))
f.Draw(dst, src, nil)

Expand Down

0 comments on commit 2712799

Please sign in to comment.