получить среднее изображение из нескольких Emgu.Cv.Mat - PullRequest
0 голосов
/ 20 ноября 2018

Я должен получить среднее изображение из набора изображений, используя Emgu.CV.Входные изображения Image<Gray,byte> (1 channel, 1 byte pixels).Я написал этот метод, но он не работает:

public static Mat GetAverage(List<Mat> matrices)
{
    //where to store the result
    Mat result = new Mat(matrices.First().Size, 
                        DepthType.Cv16U, 
                        matrices.First().NumberOfChannels); 

    //where to store the partial sums
    using (Mat elementwiseSum = new Mat(matrices.First().Size, 
                                    DepthType.Cv64F, 
                                    matrices.First().NumberOfChannels)) 
    {
        // loop over the input
        foreach (Mat matrix in matrices)
        {
            // sum each image to the partial sum
            CvInvoke.Accumulate(matrix, elementwiseSum); 
        }
        // convert to UInt16 and scale by the number of input images
        elementwiseSum.ConvertTo(result, 
                                DepthType.Cv16U, 
                                1.0 / matrices.Count); 
    }
    return result;
}

Оба elementwiseSum и result шов должны быть черными изображениями ... Что я делаю не так?

...