average blend method
This commit is contained in:
parent
5f7508fe3d
commit
603871d556
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Requirements
|
||||||
|
- go >= 1.16.2
|
||||||
|
|
||||||
|
# Install
|
||||||
|
|
||||||
|
Just `git clone`, `cd pixelweaver` and `go build` bro
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
See `pixelweaver -help` for all available options
|
||||||
|
|
||||||
|
Example : Blends three random pictures stored in specified folder, using averaging, with a sepia filter
|
||||||
|
`pixelweaver -amount 3 -input ~/Photos -blending average -sepia`
|
||||||
|
|
||||||
|
# Resources
|
||||||
|
- [image package documentation on pkg.go.dev](https://pkg.go.dev/image)
|
||||||
|
- [Sighack - Averaging RGB Colors the Right Way](https://sighack.com/post/averaging-rgb-colors-the-right-way)
|
||||||
|
- [Sau Sheong - Image processing with Go](https://go-recipes.dev/more-working-with-images-in-go-30b11ab2a9f0?gi=3bb0ce492e2e)
|
6
blend.go
6
blend.go
@ -195,6 +195,10 @@ func filter(pixel color.Color) color.Color {
|
|||||||
return pixel
|
return pixel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func average(fc uint8, bc uint8, fa uint8) float64 {
|
||||||
|
return (float64(fc)/2 + float64(bc)/2)
|
||||||
|
}
|
||||||
|
|
||||||
func darken(fc uint8, bc uint8, fa uint8) float64 {
|
func darken(fc uint8, bc uint8, fa uint8) float64 {
|
||||||
return math.Min(float64(fc), float64(bc))
|
return math.Min(float64(fc), float64(bc))
|
||||||
}
|
}
|
||||||
@ -214,6 +218,8 @@ func blend(fc uint8, bc uint8, fa uint8, ba uint8) float64 {
|
|||||||
switch ConfigRegister.Method {
|
switch ConfigRegister.Method {
|
||||||
case "darken":
|
case "darken":
|
||||||
newValue = darken(fc, bc, fa)
|
newValue = darken(fc, bc, fa)
|
||||||
|
case "average":
|
||||||
|
newValue = average(fc, bc, fa)
|
||||||
case "ligten":
|
case "ligten":
|
||||||
newValue = lighten(fc, bc, fa)
|
newValue = lighten(fc, bc, fa)
|
||||||
case "fuckyfun":
|
case "fuckyfun":
|
||||||
|
@ -48,7 +48,7 @@ func (c *Config) SetOutputDimensions() {
|
|||||||
|
|
||||||
func initConfigRegister() {
|
func initConfigRegister() {
|
||||||
// command line arguments
|
// command line arguments
|
||||||
flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, fuckyfun")
|
flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, average, fuckyfun")
|
||||||
flag.StringVar(&ConfigRegister.OutputDir, "output", "./", "Output directory")
|
flag.StringVar(&ConfigRegister.OutputDir, "output", "./", "Output directory")
|
||||||
flag.StringVar(&ConfigRegister.InputDir, "input", "/home/gator/Photos", "Input directory. Where to look the images from")
|
flag.StringVar(&ConfigRegister.InputDir, "input", "/home/gator/Photos", "Input directory. Where to look the images from")
|
||||||
flag.StringVar(&ConfigRegister.BaseImage, "base-img", "", "Path to the base image to work with. Random image if not set")
|
flag.StringVar(&ConfigRegister.BaseImage, "base-img", "", "Path to the base image to work with. Random image if not set")
|
||||||
|
Loading…
Reference in New Issue
Block a user