Sobel filter-based detection method for optical storage dot matrix reading
The optical storage dot matrix reading method based on Sobel filtering and morphological processing solves the problem of crosstalk between levels in optical storage three-dimensional dot matrix data reading, achieves high-accuracy and high-speed data reading, and is suitable for long-term stable storage of optical storage devices.
Patent Information
- Application Number
- CN202310227231.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-10
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-03-10
AI Technical Summary
When reading optically stored three-dimensional dot matrix data, deep images are easily affected by crosstalk between optical signals between layers, resulting in blurred dot matrix images and difficulty in accurately reading stored data.
A detection method based on Sobel filtering is adopted. Through Sobel edge enhancement, morphological processing and binarization technology, combined with connected area calibration and grid division, the crosstalk of deep images is eliminated and the data reading accuracy is improved.
It effectively overcomes the crosstalk of deep dot matrix images, improves the accuracy and speed of optical storage dot matrix data reading, supports multi-color dot matrix information reading of multi-dimensional optical storage, and is suitable for long-term safe storage of massive information.
Smart Images

Figure CN116452433B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of optical storage data reading and relates to an optical storage detection method, in particular to a detection method based on Sobel filtering for optical storage dot matrix reading. Background Art
[0002] Data reading methods play a crucial role in the field of optical storage, directly impacting key parameters such as data read speed and accuracy. Optical storage technology is a core technology that uses laser light to illuminate a medium, causing physical and chemical changes through interaction between the laser and the medium to store information. Laser exposure alters certain properties of the medium (such as reflectivity and polarization of reflected light). These different states of the medium's properties are mapped to different stored data, and the stored data is read out by identifying these changes in the properties of the storage cells.
[0003] Optical storage lattices utilize the interaction between high-speed lasers and storage media to create a three-dimensional, multi-layered lattice within the medium. Images of the different layers are captured by photographic imaging, and the stored data is then retrieved through detection methods.
[0004] The difficulty encountered in reading optically stored three-dimensional dot matrix data is that the image obtained at a deeper depth will be affected by the crosstalk of optical signals between larger layers, and the dot matrix image will become blurred. At the same time, the shape of the points will also vary at different depths, making it difficult for detection methods to read and access data. Summary of the Invention
[0005] To overcome the aforementioned issues encountered with existing optical storage dot matrix data reading methods, the present invention aims to design a Sobel filtering-based detection method for optical storage dot matrix reading. This method can effectively eliminate strong inter-level crosstalk in deep images, enhancing overall data reading accuracy.
[0006] The technical solutions of the present invention are as follows:
[0007] The present invention comprises the following steps:
[0008] Step (1): Dot image area calibration
[0009] An original image of the crystal to be tested is obtained by using an image acquisition device (i.e., a camera), and an image within a preset detection area is selected from the original image as a dot matrix image img;
[0010] Step (2): Performing Sobel algorithm enhancement on the dot matrix image img to obtain a Sobel edge enhancement image sobel_img, and preprocessing the Sobel edge enhancement image sobel_img to obtain a secondary grayscale image;
[0011] Step (3): perform variable threshold binarization processing on the secondary grayscale image Vmatgray′ to obtain a binary image bw;
[0012] Step (4): Rotation adjustment of the binary image bw
[0013] The binary image bw and the Sobel edge enhancement image sobel_img are rotated by a rotation angle θ to obtain a positive binary image bw2′ and a positive edge enhancement image sobel_img′ respectively;
[0014] Step (5): Connected region calibration of positive binary image bw2′
[0015] Perform connected region calibration on the positive binary image bw2′ to generate several connected regions, and then mesh the positive binary image bw2′ according to the minimum circumscribed rectangles of different connected regions to form binary central units tempcutbw′;
[0016] Step (6): Obtain the image data in the positive binary image bw2′ according to the binary center unit tempcutbw′, thereby obtaining the data stored in the crystal to be tested, and then use it to read and record data from the optical storage lattice in the actual crystal piece.
[0017] The specific operations of step (2) are:
[0018] First, the filter graph G is calculated according to the following formula:
[0019]
[0020]
[0021] Where, I represents the dot matrix image img;
[0022] Then the filter image G and the dot matrix image img are superimposed to obtain the Sobel edge enhancement image sobel_img. The Sobel edge enhancement image sobel_img is converted into a single-channel image V using the following formula: mat :
[0023] v=(r 2 +g 2 +b 2 ) 0.5
[0024] Where v represents a single-channel image V mat The values of each pixel in the image are r, g, and b, respectively, representing the red r value, green g value, and blue b value of each pixel in the Sobel edge enhancement image sobel_img;
[0025] Using a single-channel image Vmat A primary grayscale image Vmatgray is obtained, and an opening operation is performed on the primary grayscale image Vmatgray through a disk-shaped morphological structure element se to obtain a background image bg, where the radius of the morphological structure element se is 0.4 times the number of pixels of the inter-dot spacing of the dot matrix image img. The primary grayscale image Vmatgray is subtracted from the background image bg to obtain a difference image, and then the difference image is contrast enhanced to obtain a secondary grayscale image Vmatgray′.
[0026] The step (4) is specifically as follows: selecting the minimum circumscribed rectangle containing all bright pixels in the binary image bw as the calibration rectangle, wherein the bright pixel is a point in the binary image bw with a pixel value of 1, and the two sides of the calibration rectangle are parallel to the X and Y axes of the Cartesian coordinate system respectively, and the image center of the binary image bw is used as the rotation center, and the binary image bw is rotated at a rotation angle θ as the rotation angle, and the minimum circumscribed rectangle containing all bright pixels in the rotated binary image bw is obtained as the calibration rectangle under the rotation angle θ, repeating the above steps to rotate the binary image bw at different rotation angles θ, and obtaining calibration rectangles under different rotation angles θ, and selecting the rotation angle θ at which the area of the calibration rectangle is the smallest as the optimal rotation angle θ. rot , with the optimal rotation angle θ rot The binary image bw and the Sobel edge enhancement image sobel_img are rotated respectively, and the optimal rotation angle θ is rot The rotated binary image bw and the Sobel edge enhancement image sobel_img are respectively intercepted with the calibration rectangle below as the boundary, and the new images obtained by interception are respectively used as the positive binary image bw2′ and the positive edge enhancement image sobel_img′.
[0027] The step (5) is specifically as follows:
[0028] First, take the lower right corner of the positive binary image bw2′ as the origin, and establish a Cartesian coordinate system with the two sides passing through the origin and parallel to the two boundaries of the positive binary image bw2′ as the X-axis and Y-axis respectively. Perform connected region calibration on the binary image bw′ to obtain i connected regions. Select the minimum circumscribed rectangle of the i-th connected region labeli as the marking rectangle BoundingBoxi of the connected region labeli. Label the coordinate of the upper left corner of the i-th marking rectangle BoundingBoxi as (Boundingxi, Boundingyi). Combine the coordinates of the upper left corners of all marking rectangles on the X-axis and Y-axis to form the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy respectively:
[0029] Boundingx=[Boundingx1...Boundingxi...Boundingxn]
[0030] Boundingy=[Boundingy1...Boundingxi...Boundingyn]
[0031] The elements in the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy are rearranged in ascending order to obtain the X-axis arrangement set sortx and the Y-axis arrangement set sorty, respectively. The X-axis arrangement set sortx and the Y-axis arrangement set sorty are then classified to obtain the X grid line set xseg and the Y grid line set yseg, respectively. A plurality of vertical grid lines are established using the values of each element in the X grid line set xseg as the horizontal coordinates of each vertical grid line. A plurality of horizontal grid lines are established using the values of each element in the Y grid line set yseg as the vertical coordinates of each horizontal grid line. The positive binary image bw2′ is then grid-divided using all the vertical and horizontal grid lines to obtain a plurality of grid division units temp. The vertical and horizontal grid division lines are parallel to the Y and X axes, respectively. The x offset dx on the X axis and the y offset dy on the Y axis of the bright pixel area in each grid division unit temp are calculated:
[0032] dx=bx-cx
[0033] dy=by-cy
[0034] Wherein, cx and cy are the abscissa (x-coordinate) and ordinate (y-coordinate) of the center point of a single grid division unit temp, respectively; bx and by are the abscissa (x-coordinate) and ordinate (y-coordinate) of the centroid of the bright pixel area in the grid division unit temp, respectively; the bright pixel area is the area where the pixel points with a pixel value of 1 are located in the grid division unit temp;
[0035] Finally, the average of the x-offset dx and y-offset dy of all bright pixel areas in the positive binary image bw2′ is calculated and recorded as the x-average offset and y-average offset, respectively. Then, all vertical grid division lines are translated in the X-axis direction by the x-average offset to form new vertical grid division lines, and all horizontal grid division lines are translated in the Y-axis direction by the y-average offset to form new horizontal grid division lines. Then, the new vertical grid division lines and horizontal grid division lines are used to grid the positive binary image bw2′ and the positive edge enhancement image sobel_img′ to obtain several binary grid division units tempbw′ of the positive binary image bw2′ and color grid division units tempimg′ of the positive edge enhancement image sobelimg′, respectively. The units within the preset range are taken from the center parts of the binary grid division unit tempbw′ and the color grid division unit tempimg′ as the binary center unit tempcutbw′ and the color center unit tempcutimg′, respectively.
[0036] The step (6) is specifically as follows:
[0037] Determine the number of bright pixels count in the binary center unit tempcutbw′, where the bright pixels represent pixels with a pixel value of 1, and calculate the mean mean, brightness v, and color difference ΔE of the binary center unit tempcutbw′:
[0038]
[0039] v=max(r w , g w , b w )
[0040]
[0041] Among them, r w 、g w 、b w They represent the average r value, average g value, and average b value of all bright pixels in the color center unit tempcutimg' at the same position as the calculated binary center unit tempcutbw', r bg 、g bg 、b bg Respectively represent the average r value, average g value, and average b value of all dark pixels in the color center unit tempcutimg' at the same position as the calculated binary center unit tempcutbw', wherein the dark pixels represent pixels with a pixel value of 0, a represents the total number of pixels in the binary center unit tempcutbw, and max() represents a maximum value function;
[0042] Then classify the binary center unit tempcutbw':
[0043] If the number of bright pixels in the binary central unit tempcutbw' is greater than 30% of the total number of pixels, and the color difference ΔE of the binary central unit tempcutbw' is greater than 1000, the mean mean is greater than 50, and the brightness v is greater than 80, then the binary central unit tempcutbw' is recorded as the first central unit;
[0044] Otherwise, the binary center unit tempcutbw' is recorded as the second center unit;
[0045] Substitute all first central units into the model trained by the classification learner to generate a first model, substitute all second central units into the model trained by the classification learner to generate a second model, calculate the vector product similarity between each binary central unit tempcutbw' and the first model and the second model respectively, and use them as the first similarity 1_similarity and the second similarity 0_similarity:
[0046]
[0047]
[0048] Where vectemp is the vectorized form of the binary center unit tempcutbw', vec_model_1 and vec_model_0 are the vectorized forms of the first model and the second model respectively, norm represents the 2-norm of the orientation, and eps is the floating-point relative precision;
[0049] If the first similarity 1_similarity of the binary center unit tempcutbw' is greater than the second similarity 0_similarity, the value of the binary center unit tempcutbw' is recorded as 1;
[0050] Otherwise, the value of the binary center unit tempcutbw' is recorded as 0;
[0051] The values of all binary center units tempcutbw' are recorded in the form of a matrix to form a final value matrix detinf, and the final value matrix detinf is used to read and record the optical storage data in the crystal to be tested in a 0-1 manner, and then used to read and record data from the optical storage lattice in the actual crystal piece.
[0052] In step (2), a single-channel image V is used mat The specific steps to obtain a grayscale image Vmatgray are:
[0053] Create a single-channel image V mat The pixel vector Vm and the grayscale pixel vector Vmg of the primary grayscale image Vmatgray:
[0054] Vm=[vm1 vm2 vm3…vm j …vm m ]
[0055] Vmg=[vmg1 vmg2 vmg3…vmg j …vmg m ]
[0056] Among them, vm j is a single-channel image V mat The value of the j-th pixel in vmg j is an element in the grayscale pixel vector Vmg, j represents the ordinal number of the pixel, and m represents the number of pixels;
[0057] Use the pixel vector Vm to determine each element vmg in the grayscale pixel vector Vmg j The value of:
[0058] When vm j = min(Vm), vmg j Take 0;
[0059] When vm j =max(Vm), vmg j Take 255;
[0060] When vm j Not equal to min(Vm) and vm j When it is not equal to max(Vm),
[0061]
[0062] Among them, max() represents the maximum value function, and min() represents the minimum value function;
[0063] Then, the grayscale pixel vector Vmg is used to generate a grayscale image Vmatgray, wherein each element in the grayscale pixel vector Vmg is the value of each pixel in the grayscale image Vmatgray.
[0064] The specific steps of classifying the X-axis arrangement set sortx and the Y-axis arrangement set sorty in step (5) are as follows:
[0065] Step 51: Perform the k-th classification on all elements in the X-axis arrangement set sortx:
[0066] If the value of an element in the X-axis arrangement set sortx is in the range [xpole-xdistance / 2, xpole+xdistance / 2], then the element is classified from the X-axis arrangement set sortx into category k;
[0067] If the value of an element in the X-axis arrangement set sortx is not in the range [xpole-xdistance / 2, xpole+xdistance / 2], the element will not be divided out;
[0068] If all elements in the X-axis arrangement set sortx are sorted out, proceed to step 53;
[0069] Where xdistance represents the average distance in pixels between the dots of the positive binary image be2′ in the x-direction, k represents the ordinal number of the element classification in the X-axis arrangement set sortx, category k represents the set of elements to be divided when performing the k-th classification, and the label value xpole is 1 for the first classification.
[0070] Step 52: Establish an X grid line set xseg = [xseg1, ..., xsegk, ..., xsegm], calculate the average value of all elements in category k and assign the average value to the k-th element xsegk in the X grid line set xseg, and reassign the label value xpole: label value xpole = xsegk + xdistance, then increase the number of divisions k by 1, and continue with step 51;
[0071] Step 53: Interpolate the X grid line set xseg:
[0072] If the difference between two adjacent elements in the X grid line set xseg is several times greater than xdistance, then s new elements are inserted between the two adjacent elements on average to form a new X grid line set xseg, where s = {the difference between the two adjacent elements / xdistance} - 1;
[0073] If the difference between two adjacent elements in the X grid line set xseg is not an integer multiple of xdistance, no difference processing is performed;
[0074] Among them, {} represents the rounding operation;
[0075] Step 54: Perform the f-th classification on all elements in the Y-axis arrangement set sorty:
[0076] If the value of an element in the Y-axis arrangement set sorty is in the range [ypole-ydistance / 2, ypole+ydistance / 2], then the element is classified from the Y-axis arrangement set sorty into category f;
[0077] If the value of an element in the Y-axis arrangement set sorty is not in the range [ypole-ydistance / 2, ypole+ydistance / 2], the element will not be divided out;
[0078] If all elements in the Y-axis arrangement set sorty are sorted out, proceed to step 56;
[0079] Where ydistance represents the average pixel spacing between the dots in the positive binary image bw2′ in the y direction, f represents the ordinal number of the element classification by the Y-axis arrangement set sorty, category f represents the set of elements divided when the f-th classification is performed, and the label value ypole is 1 for the first classification.
[0080] Step 55: Establish a Y grid line set yseg = [yseg1, ...ysegf, ...ysegq], calculate the average value of all elements in category f and assign the average value to the f-th element ysegf in the Y grid line set yseg, and reassign the label value ypole: label value ypole = ysegf + ydistance, then increase the number of divisions f by 1, and continue with step 54;
[0081] Step 56: Interpolate the Y grid line set yseg:
[0082] If the difference between two adjacent elements in the Y grid line set yseg is several times greater than ydistance, then t new elements are inserted between the two adjacent elements on average to form a new Y grid line set yseg, where t = {the difference between the two adjacent elements / ydistance} - 1;
[0083] If the difference between two adjacent elements in the Y grid line set yseg is not a multiple of ydistance, no difference processing is performed;
[0084] Among them, {} represents the rounding operation.
[0085] The optical storage technology supported by this method boasts high stability, compact size, strong storage capacity, and a lifespan of thousands of years. It is suitable for the secure, long-term storage of massive amounts of information and is an optimal solution for archiving, backing up, and other data requiring long-term preservation. Optical storage is suitable for managing sensitive data and backups, protecting data from human error, emergencies, natural disasters, and other attacks, such as in public security and government archives, and financial and commercial archives. Optical storage devices consume no power over 95% of the time, generating virtually no heat. The optical storage medium has relatively low requirements for ambient temperature and humidity, eliminating the need for frequent replacement of storage media and equipment throughout the data lifecycle. This reduces overall energy consumption for data storage and meets the requirements for building green data centers.
[0086] This method uses a detection algorithm based on Sobel filtering to overcome the strong crosstalk between layers in deep dot patterns, improving the accuracy of dot data reading. Sobel filtering and two-dimensional filtering are used to suppress the background light intensity of deep dot patterns, increasing image contrast. Connected regions and classification methods are used to draw the dot grid, and stored data is obtained by analyzing the complex image features of a single grid.
[0087] The beneficial effects of the present invention are:
[0088] 1. Using Sobel color filtering and morphological processing, the crosstalk in deep dot matrix images is effectively overcome, and the accuracy of dot matrix data reading is improved.
[0089] 2. Use the camera to shoot the dot array surface, support the surface reading of the optical storage dot array, and improve the reading rate.
[0090] 3. Color images are used in the detection process, and the information reading of multi-color dot matrix of multi-dimensional optical storage is supported, which supports higher capacity optical storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] Figure 1 It is a flow chart of the steps of the detection of the present invention;
[0092] Figure 2 is the intercepted detection area;
[0093] Figure 3 It is an image enhanced by the Sobel algorithm;
[0094] Figure 4 It is the variable threshold binarization of the grayscale image;
[0095] Figure 5 It is to rotate and fine-tune the image;
[0096] Figure 6 It is the grid division of the detection image. DETAILED DESCRIPTION
[0097] The present invention will be further described below with reference to the accompanying drawings and examples.
[0098] The implementation process of the embodiment of the present invention is as follows:
[0099] The present invention comprises the following steps, as Figure 1 As shown:
[0100] Step (1): Dot image area calibration
[0101] The original image of the crystal to be tested is obtained by using an image acquisition device (ie, a camera), and the image within the preset detection area is selected from the original image as a dot matrix image img, such as Figure 2 As shown;
[0102] Step (2): Perform Sobel algorithm enhancement on the dot matrix image img to obtain the Sobel edge enhancement image sobel_img, and preprocess the Sobel edge enhancement image sobel_img to obtain a secondary grayscale image, such as Figure 3 As shown;
[0103] Step (3): Perform variable threshold binarization processing on the secondary grayscale image Vmatgray' to obtain a binary image bw;
[0104] like Figure 4 As shown, the specific operation of the variable threshold binarization processing of the secondary grayscale image Vmatgray' in step (3) is: dividing the secondary grayscale image Vmatgray' into several grayscale sub-images, automatically performing threshold binarization on each of the divided grayscale sub-images, and re-merging the grayscale sub-images after automatic threshold binarization to generate a binary image bw, and then processing according to the state of the bright spot in the binary image bw:
[0105] If the bright spot is a solid point, the binary image bw is expanded to obtain a new image, and the new image is used as the latest binary image bw;
[0106] If the bright spot is a hollow hole, fill the hole in the binary image bw to obtain a new image, and use the new image as the latest binary image bw;
[0107] Step (4): Rotation adjustment of the binary image bw
[0108] like Figure 5 As shown, the binary image bw and the Sobel edge enhancement image sobel_img are rotated with a rotation angle θ as the rotation angle to obtain a positive binary image bw2′ and a positive edge enhancement image sobel_img′ respectively;
[0109] Step (5): Connected region calibration of positive binary image bw2′
[0110] The connected regions of the positive binary image bw2′ are calibrated using 8-connectivity to generate several connected regions. Then, the positive binary image bw2′ is meshed according to the minimum circumscribed rectangles of different connected regions to form binary center units tempcutbw′, as shown in Figure 6 As shown;
[0111] Step (6): Obtain the image data in the positive binary image bw2′ according to the binary center unit tempcutbw′, thereby obtaining the data stored in the crystal to be tested, and then use it to read and record data from the optical storage lattice in the actual crystal piece.
[0112] The specific operations of step (2) are:
[0113] First, the filter graph G is calculated according to the following formula:
[0114]
[0115]
[0116] Where, I represents the dot matrix image img;
[0117] Then the filter image G and the dot matrix image img are superimposed to obtain the Sobel edge enhancement image sobel_img. The Sobel edge enhancement image sobel_img is converted into a single-channel image Vmat using the following formula:
[0118] v=(r 2 +g 2 +b 2 ) 0.5
[0119] Where v represents a single-channel image V mat The values of each pixel in the image are r (red), g (green), and b (blue), respectively.
[0120] Using a single-channel image V mat A primary grayscale image Vmatgray' is obtained, and an opening operation is performed on the primary grayscale image Vmatgray through a disk-shaped morphological structure element se to obtain a background image bg. The radius of the morphological structure element se is 0.4 times the number of pixels of the inter-dot spacing of the dot image img. The primary grayscale image Vmatgray is subtracted from the background image bg to obtain a difference image, and then the difference image is contrast enhanced to obtain a secondary grayscale image Vmatgray'.
[0121] Step (4) is specifically as follows: select the minimum circumscribed rectangle containing all bright pixels in the binary image bw as the calibration rectangle, the bright pixel is a point in the binary image bw with a pixel value of 1, the two sides of the calibration rectangle are parallel to the X and Y axes of the Cartesian coordinate system, that is, the calibration rectangle is a rectangle placed horizontally and vertically, the two sides of the calibration rectangle are parallel to the two sides of the binary image bw, the image center of the binary image bw is used as the rotation center, and the binary image bw is rotated at a rotation angle θ as the rotation angle, and the minimum circumscribed rectangle containing all bright pixels in the rotated binary image bw is obtained as the calibration rectangle under the rotation angle θ, repeat the above steps to rotate the binary image bw with different rotation angles θ, θ∈[-5,5], obtain the calibration rectangle under different rotation angles θ, and select the rotation angle θ with the smallest area of the calibration rectangle as the optimal rotation angle θ rot , with the optimal rotation angle θ rot The binary image bw and the Sobel edge enhancement image sobel_img are rotated respectively, and the optimal rotation angle θ is rot The rotated binary image bw and the rotated Sobel edge enhancement image sobel_img are respectively intercepted with the calibration rectangle below as the boundary, and the new images obtained by interception are respectively used as the positive binary image bw2′ and the positive edge enhancement image sobel_img′.
[0122] Step (5) is specifically as follows:
[0123] First, take the lower right corner of the positive binary image bw2′ as the origin, and establish a Cartesian coordinate system with the two sides passing through the origin and parallel to the two boundaries of the positive binary image bw2′ as the X-axis and Y-axis respectively. Use 8-connectivity to calibrate the connected regions of the binary image bw′ to obtain i connected regions. Select the minimum circumscribed rectangle of the i-th connected region labeli as the marking rectangle BoundingBoxi of the connected region labeli. Label the coordinate of the upper left corner of the i-th marking rectangle BoundingBoxi as (Boundingxi) and Boundingyi. Combine the coordinates of the upper left corners of all marking rectangles on the X-axis and Y-axis to form the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy respectively:
[0124] Boundingx=[Boundingx1...Boundingxi...Boundingxn]
[0125] Boundingy=[Boundingy1...Boundingxi...Boundingyn]
[0126] That is, the set of all connected areas is expressed as LABEL = [label1, label2l...labeli...labeln], the set of all marked rectangles is expressed as BoundingBox = [BoundingBox1, ...BoundingBox1i, ...BoundingBoxn], and the set of coordinates of the upper left corner of all marked rectangles is expressed as [(Boundingx1, Boundingy1) ... (Boundingxn, Boundingyn)], where i represents the ordinal number of the connected area and n represents the total number of connected areas;
[0127] Rearrange the elements in the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy from left to right in ascending order to obtain the X-axis arrangement set sortx and the Y-axis arrangement set sorty, respectively. Then, classify the X-axis arrangement set sortx and the Y-axis arrangement set sorty to obtain the X grid line set xseg and the Y grid line set yseg, respectively. Use the values of each element in the X grid line set xseg as the horizontal coordinates of each vertical grid line to establish several vertical grid lines. Use the values of each element in the Y grid line set yseg as the vertical coordinates of each horizontal grid line to establish horizontal grid lines. Then, use all the vertical grid lines and horizontal grid lines to grid the positive binary image bw2′ to obtain several grid division units temp. The vertical grid division lines and horizontal grid division lines are parallel to the Y axis and the X axis, respectively. Calculate the x offset dx on the X axis and the y offset dy on the Y axis of the bright pixel area in each grid division unit temp:
[0128] dx=bx-cx
[0129] dy=by-cy
[0130] Where cx and cy are the x-coordinate and y-coordinate of the center point of a single grid cell temp, bx and by are the x-coordinate and y-coordinate of the centroid of the bright pixel region in the grid cell temp. The bright pixel region is the region where the pixel value of the pixel in the grid cell temp is 1.
[0131] Finally, the average of the x-offset dx and y-offset dy of all bright pixel areas in the positive binary image bw2′ is calculated respectively, and recorded as the x-average offset and the y-average offset respectively. Then, all vertical grid division lines are translated in the X-axis direction by the x-average offset to form new vertical grid division lines, and all horizontal grid division lines are translated in the Y-axis direction by the y-average offset to form new horizontal grid division lines. Then, the positive binary image bw2′ and the positive edge enhancement image sobel_ing′ are grid-divided using the new vertical grid division lines and horizontal grid division lines to obtain a number of binary grid division units tempbw′ of the positive binary image bw2′ and color grid division units tempimg′ of the positive edge enhancement image sobel_img′, respectively. The units within the preset range are taken from the center parts of the binary grid division unit tempbw′ and the color grid division unit tempimg′ as the binary center unit tempcutbw′ and the color center unit tempcutimg′ respectively.
[0132] In a specific implementation, the binary center unit tempcutbw'=tempbw'(0.3*xlength:0.7*xlength, 0.3*ylength:0.7*ylength), and the color center unit tempcutimg'=temping'(0.3*xlength:0.7*xlength, 0.3*ylength:0.7*ylength), where xlength and ylength are the lengths of the binary grid division unit tempbw' in the X direction and the Y direction respectively;
[0133] Step (6) is specifically:
[0134] Determine the number of bright pixels count in the binary center unit tempcutbw'. Bright pixels represent pixels with a pixel value of 1. Calculate the mean, brightness υ, and color difference ΔE of the binary center unit tempcutbw':
[0135]
[0136] v=max(r w , g w , b w )
[0137]
[0138] Among them, r w 、g w 、b wThey represent the average r value, average g value, and average b value of all bright pixels in the color center unit tempcutimg′ at the same position as the calculated binary center unit tempcutbw′, r bg 、g bg 、b bg They represent the average r value, average g value, and average b value of all dark pixels in the color center unit tempcutimg' at the same position as the calculated binary center unit tempcutbw', respectively. Dark pixels represent pixels with a pixel value of 0. a represents the total number of pixels in the binary center unit tempcutbw. max() represents the maximum value function.
[0139] In addition, the hue h and saturation s1 of each binary center unit tempcutbw' can also be calculated:
[0140] If max(r w , g w , b w )=min(r w , g w , b w ), then h=0°;
[0141] If max(r w , g w , b w )=r w And g w <b w ,
[0142] but
[0143] If max(r w , g w , b w )=r w And g w ≥b w ,
[0144] but
[0145] If max(r w , g w , b w )=g w ,
[0146] but
[0147] If max(r w , g w , b w )=b w ,
[0148] but
[0149] If max(r w , g w , b w )=0, then s1=0;
[0150] If max(r w , g w , b w ) is not equal to 0, then
[0151] Among them, min() represents the minimum value function
[0152] Then classify the binary center unit tempcutbw':
[0153] If the number of bright pixels in the binary central unit tempcutbw' is greater than 30% of the total number of pixels, and the color difference ΔE of the binary central unit tempcutbw' is greater than 1000, the mean mean is greater than 50, and the brightness v is greater than 80, then the binary central unit tempcutbw' is recorded as the first central unit;
[0154] Otherwise, the binary center unit tempcutbw' is recorded as the second center unit;
[0155] Substitute all first central units into the model trained by the classification learner to generate a first model, substitute all second central units into the model trained by the classification learner to generate a second model, calculate the vector product similarity between each binary central unit tempcutbw' and the first model and the second model respectively, and use them as the first similarity 1_similarity and the second similarity 0_similarity:
[0156]
[0157]
[0158] Where vectemp is the vectorized form of the binary center unit tempcutbw', vec_model_1 and vec_model_0 are the vectorized forms of the first model and the second model respectively, norm represents the 2-norm of the orientation, and eps is the floating-point relative precision;
[0159] If the first similarity 1_similarity of the binary center unit tempcutbw' is greater than the second similarity 0_similarity, the value of the binary center unit tempcutbw' is recorded as 1;
[0160] Otherwise, the value of the binary center unit temp tbw′ is recorded as 0;
[0161] The values of all binary central units tempcutbw' are recorded in the form of a matrix to form a final value matrix detinf, and the final value matrix detinf is used to read and record the optical storage data in the crystal to be tested in a 0-1 manner, and then used to read and record data from the optical storage lattice in the actual crystal piece.
[0162] In step (2), a single-channel image V is used mat The specific steps to obtain a grayscale image Vmatgray are:
[0163] Create a single-channel image V mat The pixel vector Vm and the grayscale pixel vector Vmg of the primary grayscale image Vmatgray:
[0164] Vm=[vm1 vm2 vm3…vm j …vm m ]
[0165] Vmg=[vmg1 vmg2 vmg3…vmg j …vmg m ]
[0166] Among them, vm j is a single-channel image V mat The value of the j-th pixel in vm j is the element in the pixel vector Vm, vmg j is an element in the grayscale pixel vector Vmg, that is, a single-channel image V mat The value of the j-th pixel in , j represents the ordinal number of the pixel, and m represents the number of pixels;
[0167] Use the pixel vector Vm to determine each element vmg in the grayscale pixel vector Vmg j The value of:
[0168] When vm j = min(Vm), vmg j Take 0;
[0169] When vm j =max(Vm), vmg j Take 255;
[0170] When vm j Not equal to min(Vm) and vm j When it is not equal to max(Vm),
[0171] vmg j The value is
[0172] Among them, max() represents the maximum value function, and min() represents the minimum value function;
[0173] Then, the grayscale pixel vector Vmg is used to generate a grayscale image Vmatgray, wherein each element in the grayscale pixel vector Vmg is the value of each pixel in the grayscale image Vmatgray.
[0174] The specific steps of classifying the X-axis arrangement set sortx and the Y-axis arrangement set sorty in step (5) are as follows:
[0175] Step 51: Perform the k-th classification on all elements in the X-axis arrangement set sortx:
[0176] If the value of an element in the X-axis arrangement set sortx is in the range [xpole-xdistance / 2, xpole+xdistance / 2], then the element is classified from the X-axis arrangement set sortx into category k;
[0177] If the value of an element in the X-axis arrangement set sortx is not in the range [xpole-xdistance / 2, xpole+xdistance / 2], the element will not be divided out;
[0178] If all elements in the X-axis arrangement set sortx are sorted out, proceed to step 53;
[0179] Where xdistance represents the average distance in pixels between the dots of the positive binary image bw2′ in the x direction, k represents the ordinal number of the element classification in the X-axis arrangement set sortx, the initial value of k is 1, category k represents the set of elements to be divided when performing the k-th classification, and the label value xpole is 1 for the first classification;
[0180] Step 52: Establish an X grid line set xseg = [xseg1, ..., xsegk, ..., xsegm], calculate the average value of all elements in category k and assign the average value to the k-th element xsegk in the X grid line set xseg, and reassign the label value xpole: label value xpole = xsegk + xdistance. Then, increase the number of divisions k by 1, and continue with step 51. m represents the total number of divisions of the X-axis arrangement set sortx.
[0181] Step 53: Interpolate the X grid line set xseg:
[0182] If the difference between two adjacent elements in the X grid line set xseg is approximately an integer multiple of xdistance, then an average of s new elements are inserted between the two adjacent elements to form a new X grid line set xseg, where s = {the difference between the two adjacent elements / xdistance} - 1;
[0183] If the difference between two adjacent elements in the X grid line set xseg is not an integer multiple of xdistance, no difference processing is performed;
[0184] Among them, {} represents the rounding operation;
[0185] The approximate integer multiple is within the range of plus or minus 0.3 of the integer multiple.
[0186] Step 54: Perform the f-th classification on all elements in the Y-axis arrangement set sorty:
[0187] If the value of an element in the Y-axis arrangement set sorty is in the range [ypole-ydistance / 2, ypole+ydistance / 2], then the element is classified from the Y-axis arrangement set sorty into category f;
[0188] If the value of an element in the Y-axis arrangement set sorty is not in the range [ypole-ydistance / 2, ypole+ydistance / 2], the element will not be divided out;
[0189] If all elements in the Y-axis arrangement set sorty are sorted out, proceed to step 56;
[0190] Where ydistance represents the average pixel spacing between dots in the positive binary image bw2′ in the y direction, f represents the ordinal number of the element classification by the Y-axis arrangement set sorty, the initial value of f is 1, category f represents the set of elements to be divided when performing the f-th classification, and the label value ypole is 1 for the first classification;
[0191] Step 55: Establish a Y grid line set yseg = [yseg1, ...ysegf, ...ysegq], calculate the average value of all elements in category f and assign the average value to the f-th element ysegf in the Y grid line set yseg, and reassign the label value ypole: label value ypole = ysegf + ydistance, then increase the number of divisions f by 1, and continue with step 54, where q represents the total number of divisions of the Y-axis arrangement set sorty;
[0192] Step 56: Interpolate the Y grid line set yseg:
[0193] If the difference between two adjacent elements in the Y grid line set yseg is approximately an integer multiple of ydistance, then t new elements are inserted between the two adjacent elements on average to form a new Y grid line set yseg, where t = {the difference between the two adjacent elements / ydistance} - 1;
[0194] If the difference between two adjacent elements in the Y grid line set yseg is not an approximately integer multiple of ydistance, no difference processing is performed;
[0195] Among them, {} represents the rounding operation.
[0196] The partitioning method of the Y-axis arrangement set sorty is the same as the partitioning method of the X-axis arrangement set sortx.
Claims
1. A detection method based on Sobel filtering for optical storage dot array reading, characterized in that: The following steps are involved: Step (1): Dot image area calibration An original image of the crystal to be tested is obtained by using an image acquisition device, and an image within a preset detection area is selected from the original image as a dot matrix image img; Step (2): Performing Sobel algorithm enhancement on the dot matrix image img to obtain a Sobel edge enhancement image sobel_img, and preprocessing the Sobel edge enhancement image sobel_img to obtain a secondary grayscale image; Step (3): Perform variable threshold binarization processing on the secondary grayscale image Vmatgray' to obtain a binary image bw; Step (4): Rotation adjustment of the binary image bw The binary image bw and the Sobel edge enhancement image sobel_img are rotated by a rotation angle θ to obtain a positive binary image bw2′ and a positive edge enhancement image sobel_img′ respectively; Step (5): Connected region calibration of positive binary image bw2′ The connected regions of the positive binary image bw2′ are calibrated to generate several connected regions, and then the positive binary image bw2′ is gridded according to the minimum circumscribed rectangles of different connected regions to form binary central units tempcutbw′; Step (6): Obtain the image data in the positive binary image bw2′ according to the binary center unit tempcutbw′, thereby obtaining the data stored in the crystal to be tested, and then use it to read and record data from the optical storage lattice in the actual crystal piece.
2. The Sobel filter-based detection method for optical storage dot array reading according to claim 1, characterized in that: The specific operations of step (2) are: First, the filter graph G is calculated according to the following formula: Where, I represents the dot matrix image img; Then the filter image G and the dot matrix image img are superimposed to obtain the Sobel edge enhancement image sobel_img. The Sobel edge enhancement image sobel_img is converted into a single-channel image V using the following formula: mat : v=(r 2 +g 2 +b 2 ) 0.5 Where v represents a single-channel image V mat The values of each pixel in the image are r, g, and b, respectively, representing the red r value, green g value, and blue b value of each pixel in the Sobel edge enhancement image sobel_img; Using a single-channel image V mat A primary grayscale image Vmatgray is obtained, and an opening operation is performed on the primary grayscale image Vmatgray using a disk-shaped morphological structure element se to obtain a background image bg, where the radius of the morphological structure element se is 0.4 times the number of pixels of the inter-dot spacing of the dot matrix image img. The primary grayscale image Vmatgray is subtracted from the background image bg to obtain a difference image, and the difference image is then contrast-enhanced to obtain a secondary grayscale image Vmatgray'.
3. The Sobel filter-based detection method for optical storage dot array reading according to claim 1, characterized in that: The step (4) is specifically as follows: selecting the minimum circumscribed rectangle containing all bright pixels in the binary image bw as the calibration rectangle, wherein the bright pixel is a point in the binary image bw with a pixel value of 1, and the two sides of the calibration rectangle are parallel to the X and Y axes of the Cartesian coordinate system respectively, and the image center of the binary image bw is used as the rotation center, and the binary image bw is rotated at a rotation angle θ as the rotation angle, and the minimum circumscribed rectangle containing all bright pixels in the rotated binary image bw is obtained as the calibration rectangle under the rotation angle θ, repeating the above steps to rotate the binary image bw at different rotation angles θ, and obtaining calibration rectangles under different rotation angles θ, and selecting the rotation angle θ at which the area of the calibration rectangle is the smallest as the optimal rotation angle θ. rot , with the optimal rotation angle θ rot The binary image bw and the Sobel edge enhancement image sobel_img are rotated respectively, and the optimal rotation angle θ is rot The rotated binary image bw and the Sobel edge enhancement image sobel_img are respectively intercepted with the calibration rectangle below as the boundary, and the new images obtained by interception are respectively used as the positive binary image bw2′ and the positive edge enhancement image sobel_img′.
4. The Sobel filter-based detection method for optical storage dot array reading according to claim 1, characterized in that: The step (5) is specifically as follows: First, take the lower right corner of the positive binary image bw2′ as the origin, and establish a Cartesian coordinate system with the two sides passing through the origin and parallel to the two boundaries of the positive binary image bw2′ as the X-axis and Y-axis respectively. Perform connected region calibration on the binary image bw′ to obtain i connected regions. Select the minimum circumscribed rectangle of the i-th connected region labeli as the marking rectangle BoundingBoxi of the connected region labeli. Label the coordinate of the upper left corner of the i-th marking rectangle BoundingBoxi as (Boundingxi, Boundingyi). Combine the coordinates of the upper left corners of all marking rectangles on the X-axis and Y-axis to form the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy respectively: Boundingx=[Boundingx1…Boundingxi…Boundingxn] Boundingy=[Boundingy1…Boundingxi…Boundingyn] The elements in the X-axis coordinate set Boundingx and the Y-axis coordinate set Boundingy are rearranged in ascending order to obtain the X-axis arrangement set sortx and the Y-axis arrangement set sorty, respectively. The X-axis arrangement set sortx and the Y-axis arrangement set sorty are then classified to obtain the X grid line set xseg and the Y grid line set yseg, respectively. A plurality of vertical grid lines are established using the values of each element in the X grid line set xseg as the horizontal coordinates of each vertical grid line. A plurality of horizontal grid lines are established using the values of each element in the Y grid line set yseg as the vertical coordinates of each horizontal grid line. The positive binary image bw2′ is then grid-divided using all the vertical and horizontal grid lines to obtain a plurality of grid division units temp. The vertical and horizontal grid division lines are parallel to the Y and X axes, respectively. The x offset dx on the X axis and the y offset dy on the Y axis of the bright pixel area in each grid division unit temp are calculated: dx=bx-cx dy=by-cy Wherein, cx and cy are the horizontal coordinate and vertical coordinate of the center point of a single grid division unit temp, respectively, and bx and by are the horizontal coordinate and vertical coordinate of the centroid of the bright pixel area in the grid division unit temp, respectively; the bright pixel area is the area where the pixel points with pixel value 1 in the grid division unit temp are located; Finally, the average of the x-offset dx and y-offset dy of all bright pixel areas in the positive binary image bw2′ is calculated and recorded as the x-average offset and y-average offset, respectively. Then, all vertical grid division lines are translated in the X-axis direction by the x-average offset to form new vertical grid division lines, and all horizontal grid division lines are translated in the Y-axis direction by the y-average offset to form new horizontal grid division lines. Then, the positive binary image bw2′ and the positive edge enhancement image sobel_img′ are grid-divided using the new vertical grid division lines and horizontal grid division lines to obtain a number of binary grid division units tempbw' of the positive binary image bw2′ and color grid division units tempimg' of the positive edge enhancement image sobel_img′, respectively. The units within the preset range are taken from the center parts of the binary grid division unit tempbw' and the color grid division unit tempimg' as the binary center unit tempcutbw' and the color center unit tempcutimg', respectively.
5. The detection method based on Sobel filtering for optical storage dot array reading according to claim 1, characterized in that: The step (6) is specifically as follows: Determine the number of bright pixels count in the binary center unit tempcutbw', where the bright pixels represent pixels with a pixel value of 1, and calculate the mean mean, brightness v, and color difference ΔE of the binary center unit tempcutbw': v=max(r w ,g w ,b w ) Among them, r w 、g w 、b w They represent the average r value, average g value, and average b value of all bright pixels in the color center unit tempcutimg' at the same position as the calculated binary center unit tempcutbw', r bg 、g bg 、b bg Respectively represent the average r value, average g value, and average b value of all dark pixels in the color center unit tempcutimg' at the same position as the calculated binary center unit tempcutbw', wherein the dark pixels represent pixels with a pixel value of 0, a represents the total number of pixels in the binary center unit tempcutbw', and max() represents a maximum value function; Then classify the binary center unit tempcutbw': If the number of bright pixels in the binary central unit tempcutbw' is greater than 30% of the total number of pixels, and the color difference ΔE of the binary central unit tempcutbw' is greater than 1000, the mean mean is greater than 50, and the brightness v is greater than 80, then the binary central unit tempcutbw' is recorded as the first central unit; Otherwise, the binary center unit tempcutbw' is recorded as the second center unit; Substitute all first central units into the model trained by the classification learner to generate a first model, substitute all second central units into the model trained by the classification learner to generate a second model, calculate the vector product similarity between each binary central unit tempcutbw' and the first model and the second model respectively, and use them as the first similarity 1_similarity and the second similarity 0_similarity: First similarity Second similarity Where vectemp is the vectorized form of the binary center unit tempcutbw', vec_model_1 and vec_model_0 are the vectorized forms of the first model and the second model respectively, norm represents the 2-norm of the orientation, and eps is the floating-point relative precision; If the first similarity 1_similarity of the binary center unit tempcutbw' is greater than the second similarity 0_similarity, the value of the binary center unit tempcutbw' is recorded as 1; Otherwise, the value of the binary center unit tempcutbw' is recorded as 0; The values of all binary central units tempcutbw' are recorded in the form of a matrix to form a final value matrix detinf, and the final value matrix detinf is used to read and record the optical storage data in the crystal to be tested in a 0-1 manner, and then used to read and record data from the optical storage lattice in the actual crystal piece.
6. The detection method based on Sobel filtering for optical storage dot array reading according to claim 2, characterized in that: In step (2), a single-channel image V is used mat The specific steps to obtain a grayscale image Vmatgray are: Create a single-channel image V mat The pixel vector Vm and the grayscale pixel vector Vmg of the primary grayscale image Vmatgray: Vm=[vm1 vm2 vm3…vm j …vm m ] Vmg=[vmg1 vmg2 vmg3…vmg j …vmg m ] Among them, vm j is a single-channel image V mat The value of the j-th pixel in vmg j is an element in the grayscale pixel vector Vmg, j represents the ordinal number of the pixel, and m represents the number of pixels; Use the pixel vector Vm to determine each element vmg in the grayscale pixel vector Vmg j The value of: When vm j = min(Vm), vmg j Take 0; When vm j =max(Vm), vmg j Take 255; When vm j Not equal to min(Vm) and vm j When it is not equal to max(Vm), vmg j The value is Among them, max() represents the maximum value function, and min() represents the minimum value function; Then, the grayscale pixel vector Vmg is used to generate a grayscale image Vmatgray, wherein each element in the grayscale pixel vector Vmg is the value of each pixel in the grayscale image Vmatgray.
7. The Sobel filter-based detection method for optical storage dot array reading according to claim 1, characterized in that: The specific steps of classifying the X-axis arrangement set sortx and the Y-axis arrangement set sorty in step (5) are as follows: Step 51: Perform the k-th classification on all elements in the X-axis arrangement set sortx: If the value of an element in the X-axis permutation set sortx is in the range [xpole-xdistance / 2, xpole+xdistance / 2], then the element is classified from the X-axis permutation set sortx into category k; If the value of an element in the X-axis arrangement set sortx is not in the range [xpole-xdistance / 2, xpole+xdistance / 2], the element will not be divided out; If all elements in the X-axis arrangement set sortx are sorted out, proceed to step 53; Where xdistance represents the average distance in pixels between points in the x-direction of the positive binary image bw2′, k represents the ordinal number of the element classification in the X-axis arrangement set sortx, category k represents the set of elements to be divided when performing the k-th classification, and the label value xpole is 1 for the first classification. Step 52: Establish an X grid line set xseg = [xseg1, ..., xsegk, ..., xsegm], calculate the average value of all elements in category k and assign the average value to the k-th element xsegk in the X grid line set xseg, and reassign the label value xpole: label value xpole = xsegk + xdistance, then increase the number of divisions k by 1, and continue with step 51; Step 53: Interpolate the X grid line set xseg: If the difference between two adjacent elements in the X grid line set xseg is several times greater than xdistance, then s new elements are inserted between the two adjacent elements on average to form a new X grid line set xseg, where s = {the difference between the two adjacent elements / xdistance} - 1; If the difference between two adjacent elements in the X grid line set xseg is not an integer multiple of xdistance, no difference processing is performed; Among them, {} represents the rounding operation; Step 54: Perform the f-th classification on all elements in the Y-axis arrangement set sorty: If the value of an element in the Y-axis arrangement set sorty is in the range [ypole-ydistance / 2,ypole+ydistance / 2], then the element is classified from the Y-axis arrangement set sorty into category f; If the value of an element in the Y-axis arrangement set sorty is not in the range [ypole-ydistance / 2,ypole+ydistance / 2], the element will not be divided out; If all elements in the Y-axis arrangement set sorty are sorted out, proceed to step 56; Where ydistance represents the average pixel spacing between the dots in the positive binary image bw2′ in the y direction, f represents the ordinal number of the element classification by the Y-axis arrangement set sorty, category f represents the set of elements divided when the f-th classification is performed, and the label value ypole is 1 for the first classification. Step 55: Establish a Y grid line set yseg = [yseg1, ...ysegf ...ysegq], calculate the average value of all elements in category f and assign the average value to the f-th element ysegf in the Y grid line set yseg, and reassign the label value ypole: label value ypole = ysegf + ydistance, then increase the number of divisions f by 1, and continue with step 54; Step 56: Interpolate the Y grid line set yseg: If the difference between two adjacent elements in the Y grid line set yseg is several times greater than ydistance, then t new elements are inserted between the two adjacent elements on average to form a new Y grid line set yseg, where t = {the difference between the two adjacent elements / ydistance} - 1; If the difference between two adjacent elements in the Y grid line set yseg is not a multiple of ydistance, no difference processing is performed; Among them, {} represents the rounding operation.
Citation Information
Patent Citations
Quick eye locating method based on integral projection and edge detection
CN103218605A
Following robot gesture track recognition method based on hand speed and track distribution
CN110232308A