Example #1
0
func (img *Image) ResizeTo(dest *Image, size Size, interp InterpolationType) {
	if !dest.Initialized || dest.Size() != size || dest.imtype != img.imtype {
		dest.Release()
		*dest = *CreateImage(size, img.imtype)
	}

	C.cvResize(img.ptr, dest.ptr, C.int(interp))
}
Example #2
0
func Resize(src *IplImage, width, height, interpolation int) *IplImage {
	if width == 0 && height == 0 {
		panic("Width and Height cannot be 0 at the same time")
	}
	if width == 0 {
		ratio := float64(height) / float64(src.Height())
		width = int(float64(src.Width()) * ratio)
	} else if height == 0 {
		ratio := float64(width) / float64(src.Width())
		height = int(float64(src.Height()) * ratio)
	}

	dst := CreateImage(width, height, src.Depth(), src.Channels())
	C.cvResize(unsafe.Pointer(src), unsafe.Pointer(dst), C.int(interpolation))
	return dst
}