Beispiel #1
0
        /// <summary>
        /// computes the joint dense histogram for a set of images.
        /// </summary>
        /// <param name="images"></param>
        /// <param name="channels"></param>
        /// <param name="hist"></param>
        /// <param name="backProject"></param>
        /// <param name="ranges"></param>
        /// <param name="uniform"></param>
        public static void CalcBackProject(Mat[] images,
            int[] channels, InputArray hist, OutputArray backProject, 
            Rangef[] ranges, bool uniform = true)
        {
            if (images == null)
                throw new ArgumentNullException(nameof(images));
            if (channels == null)
                throw new ArgumentNullException(nameof(channels));
            if (hist == null)
                throw new ArgumentNullException(nameof(hist));
            if (backProject == null)
                throw new ArgumentNullException(nameof(backProject));
            if (ranges == null)
                throw new ArgumentNullException(nameof(ranges));
            hist.ThrowIfDisposed();
            backProject.ThrowIfNotReady();

            IntPtr[] imagesPtr = EnumerableEx.SelectPtrs(images);
            float[][] rangesFloat = EnumerableEx.SelectToArray(
                ranges, r => new [] {r.Start, r.End});
            using (var rangesPtr = new ArrayAddress2<float>(rangesFloat))
            {
                NativeMethods.imgproc_calcBackProject(imagesPtr, images.Length, channels, hist.CvPtr,
                    backProject.CvPtr, rangesPtr, uniform ? 1 : 0);
            }
            GC.KeepAlive(images);
            GC.KeepAlive(hist);
            backProject.Fix();
        }
Beispiel #2
0
 /// <summary>
 /// computes the joint dense histogram for a set of images.
 /// </summary>
 /// <param name="images"></param>
 /// <param name="channels"></param>
 /// <param name="mask"></param>
 /// <param name="hist"></param>
 /// <param name="dims"></param>
 /// <param name="histSize"></param>
 /// <param name="ranges"></param>
 /// <param name="uniform"></param>
 /// <param name="accumulate"></param>
 public static void CalcHist(Mat[] images, 
     int[] channels, InputArray mask,
     OutputArray hist, int dims, int[] histSize,
     Rangef[] ranges, bool uniform = true, bool accumulate = false)
 {
     if (ranges == null)
         throw new ArgumentNullException(nameof(ranges));
     float[][] rangesFloat = EnumerableEx.SelectToArray(
         ranges, r => new [] {r.Start, r.End});
     CalcHist(images, channels, mask, hist, dims, 
         histSize, rangesFloat, uniform, accumulate);
 }