예제 #1
0
파일: conv.go 프로젝트: jvlmdr/go-cv
func (phi *ConvEach) Apply(x *rimg64.Multi) (*rimg64.Multi, error) {
	channels := x.Channels * len(phi.Filters.Filters)
	field := image.Pt(phi.Filters.Width, phi.Filters.Height)
	size := slide.ValidSize(x.Size(), field)
	y := rimg64.NewMulti(size.X, size.Y, channels)
	var n int
	for i := 0; i < x.Channels; i++ {
		// Convolve each channel of the input with the bank.
		yi, err := slide.CorrBankBLAS(x.Channel(i), phi.Filters)
		if err != nil {
			return nil, err
		}
		for j := 0; j < yi.Channels; j++ {
			// Copy the channels into the output.
			y.SetChannel(n, yi.Channel(j))
			n++
		}
	}
	return y, nil
}