示例#1
0
        /// <summary>
        /// Displays the specified image in a window and waits the user to create a mask by drawing.
        /// <para>Press and hold shift + mouse (track-pad) to translate and zoom an image.</para>
        /// </summary>
        /// <param name="image">Image to display.</param>
        /// <param name="windowTitle">Window title (ID).</param>
        /// <param name="scaleForm">True to adjust form to the image size, false otherwise.</param>
        /// <returns>Drawn mask.</returns>
        public static Gray <byte>[,] GetMask(this Bgr <byte>[,] image, string windowTitle = "Draw image mask (close when finished)", bool scaleForm = false)
        {
            var mask = FormCollection.CreateAndShowDialog(() =>
            {
                var f       = new DrawingPenForm(windowTitle);
                f.ScaleForm = scaleForm;
                f.SetImage(image);

                return(f);
            },
                                                          f => f.Mask);

            return(mask);
        }
示例#2
0
        /// <summary>
        /// Displays the specified image in a window and waits the user to create a mask by drawing.
        /// <para>Press and hold shift + mouse (track-pad) to translate and zoom an image.</para>
        /// </summary>
        /// <param name="image">Image to display.</param>
        /// <param name="windowTitle">Window title (ID).</param>
        /// <param name="scaleForm">True to adjust form to the image size, false otherwise.</param>
        /// <returns>Drawn mask.</returns>
        public static Gray<byte>[,] GetMask(this Bgr<byte>[,] image, string windowTitle = "Draw image mask (close when finished)", bool scaleForm = false)
        {
            var mask = FormCollection.CreateAndShowDialog(() =>
                        {
                            var f = new DrawingPenForm(windowTitle);
                            f.ScaleForm = scaleForm;
                            f.SetImage(image);

                            return f;
                        },
                        f => f.Mask);

            return mask;        
        }