public override bool ContainsPoint(ImageInstance theImage, Point thePoint)
 {
     return(thePoint.X >= mUpperLeftCorner.X &&
            thePoint.X <= mLowerRightCorner.X &&
            thePoint.Y >= mUpperLeftCorner.Y &&
            thePoint.Y <= mLowerRightCorner.Y);
 }
Exemplo n.º 2
0
        public override System.Drawing.Point GetNextPointOnYAxis(ImageInstance theImage, ref System.Drawing.Point theNextPoint)
        {
            if (!mCompletedFirstROI)
            {
                // first iterate through the FirstROI blindly
                mFirstROI.GetNextPointOnYAxis(theImage, ref theNextPoint);
                if (theNextPoint.X != -1 && theNextPoint.Y != -1)
                {
                    return(theNextPoint);
                }

                // once we hit the end of FirstROI, check if the first point in SecondROI is outside of FirstROI, if so, use it
                mCompletedFirstROI = true;
                theNextPoint       = mSecondROI.GetFirstPointOnXAxis(theImage, ref theNextPoint);
                if (!mFirstROI.ContainsPoint(theImage, theNextPoint))
                {
                    return(theNextPoint);
                }
            }
            // after using up FirstROI and the first point of SecondROI, then iterate through SecondROI and weed out any duplicate point
            do
            {
                mSecondROI.GetNextPointOnYAxis(theImage, ref theNextPoint);
            } while (theNextPoint.X != -1 && theNextPoint.Y != -1 && mFirstROI.ContainsPoint(theImage, theNextPoint));
            return(theNextPoint);
        }
Exemplo n.º 3
0
 public override System.Drawing.Point GetNextPointOnYAxis(ImageInstance theImage, ref System.Drawing.Point theNextPoint)
 {
     do
     {
         mMainROI.GetNextPointOnYAxis(theImage, ref theNextPoint);
     } while (theNextPoint.X != -1 && theNextPoint.Y != -1 && mHoleROI.ContainsPoint(theImage, theNextPoint));
     return(theNextPoint);
 }
Exemplo n.º 4
0
 public override System.Drawing.Point GetNextPointOnYAxis(ImageInstance theImage, ref System.Drawing.Point theNextPoint)
 {
     do
     {
         mMainROI.GetNextPointOnYAxis(theImage, ref theNextPoint);
     } while (theNextPoint.X != -1 && theNextPoint.Y != -1 && mColorException.Matches(theImage.GetColor(theNextPoint.X, theNextPoint.Y)));
     return(theNextPoint);
 }
Exemplo n.º 5
0
        /// <summary>
        /// POSSIBLE OPTIMIZATION: first test if outside bounding square, if no, return false.  If inside, check if inside inner square, if yes, return true, else compute radius
        /// </summary>
        /// <param name="theImage"></param>
        /// <param name="thePoint"></param>
        /// <returns></returns>
        public override bool ContainsPoint(ImageInstance theImage, Point thePoint)
        {
            int  deltaX = thePoint.X - mCircleCenter.X;
            int  deltaY = thePoint.Y - mCircleCenter.Y;
            bool result = Math.Sqrt(deltaX * deltaX + deltaY * deltaY) <= mRadius;

            if (result)
            {
                return(true);
            }
            return(false);
        }
        // NOTE: we're passing in the point as reference for speed (avoid creating new Point objects) and for thread safety
        public override Point GetFirstPointOnXAxis(ImageInstance theImage, ref Point theFirstPoint)
        {
            if (mUpperLeftCorner.Y >= theImage.Height ||
                mUpperLeftCorner.X >= theImage.Width ||
                mLowerRightCorner.Y < 0 ||
                mLowerRightCorner.X < 0)
            {
                theFirstPoint.X = -1;
                theFirstPoint.Y = -1;
                return(theFirstPoint);
            }

            theFirstPoint.X = Math.Max(0, mUpperLeftCorner.X);
            theFirstPoint.Y = Math.Max(0, mUpperLeftCorner.Y);
            return(theFirstPoint);
        }
        protected Point mLowerRightCorner = Point.Empty; // this is for optimization while iterating over the recantangle (so we don't have to repeated compute these values due to padding)

        /*
         * public override Point GetNextPoint(ref Point theNextPoint)
         * {
         *  return GetNextPointOnXAxis(ref theNextPoint);
         * }
         */
        public override Point GetNextPointOnXAxis(ImageInstance theImage, ref Point theNextPoint)
        {
            theNextPoint.X++;
            if (theNextPoint.X <= mLowerRightCorner.X && theNextPoint.X < theImage.Width)
            {
                return(theNextPoint);
            }
            theNextPoint.X = Math.Max(0, mUpperLeftCorner.X);
            theNextPoint.Y++;
            if (theNextPoint.Y <= mLowerRightCorner.Y && theNextPoint.Y < theImage.Height)
            {
                return(theNextPoint);
            }
            theNextPoint.X = -1;
            theNextPoint.Y = -1;
            return(theNextPoint);
        }
