Ejemplo n.º 1
0
        private void SetTemplateDeskew()
        {
            switch (deskewType)
            {
            case Deskew.DeskewType.Auto:
                TemplateImage  = new Image <Gray, Byte>(Deskew.DeskewImage(templateImageCopy.Bitmap, 100, out selectedDeskewAngle)).Mat;
                imageBox.Image = TemplateImage.Bitmap;

                if (selectedDeskewAngle == 0)
                {
                    break;
                }

                doubleStateValueTextBox.DoubleValue = selectedDeskewAngle;
                break;

            case Deskew.DeskewType.Custom:
                selectedDeskewAngle = doubleStateValueTextBox.DoubleValue;

                if (selectedDeskewAngle == 0)
                {
                    break;
                }

                TemplateImage  = new Image <Gray, Byte>(Deskew.DeskewImage(templateImageCopy.Bitmap, selectedDeskewAngle)).Mat;
                imageBox.Image = TemplateImage.Bitmap;
                break;
            }
        }
        /// <summary>
        /// Returns true if ImageCleanupDocumentParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of ImageCleanupDocumentParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImageCleanupDocumentParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     FileId == input.FileId ||
                     (FileId != null &&
                      FileId.Equals(input.FileId))
                     ) &&
                 (
                     PageRange == input.PageRange ||
                     (PageRange != null &&
                      PageRange.Equals(input.PageRange))
                 ) &&
                 (
                     RemoveBlackBorders == input.RemoveBlackBorders ||
                     RemoveBlackBorders.Equals(input.RemoveBlackBorders)
                 ) &&
                 (
                     Deskew == input.Deskew ||
                     Deskew.Equals(input.Deskew)
                 ) &&
                 (
                     RemoveLeftMarginPunchHoles == input.RemoveLeftMarginPunchHoles ||
                     RemoveLeftMarginPunchHoles.Equals(input.RemoveLeftMarginPunchHoles)
                 ) &&
                 (
                     RemoveTopMarginPunchHoles == input.RemoveTopMarginPunchHoles ||
                     RemoveTopMarginPunchHoles.Equals(input.RemoveTopMarginPunchHoles)
                 ) &&
                 (
                     RemoveRightMarginPunchHoles == input.RemoveRightMarginPunchHoles ||
                     RemoveRightMarginPunchHoles.Equals(input.RemoveRightMarginPunchHoles)
                 ) &&
                 (
                     RemoveBottomMarginPunchHoles == input.RemoveBottomMarginPunchHoles ||
                     RemoveBottomMarginPunchHoles.Equals(input.RemoveBottomMarginPunchHoles)
                 ) &&
                 (
                     DespeckleStrength == input.DespeckleStrength ||
                     DespeckleStrength.Equals(input.DespeckleStrength)
                 ));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Runs the test additional features.
        /// </summary>
        private static void RunTestAdditionalFeatures()
        {
            //// =====================================================
            //// =====================================================
            ////                        Deskew
            //// =====================================================
            //// =====================================================

            Console.WriteLine("Running additional features tests:");

            Deskew.Run();

            DocumentConvertionProgress.Run();

            ManualImageMasking.Run();
            AutoImageMasking.Run();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 图像纠偏
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static Bitmap Deskew(Bitmap source)
        {
            var    max = Math.Max(source.Width, source.Height);
            Bitmap tempBmp;

            if (max > 1000)
            {
                tempBmp = MakeImage(source, source.Width / 4, source.Height / 4, source.Width / 2, source.Height / 2);
                tempBmp = BinarizeImage(tempBmp);
            }
            else
            {
                tempBmp = BinarizeImage(source);
            }
            var des   = new Deskew(tempBmp);
            var angle = des.GetSkewAngle();

            return(RotateImage(tempBmp, (float)-angle));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (FileId != null)
         {
             hashCode = hashCode * 59 + FileId.GetHashCode();
         }
         if (PageRange != null)
         {
             hashCode = hashCode * 59 + PageRange.GetHashCode();
         }
         hashCode = hashCode * 59 + RemoveBlackBorders.GetHashCode();
         hashCode = hashCode * 59 + Deskew.GetHashCode();
         hashCode = hashCode * 59 + RemoveLeftMarginPunchHoles.GetHashCode();
         hashCode = hashCode * 59 + RemoveTopMarginPunchHoles.GetHashCode();
         hashCode = hashCode * 59 + RemoveRightMarginPunchHoles.GetHashCode();
         hashCode = hashCode * 59 + RemoveBottomMarginPunchHoles.GetHashCode();
         hashCode = hashCode * 59 + DespeckleStrength.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 6
0
 public void deskew(ref WriteableBitmap bmp)
 {
     Deskew sk = new Deskew(bmp);
     double skewAngle = -1 * sk.GetSkewAngle();
     bmp = WriteableBitmapExtensions.RotateFree(bmp, skewAngle);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 图像纠偏
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 public static Bitmap Deskew(Bitmap source)
 {
     var max = Math.Max(source.Width, source.Height);
     Bitmap tempBmp;
     if (max > 1000)
     {
         tempBmp = MakeImage(source, source.Width / 4, source.Height / 4, source.Width / 2, source.Height / 2);
         tempBmp = BinarizeImage(tempBmp);
     }
     else
     {
         tempBmp = BinarizeImage(source);
     }
     var des = new Deskew(tempBmp);
     var angle = des.GetSkewAngle();
     return RotateImage(tempBmp, (float)-angle);
 }