コード例 #1
0
 public static ImageCorners GetActualImageCorners(ImageCorners clickImgCorners, Image image, IList <ClickPositionOnImage> clickInput)
 {
     return(new ImageCorners
     {
         Left = clickImgCorners.Left * image.Width / clickInput[0].AllowedWidth,
         Right = clickImgCorners.Right * image.Width / clickInput[0].AllowedWidth,
         Bottom = clickImgCorners.Bottom * image.Height / clickInput[0].AllowedHeight,
         Top = clickImgCorners.Top * image.Height / clickInput[0].AllowedHeight
     });
 }
コード例 #2
0
        /// <summary>
        /// extra_padding.pdf
        /// </summary>
        /// <param name="image"></param>
        /// <param name="imageCorners"></param>
        /// <param name="invalidColor"></param>
        /// <returns></returns>
        public static double GetExtraPaddingPercent(Bitmap image, ImageCorners imageCorners, Color invalidColor)
        {
            var diffPercentLeft = GetDiffPercentOnLeft(imageCorners, image, invalidColor);

            var diffPercentRight = GetDiffPercentOnRight(imageCorners, image, invalidColor);

            //return the max between the two
            var max = diffPercentLeft > diffPercentRight? diffPercentLeft : diffPercentRight;

            return(max + 5); //take a little extra to be on the safe side
        }
コード例 #3
0
        private static ImageCorners GetImgCornersWithExtraPadding(ImageClickInputDetails clickInputs, Bitmap image, ImageAlterationParams imageAlterationParams)
        {
            //image corners with respect to the dimensions of click area
            var clickImgCorners = ImageCorners.GetImageCornersFromClickInputs(clickInputs, imageAlterationParams.MinImageHeightRatio, imageAlterationParams.BottomPaddingPercent);

            //image corners in actual image dimension
            var actualImgCorners = ImageCorners.GetActualImageCorners(clickImgCorners, image, clickInputs.ClickPositionListForImages);

            //image corners with extra padding on on each side of disc
            return(GetModifiedImgCornersForExtraWidth(actualImgCorners, imageAlterationParams.PercentExtraWidth));
        }
コード例 #4
0
 private static bool CheckForModelPixelInYDirection(ImageCorners imageCorners, double x, Bitmap image, Color invalidColor)
 {
     for (var y = imageCorners.Top; y <= imageCorners.Bottom; y++)
     {
         var pixel = image.GetPixel((int)x, (int)y);
         if (pixel.R != invalidColor.R || pixel.G != invalidColor.G || pixel.B != invalidColor.B)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
        private static ImageCorners GetModifiedImgCornersForExtraWidth(ImageCorners origCorners, double percentExtraWidth)
        {
            var extraOnEachSide = percentExtraWidth * origCorners.Width / 100.0;

            //return modified left and right based on extraOnEachSide
            return(new ImageCorners
            {
                Left = origCorners.Left - extraOnEachSide,
                Right = origCorners.Right + extraOnEachSide,
                Top = origCorners.Top,
                Bottom = origCorners.Bottom
            });
        }
コード例 #6
0
        private static double GetDiffPercentOnRight(ImageCorners imageCorners, Bitmap image, Color invalidColor)
        {
            double x;
            var    noOfModelPixelsAlongX = 0;

            for (x = imageCorners.Right + 1; x < image.Width; x++)
            {
                if (!CheckForModelPixelInYDirection(imageCorners, x, image, invalidColor))
                {
                    break;
                }
                noOfModelPixelsAlongX++;
            }
            return(noOfModelPixelsAlongX * 100.0 / imageCorners.Width);
        }