Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Image-convolution/Go/image-convolution-3.go
Normal file
40
Task/Image-convolution/Go/image-convolution-3.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
// Files required to build supporting package raster are found in:
|
||||
// * This task (immediately above)
|
||||
// * Bitmap
|
||||
// * Grayscale image
|
||||
// * Read a PPM file
|
||||
// * Write a PPM file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"raster"
|
||||
)
|
||||
|
||||
var blur = []float64{
|
||||
1./9, 1./9, 1./9,
|
||||
1./9, 1./9, 1./9,
|
||||
1./9, 1./9, 1./9}
|
||||
|
||||
var sharpen = []float64{
|
||||
-1, -1, -1,
|
||||
-1, 9, -1,
|
||||
-1, -1, -1}
|
||||
|
||||
func main() {
|
||||
// Example file used here is Lenna100.jpg from the task "Percentage
|
||||
// difference between images" converted with with the command
|
||||
// convert Lenna100.jpg -colorspace gray Lenna100.ppm
|
||||
b, err := raster.ReadPpmFile("Lenna100.ppm")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
g0 := b.Grmap()
|
||||
g1 := g0.KernelFilter3(blur)
|
||||
err = g1.Bitmap().WritePpmFile("blur.ppm")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue