Beispiel #1
0
        /// <summary>
        /// Copies values from source to destination image using mask. Destination values where mask == 0 are not erased!.
        /// </summary>
        /// <param name="source">Image.</param>
        /// <param name="destination">Destination image</param>
        /// <param name="mask">Mask. Color locations that need to be copied must be set to !=0 in mask.</param>
        public static void CopyTo <TColor>(this TColor[,] source, TColor[,] destination, Gray <byte>[,] mask)
            where TColor : struct
        {
            if (source.Size() != mask.Size() || source.Size() != destination.Size())
            {
                throw new Exception("Image, mask, destImg size must be the same!");
            }

            ParallelLauncher.Launch((thread) =>
            {
                if (mask[thread.Y, thread.X] != 0)
                {
                    destination[thread.Y, thread.X] = source[thread.Y, thread.X];
                }
            },
                                    source.Width(), source.Height());
        }
        private static Gray <float>[,] convolve(Gray <float>[,] image, IList <float[, ]> kernels, ConvolutionBorder options)
        {
            int biggestKernelWidth, biggestKernelHeight;

            getTheBiggestSize(kernels, out biggestKernelWidth, out biggestKernelHeight);

            int fillX, fillY;
            var paddedIm = prepareImage(image, biggestKernelWidth, biggestKernelHeight, options, out fillX, out fillY);

            var convolvedIm = paddedIm;

            foreach (var kernel in kernels)
            {
                var preparedKernel = prepareKernel(kernel, convolvedIm.Size());
                convolvedIm = convolvedIm.MulComplex(preparedKernel, inPlace: false);
            }

            return(getConvolutionResult(convolvedIm, fillX, fillY, image.Size()));
        }
        /// <summary>
        /// Creates linear response maps.
        /// </summary>
        /// <param name="orientationDegImg">Orientation image (in degrees).</param>
        /// <param name="neigborhood">Spread neighborhood size.</param>
        public LinearizedMaps(Gray<int>[,] orientationDegImg, int neigborhood)
        {
            this.NeigborhoodSize = neigborhood;
            this.ImageSize = orientationDegImg.Size();
            
            this.LinearMapSize = new Size(orientationDegImg.Width() / neigborhood, orientationDegImg.Height() / neigborhood);
            this.ImageValidSize = new Size(this.LinearMapSize.Width * neigborhood, this.LinearMapSize.Height * neigborhood);

            this.LinearMaps = calculate(orientationDegImg);
        }