2021 APMCM post-competition summary - edge detection

APMCM is known as the Little American Competition. Like the American Competition, papers are submitted in English, and the competition time is after the National Competition and before the American Competition, so it is very suitable as a warm-up match for MCM.
It is the first time to participate in this kind of formal competition, and it is written in English. As a warm-up for the competition, it is necessary to spend four days rehearsing in advance. Under the conditions of daily classes and (almost) regular breaks, in the end, our team was able to win the second prize, which is quite satisfactory.

Pre-match preparation

APMCM is four days long, and there are some midterm exams during the period, so it is very important to grasp the time. We searched for a discussion place half a month in advance, and after excluding bookstores, coffee shops and teaching buildings, we chose the study and seminar space in the main library. From 8:00 am to 10:00 pm, we have dinner at Denggao Road.
We mainly read the topics of previous years, learned a little modeling skills, and then bought relevant materials of Meisai and Matlab. The choice of the discussion venue in the library also has such considerations: when encountering interdisciplinary issues, relevant materials can be browsed in time.

game

In the Asia-Pacific competition in 2021, question A is about edge detection and involves graphics and image processing; question b has a large degree of cross-discipline and is not considered; question c is traditional data processing. It just so happened that we had Gonzalez's "Graphics and Image Processing" at hand, and I happened to read a section about edge detection, so we chose to take a look at question A.
The competition lasts four days.
After the library was closed on the first day, we borrowed the conference room of the Information Institute to work until one o'clock in the morning.
Later, I found that the efficiency of staying overnight was not high, so I unified the work from eight in the morning to ten in the evening, and then went back to the dormitory to tidy up the work.
Although the general direction has been determined on the first day, the implementation of the code and the reproduction of some functions still took some detours.
About the materials: I chose HowNet and Tongfang. I encountered problems with CSDN and mathwork. Generally speaking, this question is more difficult to get started, but it is more in the direction of our group.
In other words, Reina Tuzhen is used everywhere, and I have seen countless versions.

Now let’s briefly describe our thinking and analysis on the edge detection problem at that time:

2021APMCM Question A

problem background

Problem A
Image Edge Analysis and Application

With the development of science and technology, the demand for measurement accuracy of various workpieces and parts is getting higher and higher, and the requirements for measurement instruments are also getting more and more demanding. Various image measuring equipment such as digital image size measuring instrument are now gradually replacing the traditional manual caliper measurement application. Generally, after the camera is calibrated, based on the the dot matrix or checkerboard feature information of the calibrated image, the image can be corrected for distortion and the mapping relationship between the image coordinate space and the world coordinate space can be calculated.

The edge of the target object is very useful for image recognition and computer analysis. Image edge is the reflection of discontinuity of the local characteristics of an image. The edge can outline the target object and make it clear to the observer at a glance. The edge contains rich intrinsic information (such as orientation, step property and shape, etc.), which is an important attribute for extracting image features in image recognition. Image edge contour extraction is a very important processing in boundary segmentation and also a classical problem in image processing. The purpose of both contour extraction and contour tracking is to obtain the external contour features of an image. Applying certain methods where necessary to express the features of the contours to prepare for image shape analysis has a significant impact on performing high-level processing such as feature description, recognition and understanding.

The contour can be described as a set of ordered points, and the common expression of the contour is a polygon. Contours can be either closed or open. The closed contours on an image are all connected start to end, and the open contours generally intersect with the image boundary. In Figure 1, there are five closed contour curves. Although edge detection algorithms such as sobel and canny can detect the image edge pixels boundary based on the difference of image gray value, it does not take the contour as a whole. On an image, a contour corresponds to a series of pixel points. The contour describes a continuous sequence of points, and the edge pixel points can be assembled into a contour curve to describe the edge information of the image.

A sub-pixel is a virtual pixel defined between two physical pixels of an image acquisition sensor. To improve resolution or image quality, sub-pixel calculation is very useful. Image sub-pixel edge extraction is a more accurate method than traditional pixel edge extraction. Sub-pixel means that the coordinate value of each pixel point on the image is no longer integer positioning, but floating-point number positioning. If the accuracy is increased to 0.1 pixel using subpixel technique, it is equivalent to 10 times higher resolution of image system analysis.

For the following three schematic diagrams, in Figure 1, the object edge contour lines of the image have been extracted and the image edge contour has been segmented into basic graphics such as straight line segments, circular arc segments, and circles. In Figure 2, The edge contour of a rounded rectangle is divided into several geometric shapes. In Figure 3, an elliptical sub-pixel contour curve is shown drawn on the background of a grayscale pixel image grid.

Figure 1. Image Edge Detection
Figure 1. Image Edge Detection
insert image description here
Figure 2. Segmentation Image Edge Contour
insert image description here
Figure 3. Sub-pixel Edge Contour of Image

topic

Question 1

