Automatic cropping method for ferrite complete recrystallization structure images
Through the pixel calculation and first-order derivative judgment of ferrite completely recrystallized tissue pictures, automatic cropping is achieved, solving the problems of low manual cutting efficiency and poor accuracy, and is suitable for tissue picture processing of pure ferrite steel materials.
Patent Information
- Application Number
- CN202111375826.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2041-11-19
AI Technical Summary
In the prior art, the manual cutting efficiency of ferrite completely recrystallized tissue pictures is low and inaccurate, which affects the detection results.
By calculating the pixels of the photo, the boundaries of the area to be observed are automatically identified and cropped, and the computer program is used to realize automatic cropping, and the image processing is performed using Python, Java, Visual Basic, C++ and other languages to obtain the line-by-line pixels and the boundary coordinates are judged using the first derivative.
It realizes efficient, accurate and automatic cutting of ferrite complete recrystallization tissue pictures, avoids artificial errors, and is suitable for tissue picture processing of pure ferrite steel materials.
Smart Images

Figure CN114240842B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic processing of steel metallographic images, and in particular to a method for automatically cutting out ferrite complete recrystallization structure images. Background Art
[0002] As an important functional material among steel materials, silicon steel plays an irreplaceable role in the electronics and power industries. To continuously improve the performance of silicon steel, metallographic structure testing, as a basic and important testing method, is frequently and widely used in production and scientific research.
[0003] In the process of metallographic inspection and analysis, the more important reference basis is the national standard GB / T6394-2002 "Method for Determination of Average Grain Size of Metals". Silicon steel sheets are relatively thin (the most common range of thickness distribution is 0.15mm to 0.70mm), so when taking metallographic pictures, interference areas outside the non-observation area are included. In order to more accurately analyze the tissue pictures, it is necessary to crop out the non-observation areas on the upper and lower sides. Currently, the main method in the cropping process is manual processing, which is inefficient. The cropping process is mixed with human subjective factors. If the cropping is too much, the useful analysis area will be removed, resulting in the loss of useful image information, while if the cropping is too little, useless information will be included. Both situations will have an adverse effect on the final analysis. The above problems are more prominent when there are more pictures; a search of patents in related fields shows the following patents:
[0004] The Chinese invention patent application number: CN202010285063.1 discloses a method, system, computer device and storage medium for intelligent image cropping. The method includes: first detecting whether there is a face in the image. If there is a face, further verifying the validity of the target, verifying the quantity, size, position and other information. If it is too small or at the edge of the image, discarding it; if there is a valid face, calculating the range of the key feature area based on the face information; if there is no valid face, detecting whether there is a body. If a body is detected, further detecting the target validity; if there is a valid body, calculating the key feature area of the image based on the body information; if no valid body is detected, performing saliency detection on the image, and then calculating the key feature area in the image, and finally cropping the image according to the key feature area and the required size. The present invention has the technical characteristics of fast cropping speed, precision, intelligence, and flexible use.
[0005] The Chinese invention patent application number CN201410535102.3 discloses an automatic cropping method based on image recognition, the method comprising:
[0006] (1) Image preprocessing;
[0007] (2) Face recognition;
[0008] (3) Background identification;
[0009] (4) Adaptive interception;
[0010] This invention uses a recognition-based approach to crop images, providing a percentage of the cropped image relative to the original. This invention requires no human intervention, boasts a simple algorithm, and offers high reliability. Different strategies can be employed to meet the needs of different web page display requirements. This invention can be used to crop a set of images, selecting the successfully cropped image as the display image, with an accuracy rate of 99.8%. This invention has also been applied to cropping images for news and microblog pages, achieving an accuracy rate of 99.5% in manual testing.
[0011] The Chinese invention patent application number CN202011224851.6 discloses a method and device for verifying the cropping of advertising material images. The method includes: when an application enters a page to be tested, obtaining page display data corresponding to the page to be tested from a mock server, wherein the page to be tested includes an advertising material area, and the page display data includes an advertising material image that has been dotted, and the advertising material image is displayed in the advertising material area; displaying the page to be tested according to the page display data; taking a screenshot of the advertising material area in the page to be tested to obtain an advertising material screenshot image; comparing the advertising material screenshot image with the advertising material image, and determining whether the advertising material image is cropped based on the comparison result, which can improve testing efficiency.
[0012] The Chinese invention patent with application number: CN202010251636.9 discloses an image processing method, device, electronic device and computer-readable medium. The specific implementation of the method includes: detecting the object displayed in the target image to obtain object information, the object information including range information and object category information for characterizing the display range of the object; constructing a score map based on the object information, in which the values at the corresponding positions of the display ranges of objects of different categories in the score map are different; determining the cropping area based on the sum of the values at the corresponding positions of the display ranges of different objects represented by different object category information; cropping the target image based on the image cropping information and the score map to generate a cropped image. The cropping method of this implementation method, which distinguishes according to the degree of importance, improves the pertinence of image cropping and enhances the user experience.
[0013] The Chinese invention patent with application number: CN202010974055.8 discloses a method for intelligently screening fully transparent pictures, which includes the following steps: cropping the picture into small pictures of the same size according to the size of the picture; numbering the small pictures of the same size, and performing transparency judgment on the small pictures in turn; establishing two folders, the folder names are transparent picture folder and project resource folder, if the transparency of the small picture is judged to be a transparent picture, the picture is saved in the folder named transparent picture, if the transparency of the small picture is judged to be a non-transparent picture, the picture is saved in the folder named project resource; after all pictures have completed the transparency judgment and classified, the pictures in the two folders are judged in turn, if a non-transparent picture is detected in the transparent picture folder, the picture is saved in the project resource folder; randomly select pictures according to the numbers on the pictures for detection to check whether the transparency of the pictures is judged incorrectly. Summary of the Invention
[0014] The present invention addresses the problem of low efficiency and inaccuracy in manual cropping during the preprocessing of ferrite completely recrystallized structure photos, and provides an automatic cropping method for ferrite completely recrystallized structure photos. The method calculates the pixels of the photo, determines the edge of the area to be observed, and automatically crops the photo. The method processes the photo efficiently and accurately, completely avoiding the influence of factors such as human inaccuracy, and is suitable for processing structure photos of pure ferrite steel materials after complete recrystallization.
[0015] To achieve the above object, the present invention provides a method for automatically cropping a ferrite fully recrystallized structure image, comprising the following steps:
[0016] 1) Obtain metallographic photos
[0017] A metallographic photograph is obtained by conventional metallographic production (the photograph requires a clear surface, no obvious black spots or water stains, clear grain boundary edges, and the metallographic image of the target sample should be located at or as close as possible to the vertical center of the entire photograph, and the boundary position in the photograph should be basically in a horizontal state);
[0018] 2) Photo preprocessing
[0019] Convert the obtained metallographic photos into grayscale images;
[0020] 3) Photo pixel summation
[0021] a. Convert the photo into a two-dimensional array and store it. The two-dimensional array is denoted as O. The number of rows in the two-dimensional array is the height of the original image, and the number of columns is the width of the original image. Calculate the average value of the array value and record the obtained average value as the average brightness Pix ave ;
[0022] b. Compare each value in the two-dimensional array O with the average brightness Pix ave Compare and judge, compare, judge and convert all data points in the two-dimensional array O according to the above method, and get a new two-dimensional array with the same number of rows and columns, denoted as N. Calculate the sum of the values of each row of the two-dimensional array N in units of rows, denoted as f(h), where
[0023] h is the number of rows, h is 1, 2, 3, 4, 5, 6...;
[0024] It should be emphasized here that the data O and array N are both converted from the original image in different ways. The number of rows of data O and N is the height of the original image, and the number of columns is the width of the original image.
[0025] 4) Boundary judgment and determination
[0026] Consider f(h) obtained from the above steps as the dependent variable, and the number of rows h of the two-dimensional array as the independent variable. Calculate the absolute value of the first-order derivative of the function f(h) to obtain the row-wise gradient value f(h)'; analyze and judge f(h)':
[0027] Starting from the middle row of the two-dimensional data, we will get the first maximum value of the derivative change, which is the upper border value and the lower border value. Record the corresponding h value and use h as the value. up and h down express;
[0028] 5) Image cropping
[0029] Set the minimum width of the metallographic image in step 1) to 0 and the maximum width to w, and the upper boundary coordinate h obtained in step 4) up and the lower boundary coordinate h down The four coordinate points are used as the clipping points, and the metallographic image in step 1) is clipped at these positions in the horizontal and vertical directions to obtain the clipped target area image.
[0030] Furthermore, in step 2), the brightness of the grayscale image is 130-160.
[0031] Furthermore, in step 3) b, the determination method is as follows:
[0032] When the value in the two-dimensional array O is lower than Pix ave , change the value to 1.
[0033] Or, when the value in the two-dimensional array O is greater than or equal to Pix ave , change the value to 0.
[0034] The principle of the method provided by the present invention is described below.
[0035] The method of the present invention is suitable for cropping and processing the microstructure images of pure ferritic silicon steel after complete crystallization. The grains of the completely annealed and recrystallized microstructure of ferrite present a similar equiaxed shape. Under a conventional optical metallographic microscope, the interior of the grains appears grayish white, while the grain boundaries appear grayish black. The contrast between the two colors is quite different, which is an important prerequisite for the feasibility of the method of the present invention.
[0036] A second advantage of the present method is a clear demarcation line. During the specimen inlay process, whether a single specimen or multiple specimens are stacked together, the gaps between the specimens are filled with inlay material. When the specimen is iron-based and the inlay material is an organic non-metallic material, a distinct demarcation line appears under an optical microscope at the contact point between the two materials, appearing dark gray-black in color.
[0037] The third advantage is that in practical applications, the tissue photographs taken are square or rectangular images, and the processed images are based on the original images by horizontally cropping the upper and lower edges to remove useless areas. This is also one of the advantages of the method of the present invention.
[0038] The present invention utilizes the difference between the border and the base color in the photo, and the fact that the target photo is square, and automatically identifies the border and then crops the photo in combination with the method of the present invention.
[0039] The necessary steps in the method of the present invention are described in detail below.
[0040] As mentioned in step 1), the metallographic photographs taken should be as clear as possible, without obvious and large black spots or water stains. The reason is that black spots and water stains are darker in color, similar to the black color of the gaps between the inlay and the specimen, or between specimens. This will cause interference when calculating pixel values by row, thereby affecting the accuracy of boundary judgment, especially when there are more black spots or water stains.
[0041] Step 2) Photo preprocessing: This step converts the captured photo into a single grayscale image. Removing the color channels from the photo facilitates pixel value calculation and speeds up the determination of photo boundaries. This is especially true when the metallographic photo appears green or yellowish-brown due to the effects of filters. Grayscale processing is necessary first.
[0042] Steps 3) and 4) are the key points of this method. The principle of this method is as described above. The color of the boundary and normal tissue is significantly different, but the difference varies slightly depending on the tissue and requires further processing and judgment. After processing in steps 1) and 2), the grayscale and brightness of the photo have reached the requirements of this method. The color of the photo is removed and converted to grayscale, and then further converted into a two-dimensional array with the same height and width as the photo. This digitizes the image values and allows subsequent mathematical operations to be performed. The purpose of calculating the average brightness value of the entire image is to provide a reference for determining the boundary. This value is an important basis for boundary judgment. Because the black boundary in the image is relatively narrow and small relative to the area of the grain region in the tissue, it will not have a substantial impact on the average brightness of the entire image. All pixels in the image are compared with the average brightness value and replaced accordingly. The purpose is to prevent the normal area and the boundary from producing a large gradient when the pixel values are subsequently calculated and summed row by row. It is recommended that the values after pixel replacement be 0 and 1 (or other non-zero values). This produces a large gradient value variation, making it easier to accurately judge. To determine the gradient, the method uses a first-order derivative, treating the sum of the row-by-row pixels and the image height as the dependent and independent variables, respectively. Starting at half the image height, the method proceeds upward and downward row by row, finding the rows with the largest gradient changes. The resulting upper and lower row coordinates are then considered the upper and lower boundaries for cropping the image. The resulting upper and lower boundary values, along with the original image width, total four points, which are the cropping coordinates of the target area in the original image. Cropping according to these coordinates yields the target image.
[0043] In addition, the first point with the largest change in the derivative is found upward and downward from the middle of the array, which is the upper and lower boundaries of the image. The reason is that when the sample boundary is narrow, the point with the largest and smallest changes may be one point; but when the upper and lower boundaries are wide, multiple points with the largest change in the derivative will be generated, and only one of these points is the target boundary, that is, the first point with the largest change found in the upward or downward direction.
[0044] The method of the present invention judges row by row, both upward and downward, from the middle position of the image along the height direction. Therefore, the sample photo taken is required to be located as close to the middle of the entire image height as possible to avoid the situation where the photo field of view contains multiple target sample metallographic images and thus multiple boundaries when the sample is relatively thin, which would interfere with the subsequent boundary judgment. It is specifically noted here that the method described in the present invention is not suitable for cropping a photo containing two or more samples to be observed at the same time. However, using the principle of the method of the present invention, after adjustment, it can be applied to cropping photos containing two or more samples to be observed.
[0045] Beneficial effects of the present invention:
[0046] This method calculates the pixels in a photo to determine the boundary coordinates of the area to be observed and automatically crops the image. This entire process requires implementation through a computer program or programming language, achieving the goal of automatic, batch photo processing. Popular languages such as Python, Java, Visual Basic, and C++ can be used to calculate the automatic brightness of an image and determine the row-by-row pixel sums. The concepts in this method are then implemented using the language to determine the row-by-row pixel sums. The corresponding functions in the language are then used to perform the derivation according to the method's requirements. Pixel change points are then determined row by row to determine the boundary coordinates and perform cropping. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 The original image of the tissue photograph to be cropped in Example 1 (there is a complete sample metallographic image in the middle of the image, with upper and lower boundaries);
[0048] Figure 2 The process and results of the method of the present invention in Example 1 are as follows
[0049] In the figure, a is the area to be cropped, and the yellow dotted box is the target cropping boundary.
[0050] b is a schematic diagram of the boundary between samples in Example 1
[0051] c is the metallographic image in Example 1 converted into an array and processed, the data of each row is calculated and the derivative is obtained, and the data and the derivative are plotted, where h up and h down The maximum number of rows of derivative changes, which is determined as the upper and lower boundaries of the metallographic image in Example 1
[0052] d is the final image of the metallographic image in Example 1 after boundary clipping determined by the method of the present invention. DETAILED DESCRIPTION
[0053] The present invention is further described in detail below with reference to specific embodiments so that those skilled in the art can understand.
[0054] The method for automatically cropping a ferrite fully recrystallized structure image includes the following steps:
[0055] 1) Obtain metallographic photos
[0056] The sample with a thickness of 0.5 mm was selected, and the structure was pure ferrite completely recrystallized structure. The tissue photos taken ( Figure 1 ), which is conventional metallographic; in the conventional metallographic process, Python programming language is used, and the corresponding image library function in the language is called, and the metallographic photo is obtained by reading it through Python code, and its width and height are 1513pix×1133pix respectively;
[0057] The conventional metallographic process is used to obtain metallographic photographs;
[0058] 2) Photo preprocessing
[0059] For the obtained metallographic photos, the corresponding image processing library was called using the Python programming language to read the pixel data, convert the images into grayscale images, and adjust the average brightness to 151;
[0060] 3) Photo pixel summation
[0061] a. Use Python programming language to convert the adjusted metallographic photo into a two-dimensional array and store it. The two-dimensional array is denoted as O (see Table 1). The number of rows in the two-dimensional array is the height of the original image, and the number of columns is the width of the original image. Calculate the average value of the array value and record it as the average brightness Pix ave ;
[0062] b. Compare each value in the two-dimensional array O with the average brightness Pix ave For comparison:
[0063] When the value in the two-dimensional array O is lower than Pix ave , change the value to 1.
[0064] Or, when the value in the two-dimensional array O is greater than or equal to Pix ave When , change the value to 0;
[0065] Compare, judge and transform all data points in the two-dimensional array O in turn according to the above method to obtain a new two-dimensional array with the same number of rows and columns, denoted as N (see Table 2). The sum of the values of each row of the two-dimensional array N is obtained in units of rows, denoted as f(h), where
[0066] h is the number of rows, h is 1, 2, 3, 4, 5, 6...;
[0067] It should be emphasized here that the data O and array N are both converted from the original image in different ways. The number of rows of data O and N is the height of the original image, and the number of columns is the width of the original image.
[0068] 4) Boundary judgment and determination
[0069] Consider f(h) obtained from the above steps as the dependent variable, and the number of rows h of the two-dimensional array as the independent variable. Calculate the absolute value of the first-order derivative of the function f(h) to obtain the row-wise gradient value f(h)'; analyze and judge f(h)':
[0070] Starting from the middle row of the two-dimensional data, we will get the first maximum value of the derivative change, which is the upper border value and the lower border value. Record the corresponding h value and use h as the value. up and h downIn this embodiment, h up and h down They are 92 and 1013 respectively, see Table 3.
[0071] 5) Image cropping
[0072] Set the minimum width of the metallographic image in step 1) to 0 and the maximum width to w, and the upper boundary coordinate h obtained in step 4) up and the lower boundary coordinate h down As the four coordinate points for clipping, namely the upper left corner coordinate (0, 92) and the lower right corner coordinate (1513, 1013), the metallographic image in step 1) is clipped at this position in the horizontal and vertical directions to obtain the clipped target area image, see ( Figure 2 d).
[0073] Table 1 Data conversion process table, array O (partial data)
[0074]
[0075] Table 2 Data conversion process table, array N (partial data)
[0076]
[0077] Table 3 Upper and lower boundaries found (partial data)
[0078]
[0079]
[0080] This embodiment illustrates only one specific case, using Python for processing. This example is not exhaustive, and the programming languages used are not limited to those used in this example. Any program generated using the processing methods and ideas of the present invention, as well as any programming language, is protected by this patent.
[0081] Although the above embodiments have been described in detail, they are only a part of the embodiments of the present invention, not all of them. People can also obtain other embodiments based on this embodiment without inventiveness, and these embodiments all fall within the scope of protection of the present invention.
Claims
1. A method for automatically cutting out a picture of a completely recrystallized ferrite structure, characterized by: The following steps are involved: 1) Obtain metallographic photos The conventional metallographic process is used to obtain metallographic photographs; 2) Photo preprocessing Convert the obtained metallographic structure photos into grayscale images; wherein the brightness of the grayscale images is 130 to 160; 3) Photo pixel summation a. Convert the photo into a two-dimensional array and store it. The two-dimensional array is denoted as O. The number of rows in the two-dimensional array is the height of the original image, and the number of columns is the width of the original image. Calculate the average value of the array value and record the obtained average value as the average brightness Pix ave ; b. Compare each value in the two-dimensional array O with the average brightness Pix ave Compare and judge, compare, judge and convert all data points in the two-dimensional array O according to the above method, and get a new two-dimensional array with the same number of rows and columns, denoted as N. Calculate the sum of the values of each row of the two-dimensional array N in units of rows, denoted as f(h), where h is the number of rows, h is 1, 2, 3, 4, 5, 6...; It is important to emphasize here that data O and array N are both converted from the original image in different ways. The number of rows of data O and N is the height of the original image, and the number of columns is the width of the original image. The judgment method is as follows: When the value in the two-dimensional array O is lower than Pix ave , change the value to 1. Or, when the value in the two-dimensional array O is greater than or equal to Pix ave When , change the value to 0; 4) Boundary judgment and determination Consider f(h) obtained from the above steps as the dependent variable, and the number of rows h of the two-dimensional array as the independent variable. Calculate the absolute value of the first-order derivative of the function f(h) to obtain the row-wise gradient value f(h)'; analyze and judge f(h)': Starting from the middle row of the two-dimensional data, we will get the first maximum value of the derivative change, which is the upper border value and the lower border value. Record the corresponding h value and use h as the value. up and h down express; 5) Image cropping Set the minimum width of the metallographic image in step 1) to 0 and the maximum width to w, and the upper boundary coordinate h obtained in step 4) up and the lower boundary coordinate h down The four coordinate points are used as the clipping points, and the metallographic image in step 1) is clipped at these positions in the horizontal and vertical directions to obtain the clipped target area image.
Citation Information
Patent Citations
Image-identification-based automatic cutting method
CN104392202A
Image processing methods, apparatus, electronic devices, and computer-readable media
CN111461965B
Intelligent picture cutting method and system, computer equipment and storage medium
CN111524145A
Method for intelligently screening full-transparent pictures
CN112308088A
Advertisement material picture cutting verification method and device
CN112329854A