Exemple #1
0
        static Func <IplImage, IplImage, Scalar> ActivationFunction(ReduceOperation operation)
        {
            switch (operation)
            {
            case ReduceOperation.Avg: return(CV.Avg);

            case ReduceOperation.Max: return((image, mask) =>
                {
                    Scalar min, max;
                    MinMaxLoc(image, mask, out min, out max);
                    return max;
                });

            case ReduceOperation.Min: return((image, mask) =>
                {
                    Scalar min, max;
                    MinMaxLoc(image, mask, out min, out max);
                    return min;
                });

            case ReduceOperation.Sum: return((image, mask) => CV.Sum(mask));

            default: throw new InvalidOperationException("The specified reduction operation is invalid.");
            }
        }
Exemple #2
0
 public static Reductor Get(ReduceOperation operation)
 {
     if (operation == ReduceOperation.Custom)
     {
         throw new NotSupportedException(
             "Custom reduce operation must be specified explicitly.");
     }
     return Cache[operation];
 }
Exemple #3
0
 /// <summary>
 /// transforms 2D matrix to 1D row or column vector by taking sum, minimum, maximum or mean value over all the rows
 /// </summary>
 /// <param name="dim">The dimension index along which the matrix is reduced. 
 /// 0 means that the matrix is reduced to a single row and 1 means that the matrix is reduced to a single column</param>
 /// <param name="rtype"></param>
 /// <param name="dtype">When it is negative, the destination vector will have 
 /// the same type as the source matrix, otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), mtx.channels())</param>
 /// <returns></returns>
 public Mat Reduce(ReduceDimension dim, ReduceOperation rtype, int dtype)
 {
     var dst = new Mat();
     Cv2.Reduce(this, dst, dim, rtype, dtype);
     return dst;
 }
Exemple #4
0
 /// <summary>
 /// transforms 2D matrix to 1D row or column vector by taking sum, minimum, maximum or mean value over all the rows
 /// </summary>
 /// <param name="src"></param>
 /// <param name="dst"></param>
 /// <param name="dim"></param>
 /// <param name="rtype"></param>
 /// <param name="dtype"></param>
 public static void Reduce(InputArray src, OutputArray dst, ReduceDimension dim, ReduceOperation rtype, int dtype)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     NativeMethods.core_reduce(src.CvPtr, dst.CvPtr, (int)dim, (int)rtype, dtype);
     dst.Fix();
 }
Exemple #5
0
 internal static extern void cvReduce(Arr src, Arr dst, int dim, ReduceOperation op);