opencv/goimage.go
func FromImage(img image.Image) *IplImage {
	b := img.Bounds()
	model := color.RGBAModel
	dst := CreateImage(
		b.Max.X-b.Min.X,
		b.Max.Y-b.Min.Y,
		IPL_DEPTH_8U, 4)

	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			px := img.At(x, y)
			c := model.Convert(px).(color.RGBA)

			value := NewScalar(float64(c.B), float64(c.G), float64(c.R), float64(c.A))
			dst.Set2D(x-b.Min.X, y-b.Min.Y, value)
		}
	}

	return dst
}
func FromImage(img image.Image) *IplImage {
	b := img.Bounds()
	model := color.RGBAModel
	dst := CreateImage(
		b.Max.X-b.Min.X,
		b.Max.Y-b.Min.Y,
		IPL_DEPTH_8U, 4)

	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			px := img.At(x, y)
			c := model.Convert(px).(color.RGBA)

			value := NewScalar(float64(c.B), float64(c.G), float64(c.R), float64(c.A))
			dst.Set2D(x-b.Min.X, y-b.Min.Y, value)
		}
	}

	return dst
}
/* FromImage converts a go image.Image to an opencv.IplImage. */