Beispiel #1
0
func MakeComputeMaker(src image.Image) *ComMaker {
	b := src.Bounds()
	sz := b.Size()
	width := sz.X / 8
	height := sz.Y / 8
	smallB := image.Rect(0, 0, width, height)

	cm := ComMaker{
		width:  sz.X / 8,
		height: sz.Y / 8,
		bound:  smallB,
	}

	// Make Grey Img
	gSrc := image.NewGray(b)
	draw.Draw(gSrc, b, src, image.ZP, draw.Src)

	// Make Smaller
	gDst := image.NewGray(smallB)

	// Prep Conversion
	cfg, err := rez.PrepareConversion(gDst, gSrc)
	if err != nil {
		log.Println(err)
		return nil
	}

	cm.rConv, err = rez.NewConverter(cfg, rez.NewBilinearFilter())
	if err != nil {
		log.Println(err)
		return nil
	}

	return &cm
}
Beispiel #2
0
func ToComputeImage(src image.Image) *image.Gray {
	// Small M
	bSize := src.Bounds().Size()
	smallBounds := image.Rect(0, 0, bSize.X/16, bSize.Y/16)
	smallM := image.NewGray(smallBounds)

	rez.Convert(smallM, src, rez.NewBilinearFilter())
	return smallM
}
Beispiel #3
0
func ToComputeImageCol(src image.Image) *image.RGBA {
	// Small M
	//bSize := src.Bounds().Size()
	smallBounds := src.Bounds() // image.Rect(0, 0, bSize.X/16, bSize.Y/16)
	smallM := image.NewRGBA(smallBounds)

	rez.Convert(smallM, src, rez.NewBilinearFilter())

	return smallM
}
Beispiel #4
0
func main() {
	im := load()
	resize(im, newResizeFuncNfnt(nfnt_resize.NearestNeighbor), "nfnt_nearest_neighbor.png")
	resize(im, newResizeFuncNfnt(nfnt_resize.Bilinear), "nfnt_bilinear.png")
	resize(im, newResizeFuncNfnt(nfnt_resize.Bicubic), "nfnt_bicubic.png")
	resize(im, newResizeFuncNfnt(nfnt_resize.MitchellNetravali), "nfnt_mitchell_netravali.png")
	resize(im, newResizeFuncNfnt(nfnt_resize.Lanczos2), "nfnt_lanczos2.png")
	resize(im, newResizeFuncNfnt(nfnt_resize.Lanczos3), "nfnt_lanczos3.png")
	resize(im, newResizeFuncXDraw(x_draw.NearestNeighbor), "x_draw_nearest_neighbor.png")
	resize(im, newResizeFuncXDraw(x_draw.ApproxBiLinear), "x_draw_approx_bilinear.png")
	resize(im, newResizeFuncXDraw(x_draw.BiLinear), "x_draw_bilinear.png")
	resize(im, newResizeFuncXDraw(x_draw.CatmullRom), "x_draw_catmull_rom.png")
	resize(im, newResizeFuncImaging(imaging.NearestNeighbor), "imaging_nearest_neighbor.png")
	resize(im, newResizeFuncImaging(imaging.Box), "imaging_box.png")
	resize(im, newResizeFuncImaging(imaging.Linear), "imaging_linear.png")
	resize(im, newResizeFuncImaging(imaging.MitchellNetravali), "imaging_mitchell_netravali.png")
	resize(im, newResizeFuncImaging(imaging.CatmullRom), "imaging_catmull_rom.png")
	resize(im, newResizeFuncImaging(imaging.Gaussian), "imaging_gaussian.png")
	resize(im, newResizeFuncImaging(imaging.Lanczos), "imaging_lanczos.png")
	resize(im, newResizeFuncGift(gift.NearestNeighborResampling), "gift_nearest_neighbor.png")
	resize(im, newResizeFuncGift(gift.BoxResampling), "gift_box.png")
	resize(im, newResizeFuncGift(gift.LinearResampling), "gift_linear.png")
	resize(im, newResizeFuncGift(gift.CubicResampling), "gift_cubic.png")
	resize(im, newResizeFuncGift(gift.LanczosResampling), "gift_lanczos.png")
	func() {
		defer func() {
			err := recover()
			if err != nil {
				fmt.Printf("error with rez: %s\n", err)
			}
		}()
		resize(im, newResizeFuncRez(rez.NewBilinearFilter()), "rez_bilinear.png")
		resize(im, newResizeFuncRez(rez.NewBicubicFilter()), "rez_bicubic.png")
		resize(im, newResizeFuncRez(rez.NewLanczosFilter(2)), "rez_lanczos2.png")
		resize(im, newResizeFuncRez(rez.NewLanczosFilter(3)), "rez_lanczos3.png")
	}()
}
func BenchmarkRezBilinear(b *testing.B) {
	benchmarkRez(b, rez.NewBilinearFilter())
}