: Build a mathematical model, analyze the method and process of extracting sub-pixel edge with 1/10 pixel accuracy and above, extract sub-pixel edge contour boundaries of the main edge parts of the objects on the three images (Pic1_1, Pic1_2, Pic1_3) in Annex 1, and convert the edge sub-pixel point data into ordered edge contour curve data, with the need to considering how to eliminate the interference effects of edge burrs and shadow parts of the edges. Note that the Pic1_3 image was taken under relatively complex lighting conditions, with more interference information.

a)Please draw the extracted edge contours in different colors on the image, output it as a color edge contour image and save it as png image format for submission. The file names are pic1_1.png, pic1_2.png, pic1_3.png.

b)Output the edge contour data in the format of EdgeContoursOutput.xls file in Annex 1, and output the data of the Pic1_1 and Pic1_2 images to the corresponding Sheet1 and Sheet2 of the worksheet respectively. The output data contains the total edge contours count, the total edge contours length in the image coordinate space, point count and length of each contour curve, and the X and Y coordinate data of each contour point.

c)The total contour curves count on each image and the point count and length data on each curve should be given in the paper. See Table 1, Table 2 and Table 3.

Question 2

:While the measured image is taken, there is a dot matrix calibration plate placed at the same horizontal height of the target object. The diameter of the dots on the calibration plate is 1 mm, and the center distance between two dots is 2 mm. Annex 2 contains three calibration plate images taken at different angles and one product image (Pic2_4.bmp). Please build a mathematical model, use the calibration plate image information to conduct image rectification analysis of the product image and consider how to calculate, as accurately as possible, the actual physical sizes of the edge segmentation fitting curve segments on the product image. Please calculate the length (mm) of each edge contour, and finally calculate the total edge contours length (mm). According to the contour data labeling shown in Figure 4, output the data results of the table format files such as EdgeContoursLengthOutput.xls in Annex 2.

insert image description here
Figure 4. Image Contour Data Labeling

Question 3

: Two sub-pixel contour edge data (EdgeContour1.xls and EdgeContour2.xls) are provided in Annex 3, and the shape are shown in Figure 5. Please build a mathematical model, analyze the automated segmentation and fitting of edge contour curve data into straight line segments, circular arc segments (including circles), or elliptical arc segments (including ellipses), and discuss the model method or strategy for automated segmentation and fitting of edge contours. The blue curve starts from the blue digit 1 label and outputs the model calculation result data along the arrow direction. The green curve starts from the green digit 1 label and outputs the model calculation result data along the arrow direction. Please fill in the parameters of the segmented curve segments into the table in the table format. Submit Table 7 and Table 8 (regarding contour 1 and contour 2 segmentation data) in the paper. Note that the type of the lines in this table is populated according to the actual type.

insert image description here
Figure 5. Edge Contour Curve Data

Remark:

  1. SweepAngle indicates the sweep angle from the start point to the end point, angular system;
  2. Size indicates the radius value of specified ellipse or elliptic arc in the X and Y directions;
  3. RotationAngle indicates the rotation angle value of specified ellipse or elliptic arc, angular system;
  4. For the direction of rotation angle, the rotation direction from positive direction of x-axis to positive direction of y-axis is positive direction, and vice versa is negative direction.
  5. All image coordinate points are expressed under the image coordinate system, that is, the upper left corner is the (0,0) origin, the positive direction of the X-axis is to the right, and the positive direction of the Y-axis is downward.

analyze

First of all, it is very important to translate into Chinese in time for this kind of questions that contain technical terms. Within half an hour of getting the questions, I got the word and pdf translations of questions A, B, and C. Our group was able to discuss and determine the selected questions in time. I would like to thank my friend and his WPS members here.
Of course, there are always times when machine translation is not perfect, and when you encounter problems with individual words or sentences, you still have to check them one by one.
After many references, we got a preliminary impression of the topic:
edge detection is performed on the given picture, and the edges are marked, and different sub-pixel structures are counted according to the requirements of the topic.
At this time, it is time for Gonzalez to come in handy. One hundred and sixty oceans have no white flowers.
Heaven-level fighting skills: "Chapter Ten: Image Segmentation"!
From point, line and edge detection to multi-threshold processing, this book provides us with a key angle to cut into the problem. Of course, it will be much clearer to find information on the Internet along this line of thought.

basic knowledge

edge model

Different images have different gray levels, and generally there will be obvious edges at the boundary. Using this feature, the image can be segmented. Edge detection is a common method to segment images based on grayscale mutations.

Edge models can be classified according to their grayscale profile. It can be divided into step model , slope model and roof edge model etc.
Although noise and edges will cause the edge to deviate from the ideal shape, the edge of the image can still be identified by using the characteristics of the edge model. In this process, we use "gradient" as a tool to find the edge strength and direction at any position (x, y) in the image f, denote it by ∇f, and define it as a vector.