Exemplo n.º 8
0
 public void UpdateImage()
 {
     if (mTestExecution == null || mImageDisplayDef == null || mImageDisplayDef.ImageDefinition == null)
     {
         Image = null;
         return;
     }
     mImageInstance = mTestExecution.ImageRegistry.GetObjectIfExists(mImageDisplayDef.ImageDefinition.Name);
     if (mImageInstance == null)
     {
         Image = null;
     }
     else
     {
         Image = mImageInstance.Bitmap;
     }
 }
Exemplo n.º 9
0
        /*
         * public override Point GetNextPoint(ref Point theNextPoint)
         * {
         *  return GetNextPointOnXAxis(ref theNextPoint);
         * }
         */
        public override Point GetNextPointOnXAxis(ImageInstance theImage, ref Point theNextPoint)
        {
            do
            {
                theNextPoint.X++;
                if (mOppositeEdgeOfThisRow > 0)
                {
                    if (theNextPoint.X < 0)
                    {
                        theNextPoint.X = 0;
                    }
                    if (theNextPoint.X <= mOppositeEdgeOfThisRow && theNextPoint.X < theImage.Width)
                    {
                        return(theNextPoint);
                    }
                    theNextPoint.Y++; // move to next row
                    mOppositeEdgeOfThisRow = -1;
                    theNextPoint.X         = mUpperLeftCorner.X;
                    if (theNextPoint.Y > mLowerRightCorner.Y || theNextPoint.Y >= theImage.Height)
                    {
                        theNextPoint.X = -1;
                        theNextPoint.Y = -1;
                        return(theNextPoint);
                    }
                }

                // find left edge of circle on this row
                int deltaX;
                int deltaY = Math.Abs(mCircleCenter.Y - theNextPoint.Y);
                int distance;
                do
                {
                    theNextPoint.X++;
                    deltaX   = Math.Abs(mCircleCenter.X - theNextPoint.X);
                    distance = (int)Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
                } while (theNextPoint.X <= mCircleCenter.X && distance > mRadius);
                if (theNextPoint.X > mCircleCenter.X)
                {
                    throw new ArgumentException("Missed finding left edge of circle ROI! Code 89472");
                }
                mOppositeEdgeOfThisRow = mCircleCenter.X + deltaX;
            } while (theNextPoint.X < 0 || theNextPoint.X >= theImage.Width);

            return(theNextPoint);
        }
Exemplo n.º 10
0
        // NOTE: we're passing in the point as reference for speed (avoid creating new Point objects) and for thread safety
        public override Point GetFirstPointOnXAxis(ImageInstance theImage, ref Point theFirstPoint)
        {
            if (mUpperLeftCorner.Y >= theImage.Height ||
                mUpperLeftCorner.X >= theImage.Width ||
                mLowerRightCorner.Y < 0 ||
                mLowerRightCorner.X < 0)
            {
                theFirstPoint.X = -1;
                theFirstPoint.Y = -1;
                return(theFirstPoint);
            }

            theFirstPoint.X = mUpperLeftCorner.X;              // always starting at the left edge (even if <0) because GetNextPoint() must find left edge of circle even if it doesn't return it
            theFirstPoint.Y = Math.Max(0, mUpperLeftCorner.Y); // don't waste time on rows above the image

            mOppositeEdgeOfThisRow = -1;
            // NOTE: the upper left corner of the bounding square is never within the circle, so find the next pixel on the top row that is within the circle
            return(GetNextPointOnXAxis(theImage, ref theFirstPoint));
        }
Exemplo n.º 11
0
 public override bool ContainsPoint(ImageInstance theImage, System.Drawing.Point thePoint)
 {
     return(mMainROI.ContainsPoint(theImage, thePoint) && !mColorException.Matches(theImage.GetColor(thePoint.X, thePoint.Y)));
 }
Exemplo n.º 12
0
 public override bool ContainsPoint(ImageInstance theImage, System.Drawing.Point thePoint)
 {
     return(mMainROI.ContainsPoint(theImage, thePoint) && !mHoleROI.ContainsPoint(theImage, thePoint));
 }
