Input: |
I // I is the collected image by the camera |
TG //TG is the template of the Gaussian |
TO //TO is the template of the open operator |
TSx //Sobel’s template along the X direction |
TSy // Sobel’s template along the Y direction |
Sigma // Sigma is the of TG |
Output: |
/*Gaussian Filter*/ |
Step 1: |
NI [IW, IH] ← 0 |
/*IW (width of the image I), IH (height of the image I), and set a temporary image to black*/ |
[IW, IH] ← size (I) // Get I dimensions |
[TGW, TGH] ← size (TG) |
/* TGW (width of the template TG), TGH (height of the template TG), and get TG dimensions*/ |
CG ← floor (TG/2)+1 // CG is a half of TG |
sum ← 0 // we will calculate the normalization for i ← 1 to TGW do |
for j ← 1 to TGH do |
(TGi, TGj) ← exp (−((j−center) × (j−center)+(i−center) × (i−center)))/(2 × sigma) |
sum ← TG |
end |
end |
//Normalization processing |
Void Convolve (I, TG) //Convolution function |
|
//Address all columns except border |
|
//Address all rows except border |
C |
|
|
|
end |
end |
CR |
end |
end |
ormalise(NI)// GI is Gaussian fitter result |
end Convolve |
/*The result of the convolution is to use an N×N convolution template to traverse the entire image, multiply and then add the corresponding coordinates, and then permutate the values of the corresponding coordinates of the original image. This article contains many of convolution operations, so the following article directly calls the convolution function*/ |
/* Image binarization*/ |
Step 2: |
|
then |
|
//Segment the foreground of the GI |
|
|
//Segment the background of the GI |
end if |
end |
/* Open operation*/ |
Step 3: |
|
/*Get GI dimensions, and the GIW (width of the image GI) and GIH (height of the image GI) are equal IW and IH*/ |
|
/* TOW (width of the template TO),TOH (height of the template TO), and get TO dimensions |
// CO is a half of TO |
//we will judge the total |
The total number of nonzero in TO |
/*The GI is first Erosion processing */ |
|
|
|
|
|
then |
|
end |
end |
end |
end |
end |
/*The GI is then do Dilation operation */ |
|
|
|
|
|
then |
|
end |
end |
end |
end |
end |
/* Obtain geometric contours */ |
Step 4: |
|
/*The edge image (image after Sobel operation along X direction template) in the X-direction is generated by convoluting with the template along the X-direction*/ |
|
/*The edge image (image after Sobel operation along Y direction template) in the Y-direction is generated by convoluting with the template along the Y-direction*/ |
|
// The edge image (image I after Sobel operation along X and Y directions template) of GI if formed by and |
Image binarization SI/* The IC (contours of the image I) geometric contours contained in the image are obtained by using image binarization on SI*/ |
/* Obtain geometric contours centroid*/ |
Step 5: |
|
/* Assign all the information of the i contour in IC, including coordinates and pixel values, to */ |
for each Contoursi in IC do |
in do |
|
|
|
|
// The i contours x centroid coordinate |
|
// The i contours y centroid coordinate |
end |
end |
/* Measurement*/ |
Step 6: |
|
/* The (centroid coordinate of the little contours) of the black circle hole is filtered according to the size of the contour*/ |
|
/* The (centroid coordinate of the big contours) of the resembling the double-headed arrow contour is filtered according to the size of the contour*/ |
|
|
/* The image coordinate system is converted to a planar rectangular coordinate system*/ |
then |
90° |
then |
−90° |
then |
0° |
then |
−180° |
then |
|
then |
|
then |
|
then |
|
Out |