∇f(x,y)≡grad[f (x,y)]≡ [ g x ( x , y ) g y ( x , y ) ] \begin{bmatrix} g_x (x,y)\\ g_y (x,y) \end{bmatrix} [gx(x,y)gy(x,y)]= [ ∂ f ( x , y ) ∂ x ∂ f ( x , y ) ∂ y ] \begin{bmatrix} \cfrac{\partial f (x,y)}{\partial x}\\ \cfrac{\partial f (x,y)}{\partial y} \end{bmatrix} xf(x,y)yf(x,y)

The magnitude M(x,y) of a gradient vector at a point (x,y) is given by its Euclidean vector norm.
Angles are measured counterclockwise relative to the x-axis. The direction of the edge at a point (x,y) is orthogonal to the direction of the gradient vector at that point.

algorithm

edge detector

Sobel operator is a discrete differential operator. It combines Gaussian smoothing and differential derivation to calculate the approximate gradient of the image grayscale function. The Sobel operator first performs convolution on the image pixels, and then performs a threshold operation on the gray value of the generated new pixel to determine the edge information.
If Gx is the convolution of the original image in the x direction, Gy is the convolution of the original image in the y direction.
The Sobel operator has a smooth suppression effect on noise, but the obtained edge is thicker, and false edges may appear.

The Canny edge detector is based on three basic goals: low error rate, edge points should be well located, and single edge point effect.
Using numerical optimization for 1D step edges polluted by additive white Gaussian noise based on three basic objectives, it can be concluded that a good approximation to the optimal step edge detector is the first derivative of Gaussian.

The steps of the canny edge detection algorithm are summarized as follows:
1. Use a Gaussian filter to smooth the input image.
2. Calculate the gradient magnitude image and angle image.
3. Apply a non-maximum limit to the gradient magnitude image.
Detect and connect edges using dual thresholding and connectivity analysis

Pretzel

Salt and pepper noise is the random appearance of black and white pixels on an image. After specifying the signal-to-noise ratio SNR (its value range is between [0, 1]), calculate the total number of pixels SP, get the number of pixels to be noised, and randomly obtain the position of each pixel to be noised P(i , j) and specify a pixel value of 255 or 0.

noise reduction

1. Neighborhood averaging method is a spatial domain smoothing noise technique, which is a linear filtering technique.

2. The basic principle of median filtering is to replace the value of a point in a digital image or digital sequence with the median value of each point in a neighborhood of the point. The median filter is a nonlinear processing method to suppress noise. This method is simple to calculate, easy to implement, and can better protect the boundary, but sometimes it will lose the thin lines and small areas in the image. The size and shape of the window sometimes have a great impact on the filtering effect. At the same time, it should be pointed out that It has no obvious effect on filtering out the noise of Gaussian distribution.

3. Winner filtering is a restoration method that minimizes the mean square error between the original image f(x, y) and its restored image g(x, y). Compared with the neighborhood average method, the Wiener filter has a better filtering effect on Gaussian white noise image filtering. It has better selectivity than linear filters, and can better preserve the edge and high-frequency details of the image. Although Wiener filtering can obtain satisfactory results in most cases, especially for images containing white noise, the effect is often unsatisfactory when the signal-to-noise ratio is relatively low. In addition, the minimum mean square error criterion does not necessarily match human vision.

Hough transform

The Standard Hough Transform (SHT) uses a parametric representation of the line:
insert image description here
the variable rho is the distance from the origin to the line along a vector perpendicular to the line. θ is the angle in degrees measured clockwise from the origin to the vertical projection of the line with respect to the positive x-axis. The range of θ is –90° ≤ θ < 90°. The angle of the line itself is θ + 90°, also measured clockwise with respect to the positive x-axis.

Matlab image processing toolbox provides 3 functions related to Hough transform. The function hough() implements the concepts discussed earlier; the function houghpeaks() finds the peaks of the Hough transform (accumulating high counts of units); the function houghlines() extracts line segments in the original image based on the results from the other two functions.

part image processing

Use different parameters to add noise to the picture, and then perform Gaussian and salt and pepper filtering.
insert image description here
insert image description here
insert image description here
insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Summarize

  1. It is very important to find a teammate with well-written code. There are still many pitfalls in applying the model to practical problems. The algorithm needs to be improved. Even the ready-made code must be understood, let alone write code according to the algorithm.
  2. mathtype is really fragrant. Why is there not too many formulas in this blog post, because it is too troublesome to type formulas with latex!
  3. There is an introduction to some algorithms and functions of matlab on mathwork. If you don’t understand it when using it, you can go to it first.
  4. HowNet is very useful, but the key words must be identified accurately. Under the category of computer vision, even edge detection can be used in many fields. It is necessary to identify the direction that is suitable for the competition topic.
  5. It is much more convenient to have a professional book at hand.

Reference: Gonzalez "Graphics and Image Processing"

insert image description here

Guess you like

Origin blog.csdn.net/Algernon98/article/details/122909233