Exemplo n.º 13
0
 public override System.Drawing.Point GetFirstPointOnYAxis(ImageInstance theImage, ref System.Drawing.Point theFirstPoint)
 {
     mCompletedFirstROI = false;
     mFirstROI.GetFirstPointOnYAxis(theImage, ref theFirstPoint);
     return(theFirstPoint);
 }
Exemplo n.º 14
0
 public abstract Point GetFirstPointOnYAxis(ImageInstance theImage, ref Point theFirstPoint);
Exemplo n.º 15
0
 public override bool ContainsPoint(ImageInstance theImage, System.Drawing.Point thePoint)
 {
     return(mFirstROI.ContainsPoint(theImage, thePoint) || mSecondROI.ContainsPoint(theImage, thePoint));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Note: some users of this assume that we move along the y-axis in positive direction 1 pixel at a time.
 /// </summary>
 /// <param name="theImage"></param>
 /// <param name="theNextPoint"></param>
 /// <returns></returns>
 public abstract Point GetNextPointOnYAxis(ImageInstance theImage, ref Point theNextPoint);
Exemplo n.º 17
0
 public override Point GetFirstPointOnYAxis(ImageInstance theImage, ref Point theFirstPoint)
 {
     return(GetFirstPointOnXAxis(theImage, ref theFirstPoint));
 }
Exemplo n.º 18
0
 public abstract bool ContainsPoint(ImageInstance theImage, Point thePoint);
Exemplo n.º 19
0
        public override Point GetNextPointOnYAxis(ImageInstance theImage, ref Point theNextPoint)
        {
            do
            {
                theNextPoint.Y++;
                if (mOppositeEdgeOfThisRow > 0)
                {
                    if (theNextPoint.Y < 0)
                    {
                        theNextPoint.Y = 0;
                    }
                    if (theNextPoint.Y <= mOppositeEdgeOfThisRow && theNextPoint.Y < theImage.Height)
                    {
                        return(theNextPoint);
                    }
                    theNextPoint.X++; // move to next column
                    mOppositeEdgeOfThisRow = -1;
                    theNextPoint.Y         = mUpperLeftCorner.Y;
                    if (theNextPoint.X > mLowerRightCorner.X || theNextPoint.Y >= theImage.Height)
                    {
                        theNextPoint.X = -1;
                        theNextPoint.Y = -1;
                        return(theNextPoint);
                    }
                }

                // find left edge of circle on this row
                int deltaX = Math.Abs(mCircleCenter.X - theNextPoint.X);
                int deltaY;
                int distance;
                do
                {
                    theNextPoint.Y++;
                    deltaY   = Math.Abs(mCircleCenter.Y - theNextPoint.Y);
                    distance = (int)Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
                } while (theNextPoint.Y <= mCircleCenter.Y && distance > mRadius);
                if (theNextPoint.Y > mCircleCenter.Y)
                {
                    throw new ArgumentException("Missed finding top edge of circle ROI! Code 89473");
                }
                mOppositeEdgeOfThisRow = mCircleCenter.Y + deltaY;
            } while (theNextPoint.Y < 0 || theNextPoint.Y >= theImage.Height);

            return(theNextPoint);

            /*
             * theNextPoint.Y++;
             * if (mOppositeEdgeOfThisRow > 0)
             * {
             *  if (theNextPoint.Y <= mOppositeEdgeOfThisRow) return theNextPoint;
             *  theNextPoint.X++; // move to next column
             *  mOppositeEdgeOfThisRow = -1;
             *  theNextPoint.Y = mUpperLeftCorner.Y;
             *  if (theNextPoint.X > mLowerRightCorner.X)
             *  {
             *      theNextPoint.X = -1;
             *      theNextPoint.Y = -1;
             *      return theNextPoint;
             *  }
             * }
             *
             * // find left edge of circle on this row
             * int deltaX = Math.Abs(mCircleCenter.X - theNextPoint.X);
             * int deltaY;
             * int distance;
             * do
             * {
             *  theNextPoint.Y++;
             *  deltaY = Math.Abs(mCircleCenter.Y - theNextPoint.Y);
             *  distance = (int)Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
             * } while (theNextPoint.Y <= mCircleCenter.Y && distance > mRadius);
             * if (theNextPoint.Y > mCircleCenter.Y)
             * {
             *  throw new ArgumentException("Missed finding top edge of circle ROI! Code 89473");
             * }
             * mOppositeEdgeOfThisRow = mCircleCenter.Y + deltaY;
             *
             * return theNextPoint;
             */
        }