A spine image correction method based on image straight line segment information
By segmenting and detecting straight line segments on the spine image, and combining rotation and perspective transformation matrices for correction, the problem of torsion, rotation and perspective distortion of the spine image is solved, and the accuracy and reliability of automated library inventory are improved.
Patent Information
- Application Number
- CN202311398142.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-10-26
AI Technical Summary
It is difficult for the existing technology to effectively solve the problems of torsion distortion, perspective distortion, rotation distortion and corner distortion that occur during the collection and segmentation process of book spine images, which affects the library's automated inventory and book management.
By obtaining the original image, perform segmentation processing and straight line segment detection, calculate the approximate straight line segment group and rotation transformation matrix, perform rotation transformation and affine transformation, correct the image by combining the perspective transformation matrix, identify the invalid area for cropping, and obtain the corrected spine image.
It effectively solves the problems of torsion distortion, rotation distortion and perspective distortion of the spine image, improves the accuracy of image processing and the reliability of automated inventory, and reduces the pressure of subsequent processing.
Smart Images

Figure CN117333374B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a spine image correction method based on image straight line segment information. Background Art
[0002] Currently, during the inventory process of books in the library, it is necessary to take a photo of the spine of each book, which is not feasible due to equipment and time limitations.
[0003] Therefore, existing solutions often use image acquisition equipment to capture the spines of multiple books on the shelf based on a digital image, and segment the digital image through various digital signal processing, machine learning or deep learning methods to obtain the spine image of each book.
[0004] The acquired book spine images usually have the following four types of distortion:
[0005] Since books are non-rigid solids, they often have torsion in length, width, and height due to factors such as placement, squeezing by adjacent books, and aging of bindings. This causes the image of the spine after collection and segmentation to not always be a simple parallelogram compared to the true image of a pure plane, resulting in torsion distortion;
[0006] Perspective distortion occurs when the projection of the spine of a book on the image acquisition plane deviates from the center of the plane due to perspective relationship;
[0007] When the book is tilted, there is a linear rotation deviation between the collected and segmented image and the true image value, resulting in rotation distortion;
[0008] When the segmentation model segments the spines of books with a large tilt angle relative to the bookshelf in an image containing multiple spines, due to the limitations of various algorithms themselves, the resulting mask area does not always contain all the edges and edge corners of the spine, resulting in corner distortion.
[0009] The above-mentioned torsion distortion, perspective distortion, rotation distortion and corner distortion interfere with downstream tasks such as classification recognition and optical character recognition (OCR) in book management based on image processing, affecting the library's automated library building and inventory.
[0010] Based on the above distortion problem, CN104966081B "Spine Image Recognition Method" proposes to obtain edge segments through LSWMS edge detection, and obtain a pair of parallel long segments as the long edge lines of the spine after a series of filtering operations. This method regards the book as a rigid body with parallel length, width and height edges, and it is difficult to solve the "torsion distortion" problem; CN112116611B "A spine segmentation and text recognition system and method" calculates the average angle value of the global straight line after fitting, and only performs affine rotation transformation on the plane, and simply considers the obtained spine projection center on the digital image acquisition plane to be approximately coincident with the center of the acquisition plane. Although it can approximately solve the "rotation distortion", it is still difficult to solve the "perspective distortion" problem; CN111401252A "A spine matching method based on a visual book inventory system" extracts the four edge corner points of the spine through the ORB algorithm for perspective transformation. This method believes that the obtained spine image contains all the edge lines and edge corner points of the spine, but it is difficult to solve the "corner distortion" problem.
[0011] Therefore, a spine image correction method based on image straight line segment information is proposed. Summary of the invention
[0012] In order to solve the above technical problems, the present invention provides a spine image correction method based on image straight line segment information, so as to solve the problems of torsion distortion, perspective distortion, rotation distortion and corner distortion of the collected spine image.
[0013] An embodiment of the present invention provides a spine image correction method based on image straight line segment information, comprising:
[0014] Get the original image;
[0015] Performing segmentation processing on the original image to obtain an original segmented image;
[0016] Acquire a segmentation mask of the original segmented image, and calculate a mask edge curve of the segmentation mask;
[0017] Calculating a group of approximate straight line segments of the original segmented image according to the mask edge curve;
[0018] Calculating a linear rotation transformation matrix according to the inclination data of each straight line segment in the approximate straight line segment group;
[0019] Performing a rotation transformation on the original segmented image according to the linear rotation transformation matrix to obtain a segmentation transformation image;
[0020] Performing affine transformation processing on the segmented transformation image to obtain a coarsely corrected segmented image;
[0021] Preprocessing the coarsely corrected segmented image to obtain a preprocessed segmented image;
[0022] Detect the straight line segment information of the preprocessed segmented image by a straight line segment detection model, and construct a horizontal straight line segment group and a vertical straight line segment group;
[0023] Based on the horizontal straight line segment group and the vertical straight line segment group, obtaining a slope parameter of the perspective transformation;
[0024] According to the slope parameter, constructing a minimum circumscribed quadrilateral as a perspective transformation quadrilateral for the preprocessed segmented image, taking the vertices of the perspective transformation quadrilateral as perspective transformation corner points, and calculating a perspective transformation matrix;
[0025] Performing perspective transformation on the coarse corrected segmented image by using the perspective transformation matrix to obtain a perspective segmented image;
[0026] The invalid area of the perspective segmented image is identified and cropped to obtain a corrected spine image.
[0027] Preferably, a spine image correction method based on image straight line segment information, the step of obtaining a segmentation mask of the original segmented image and calculating a mask edge curve of the segmentation mask comprises:
[0028] Performing grayscale processing on the original segmented image to obtain a grayscale segmented image;
[0029] Performing noise reduction processing on the grayscale segmented image to obtain a noise-reduced grayscale segmented image;
[0030] Binarizing the denoised grayscale segmented image using a high threshold parameter to obtain an approximate binary mask;
[0031] Performing corrosion processing and median filtering processing on the binary mask to obtain the segmentation mask;
[0032] The edge detection is performed on the segmentation mask based on an edge detection algorithm to obtain the mask edge curve.
[0033] Preferably, a spine image correction method based on image straight line segment information, the step of calculating the approximate straight line segment group of the original segmented image according to the mask edge curve, comprises:
[0034] Performing transformation processing on the mask edge curve to obtain a transformed straight line segment group;
[0035] Multiplying the height of the original segmented image by a preset ratio to obtain a dynamic length threshold;
[0036] The transformed straight line segment group is filtered according to the dynamic length threshold to obtain the approximate straight line segment group.
[0037] Preferably, a spine image correction method based on image straight line segment information, the step of calculating a linear rotation transformation matrix according to the inclination data of each straight line segment in the approximate straight line segment group, comprises:
[0038] Calculating the slope of each straight line segment of the approximate straight line segment group by the rotation angle, and calculating the inclination data of each straight line segment by the slope of each straight line segment;
[0039] The maximum value of the inclination angle data is obtained, and the linear rotation transformation matrix is constructed.
[0040] Preferably, a spine image correction method based on image straight line segment information, the step of: performing a rotation transformation on the original segmented image according to the linear rotation transformation matrix to obtain a segmented transformation image, comprises:
[0041] Create a canvas;
[0042] Assume that the width of the canvas is W, the height is H, the rotation angle is α, the width of the original segmented image is w, and the height is h, then the expressions of W and H are:
[0043] W=h·sinα+w·cosα
[0044] H=h·cosα+w·sinα
[0045] The segmentation transformation image is rotationally transformed on the canvas according to the linear rotation transformation matrix to obtain the segmentation transformation image.
[0046] Preferably, a spine image correction method based on image straight line segment information, the step of: performing affine transformation processing according to the segmentation transformation image to obtain a coarse correction segmentation image, comprises:
[0047] Calculating distance data between the center point of the canvas and the center point of the segmented transformation image, and calculating an affine transformation matrix according to the distance data;
[0048] Performing an affine transformation operation on the segmented transformation image according to the affine transformation matrix to obtain an affine transformation image;
[0049] Identifying a valid portion of the affine transformed image and constructing a minimum bounding rectangle;
[0050] The affine transformed image is cropped with the minimum circumscribed rectangle as a boundary to obtain the roughly corrected segmented image.
[0051] Preferably, a spine image correction method based on image straight line segment information, the step of preprocessing the coarsely corrected segmented image to obtain a preprocessed segmented image, comprises:
[0052] Acquire the coarsely corrected segmented image;
[0053] Performing contrast enhancement processing on the coarsely corrected segmented image to obtain an enhanced segmented image;
[0054] Performing edge sharpening processing on the enhanced segmented image to obtain a sharpened enhanced segmented image;
[0055] The sharpened and enhanced segmented image is subjected to tensorization processing to obtain a preprocessed segmented image.
[0056] Preferably, a spine image correction method based on image straight line segment information, the step of: detecting the straight line segments of the preprocessed segmented image by a straight line segment detection model, and constructing a horizontal straight line segment group and a vertical straight line segment group, comprises:
[0057] Detecting the straight line segments of the preprocessed segmented image by a straight line segment detection model;
[0058] Calculating the slope of the straight line segment in the preprocessed segmented image, and obtaining the inclination data of the straight line segment in the preprocessed segmented image; when the inclination data is less than a preset inclination threshold, classifying the straight line segment as a horizontal straight line segment; when the inclination data is greater than the preset inclination threshold, classifying the straight line segment as a vertical straight line segment;
[0059] A horizontal straight line segment group is constructed according to the horizontal straight line segments in the preprocessed component image, and a vertical straight line segment group is constructed according to the vertical straight line segments in the preprocessed component image.
[0060] Preferably, a spine image correction method based on image straight line segment information, the step of obtaining the slope parameter of the perspective transformation based on the horizontal straight line segment group and the vertical straight line segment group, comprises:
[0061] Identify the positions of the horizontal straight line segments in the horizontal straight line segment group in the preprocessed segmented image, and construct a group of horizontal straight line segments in an upper region of the image and a group of horizontal straight line segments in a lower region of the image respectively;
[0062] Calculate the slopes of all horizontal straight line segments in the horizontal straight line segment group in the image area, and calculate the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; count the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment group in the image area, and use the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the upper straight line slope parameter of the perspective transformation;
[0063] Calculating the slopes of all horizontal straight line segments in the horizontal straight line segment group in the lower area of the image, and calculating the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; counting the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment group in the lower area of the image, and taking the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the lower straight line slope parameter of the perspective transformation;
[0064] Identify the positions of the vertical straight line segments in the vertical straight line segment group in the preprocessed segmented image, and construct a vertical straight line segment grouping in the left region of the image and a vertical straight line segment grouping in the right region of the image respectively;
[0065] Calculating the slopes of all vertical straight line segments in the vertical straight line segment group in the left area of the image, calculating the corresponding vertical straight line segment inclination angle according to the slope of the vertical straight line segment, performing fitting processing on the vertical straight line segments with similar vertical straight line segment inclination angles, and selecting the slope of the vertical straight line segment with the longest line segment in the vertical straight line segment group in the left area of the image as the left straight line slope parameter of the perspective transformation;
[0066] Calculate the slopes of all vertical straight line segments in the vertical straight line segment group in the right area of the image, calculate the corresponding vertical straight line segment inclination according to the slope of the vertical straight line segment, perform fitting processing on the vertical straight line segments with approximate vertical straight line segment inclinations, and select the slope of the vertical straight line segment with the longest line segment in the vertical straight line segment group in the right area of the image as the right straight line slope parameter of the perspective transformation.
[0067] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0068] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A schematic diagram of the structure of a spine image correction method based on image straight line segment information provided by the present invention;
[0070] Figure 2 An original segmented image provided by a specific embodiment of the present invention;
[0071] Figure 3 A corrected book spine image according to a specific embodiment of the present invention;
[0072] Figure 4 An original segmented image according to another specific embodiment of the present invention;
[0073] Figure 5 Another specific embodiment of the present invention provides a corrected book spine image. DETAILED DESCRIPTION
[0074] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0075] The embodiment of the present invention provides a spine image correction method based on image straight line segment information, referring to Figure 1 ,include:
[0076] Get the original image;
[0077] Perform segmentation processing on the original image to obtain the original segmented image;
[0078] Obtain a segmentation mask of the original segmented image, and calculate a mask edge curve of the segmentation mask;
[0079] According to the mask edge curve, calculate the approximate straight line segment group of the original segmented image;
[0080] Calculate the linear rotation transformation matrix according to the inclination data of each straight line segment in the approximate straight line segment group;
[0081] Performing a rotation transformation on the original segmented image according to the linear rotation transformation matrix to obtain a segmentation transformation image;
[0082] Performing affine transformation processing on the segmentation transformation image to obtain a coarsely corrected segmentation image;
[0083] Preprocessing the coarsely corrected segmented image to obtain a preprocessed segmented image;
[0084] The straight line segment information of the preprocessed segmented image is detected by a straight line segment detection model, and a horizontal straight line segment group and a vertical straight line segment group are constructed;
[0085] Based on the horizontal straight line segment group and the vertical straight line segment group, a slope parameter of the perspective transformation is obtained;
[0086] According to the slope parameter, the minimum circumscribed quadrilateral is constructed for the preprocessed segmented image as the perspective transformation quadrilateral, and the vertices of the perspective transformation quadrilateral are used as perspective transformation corner points to calculate the perspective transformation matrix;
[0087] Performing perspective transformation on the coarse corrected segmented image through a perspective transformation matrix to obtain a perspective segmented image;
[0088] The invalid area of the perspective segmentation image is identified and cropped to obtain the corrected spine image.
[0089] The working principle of the book spine image correction method based on the image straight line segment information is as follows: by segmenting the original image containing multiple books, an original segmented image containing a single book is obtained; a segmentation mask of the original segmented image is obtained, and the mask edge curve is calculated; according to the mask edge curve, an approximate straight line segment group of the original segmented image is calculated, and the linear rotation transformation matrix is calculated through the inclination data of each straight line segment in the approximate straight line segment group; the original segmented image is rotated according to the linear rotation transformation matrix to obtain a segmentation transformation image; the segmentation transformation image is affinely transformed to obtain a coarse correction segmented image; the coarse correction segmented image is The segmented image is preprocessed to obtain a preprocessed segmented image; the straight line segment information of the preprocessed segmented image is detected by a straight line segment detection model, and a horizontal straight line segment group and a vertical straight line segment group are constructed; based on the horizontal straight line segment group and the vertical straight line segment group, a slope parameter of the perspective transformation is obtained; according to the slope parameter, a minimum circumscribed quadrilateral is constructed for the processed image as a perspective transformation quadrilateral, and the vertices of the perspective transformation quadrilateral are used as perspective transformation corner points to calculate the perspective transformation matrix; a perspective transformation is performed on the coarsely corrected segmented image by the perspective transformation matrix to obtain a perspective segmented image; and the invalid area of the perspective segmented image is identified for cropping to obtain a corrected spine image.
[0090] The above-mentioned spine image correction method based on image straight line segment information has the beneficial effects of: by segmenting the original image containing multiple books, the original segmented image containing a single book is obtained; according to the segmentation mask of the original segmented image, the mask edge curve is calculated to obtain the approximate straight line segment group, so that the acquisition of the approximate straight line segment does not depend on the edge line and edge corner points of the spine in the original segmented image, solving the problem of corner distortion in traditional technology; and the original segmented image is rotated according to the linear rotation transformation matrix, so that the deviation angle of rotation distortion is reduced to a preset deviation range, thereby having The problem of rotation distortion is effectively solved; the straight line segment information of the image is preprocessed based on global detection through the straight line segment detection model to construct horizontal straight line segment groups and vertical straight line segment groups, and further according to the slope parameter, the perspective transformation quadrilateral is constructed for the segmented transformation image to perform perspective transformation processing to solve the image torsion distortion, rotation distortion and perspective distortion problems; the above method regards the spine as a non-rigid body that can be twisted in three dimensions of length, width and height, and assumes that there is non-parallelism between the edge lines of the spine. A perspective transformation quadrilateral is constructed according to the straight line segment information detected by the straight line segment detection model to achieve correction processing of the spine image.
[0091] In one embodiment, the above method is applied to the automatic or semi-automatic inventory process of the library to correct the input original image, reduce the pressure of subsequent book image processing, and reduce the failure rate of image processing.
[0092] In one embodiment, the straight line segment detection model includes the SOLD2 model traditional line segment detection algorithm (such as LSD, FLD, MCMLSD, LSM, CannyLines, etc.) and the method based on the deep learning model algorithm implementation (such as LCNN, TP-LSD, Wireframe, etc.).
[0093] In a specific embodiment, the original segmented image is as follows: Figure 2 As shown in the figure, after being processed by the above method, the corrected spine image is obtained as Figure 3 As shown, the deviation angle of rotational distortion is reduced to within 4°.
[0094] In another specific embodiment, the original segmented image is as follows: Figure 4 As shown in the figure, after being processed by the above method, the corrected spine image is obtained as Figure 5 shown.
[0095] Embodiment 2:
[0096] A spine image correction method based on image straight line segment information, the steps are: obtaining a segmentation mask of an original segmented image, and calculating a mask edge curve of the segmentation mask, including:
[0097] Grayscale the original segmented image to obtain a grayscale segmented image;
[0098] Performing noise reduction processing on the grayscale segmentation image to obtain a noise-reduced grayscale segmentation image;
[0099] The denoised grayscale segmentation image is binarized by a high threshold parameter to obtain an approximate binary mask;
[0100] Performing corrosion processing and median filtering processing on the binary mask to obtain a segmentation mask;
[0101] The edge detection is performed on the segmentation mask based on the edge detection algorithm to obtain the mask edge curve.
[0102] In the above embodiments, the original segmented image is subjected to grayscale processing, noise reduction processing and binarization processing to obtain an approximate binary mask of the original segmented image; and the approximate binary mask is subjected to corrosion processing and median filtering processing to eliminate jagged edges and noise points of the approximate binary mask to obtain a segmentation mask with smoother edges, and the segmentation mask is subjected to edge detection based on an edge detection algorithm to obtain a mask edge curve.
[0103] In the above embodiments, the method for denoising the grayscale segmented image includes Gaussian blur smoothing, filter processing (such as median filter, adaptive LMS Wiener filter, etc.), mathematical modeling processing (such as with the help of sparse model, gradient model or Markov random field model), machine learning-based processing (such as through DnCNN, FFDnet, CBDnet, Neighbor2Neighbor and other deep learning models), and super-resolution processing (such as through interpolation or GAN adversarial generation network and other methods).
[0104] In the above embodiments, the edge detection algorithm includes an edge detection algorithm based on operator implementation (available operators include Sobel, Prewitt, Roberts, Marr-Hildreth, etc.) and an edge detection method based on a deep learning network implementation (such as the edge detection module of the SAM segmentation model).
[0105] Embodiment 3:
[0106] A spine image correction method based on image straight line segment information, the steps are: according to the mask edge curve, calculating the approximate straight line segment group of the original segmented image, including:
[0107] Performing transformation processing on the mask edge curve to obtain a transformation straight line segment group;
[0108] Multiply the height of the original segmented image by the preset ratio to obtain a dynamic length threshold;
[0109] The transformed straight line segment group is filtered according to the dynamic length threshold to obtain an approximate straight line segment group.
[0110] In the above embodiment, the mask edge curve is transformed to obtain the transformed straight line segment group, and the transformed straight line segment group is filtered according to the dynamic length threshold to obtain the approximate straight line segment group. The dynamic length threshold is obtained by multiplying the height of the original segmented image by a preset ratio, so that the approximate straight line segments in the approximate straight line segment group are all less than the dynamic length threshold, thereby removing the influence of interference information.
[0111] In the above embodiments, the mask edge curve transformation processing method includes the Hough transformation method.
[0112] Embodiment 4:
[0113] A spine image correction method based on image straight line segment information, the steps are: according to the inclination data of each straight line segment in the approximate straight line segment group, a linear rotation transformation matrix is calculated, including:
[0114] The slope of each straight line segment of the approximate straight line segment group is calculated by the rotation angle, and the inclination data of each straight line segment is calculated by the slope of each straight line segment;
[0115] Get the maximum value in the inclination data and construct a linear rotation transformation matrix.
[0116] In the above embodiment, the slope of each straight line segment of the approximate straight line segment group is calculated by the rotation angle, and the inclination data of each straight line segment is calculated by the slope of each straight line segment, and the maximum value of the inclination data is taken to construct a linear rotation transformation matrix.
[0117] The effect of the above technology is: the slope of each straight line segment in the approximate straight line segment group is calculated through the rotation angle, and the maximum value of the inclination data corresponding to the slope of each straight line segment is selected to obtain the linear rotation transformation matrix, and the original segmented image is further rotated according to the linear rotation transformation matrix to solve the rotation distortion problem of the original segmented image.
[0118] Embodiment 5:
[0119] A spine image correction method based on image straight line segment information, comprising the steps of: performing a rotation transformation on an original segmented image according to a linear rotation transformation matrix to obtain a segmented transformation image, including:
[0120] Create a canvas;
[0121] Assume the width of the canvas is W, the height is H, the rotation angle is α, the width of the original segmented image is w, and the height is h, then the expressions of W and H are:
[0122] W=h·sinα+w·cosα
[0123] H=h·cosα+w·sinα
[0124] According to the linear rotation transformation matrix, the segmentation transformation image is rotated on the canvas to obtain the segmentation transformation image.
[0125] In the above embodiment, a canvas is created according to the width, height and rotation angle of the original segmented image; and the segmented transformation image is rotationally transformed on the canvas through a linear rotation transformation matrix to obtain the segmented transformation image.
[0126] The beneficial effect of the above technology is that: according to the linear rotation transformation matrix, the segmentation transformation image is rotated and transformed on the canvas to achieve the acquisition of the segmentation transformation image.
[0127] Embodiment 6:
[0128] A spine image correction method based on image straight line segment information, the steps are: performing affine transformation processing according to the segmentation transformation image to obtain a coarse correction segmentation image, including:
[0129] Calculate the distance data between the center point of the canvas and the center point of the segmentation transformation image, and calculate the affine transformation matrix based on the distance data;
[0130] Performing an affine transformation operation on the segmented transformation image according to the affine transformation matrix to obtain an affine transformation image;
[0131] Identify the valid part of the affine transformed image and construct the minimum bounding rectangle;
[0132] The affine transformed image is cropped with the minimum circumscribed rectangle as the boundary to obtain a roughly corrected segmented image.
[0133] In the above embodiments, the affine transformation matrix is calculated by using the distance data between the center point of the canvas and the center point of the segmentation transformation image, and the segmentation transformation image is subjected to an affine transformation operation according to the affine transformation matrix to obtain the affine transformation image; based on the effective part of the affine transformation image, a minimum circumscribed rectangle is constructed to crop the affine transformation image to obtain a roughly corrected segmentation image.
[0134] The beneficial effects of the above technology are: the affine transformation matrix obtained by the distance data between the center point of the canvas and the center point of the segmented transformation image realizes the affine transformation processing of the segmented transformation image; and the invalid part of the affine transformation image is cut off by constructing a minimum circumscribed rectangle to obtain a roughly corrected segmented image, so as to realize the rotation distortion correction of the original segmented image.
[0135] Embodiment 7:
[0136] A spine image correction method based on image straight line segment information, the steps are: preprocessing the coarse correction segmentation image to obtain the preprocessed segmentation image, including:
[0137] Obtain a coarsely corrected segmented image;
[0138] Performing contrast enhancement processing on the coarsely corrected segmented image to obtain an enhanced segmented image;
[0139] Perform edge sharpening processing on the enhanced segmented image to obtain a sharpened enhanced segmented image;
[0140] The sharpened and enhanced segmented image is subjected to tensorization processing to obtain a preprocessed segmented image.
[0141] In the above embodiments, the rough-corrected segmented image is subjected to contrast enhancement, edge sharpening and tensor quantization processing to obtain a pre-processed segmented image.
[0142] The beneficial effect of the above technology is that by contrast enhancement and edge sharpening of the coarsely corrected segmented image, the edge features of the coarsely corrected segmented image are effectively extracted, and the sharpened and enhanced segmented image is tensorized to achieve preprocessing of the coarsely corrected segmented image, thereby facilitating the straight line segment detection model to detect the straight line segments in the preprocessed segmented image.
[0143] Embodiment 8:
[0144] A spine image correction method based on image straight line segment information, comprising the steps of: detecting straight line segments of a preprocessed segmented image through a straight line segment detection model, and constructing a horizontal straight line segment group and a vertical straight line segment group, including:
[0145] Detect straight line segments of the preprocessed segmented image using a straight line segment detection model;
[0146] Calculate the slope of the straight line segment in the preprocessed segmented image and obtain the inclination data of the straight line segment in the preprocessed segmented image; when the inclination data is less than the preset inclination threshold, the straight line segment is classified as a horizontal straight line segment; when the inclination data is greater than the preset inclination threshold, the straight line segment is classified as a vertical straight line segment;
[0147] A horizontal straight line segment group is constructed according to the horizontal straight line segments in the preprocessed segmented image, and a vertical straight line segment group is constructed according to the vertical straight line segments in the preprocessed component image.
[0148] In the above embodiments, the straight line segments of the preprocessed segmented image are detected by a straight line segment detection model, and the slope of the straight line segments in the preprocessed segmented image is calculated, and the corresponding inclination data is calculated according to the slope of the straight line segment; when the inclination data is less than the preset inclination threshold, the straight line segment is classified as a horizontal straight line segment; when the inclination data is greater than the preset inclination threshold, the straight line segment is classified as a vertical straight line segment, and a horizontal straight line segment group and a vertical straight line segment group are constructed respectively.
[0149] The beneficial effects of the above technology are: through the straight line segment detection model, the global straight line segment detection in the preprocessed segmented image is realized, and the slope of the straight line segment and the corresponding inclination data are calculated, the inclination data is judged and analyzed based on the preset inclination threshold, and the straight line segments are grouped into horizontal straight line segments and vertical straight line segments, thereby realizing the recognition and classification of the straight line segments in the preprocessed segmented image based on the global interval.
[0150] Embodiment 9:
[0151] A spine image correction method based on image straight line segment information, the steps are: based on a horizontal straight line segment group and a vertical straight line segment group, obtaining a slope parameter of a perspective transformation, including:
[0152] Identify the positions of the horizontal straight line segments in the horizontal straight line segment group in the preprocessed segmented image, and construct a horizontal straight line segment grouping in the upper region of the image and a horizontal straight line segment grouping in the lower region of the image respectively;
[0153] Calculate the slopes of all horizontal straight line segments in the horizontal straight line segment grouping in the image area, and calculate the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; count the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment grouping in the image area, and use the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the upper straight line slope parameter of the perspective transformation;
[0154] Calculate the slopes of all horizontal straight line segments in the horizontal straight line segment group in the lower area of the image, and calculate the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; count the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment group in the lower area of the image, and use the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the lower straight line slope parameter of the perspective transformation;
[0155] Identify the positions of the vertical straight line segments in the vertical straight line segment group in the preprocessed segmented image, and construct a vertical straight line segment grouping in the left region of the image and a vertical straight line segment grouping in the right region of the image respectively;
[0156] Calculate the slopes of all vertical straight line segments in the vertical straight line segment group in the left area of the image, calculate the corresponding vertical straight line segment inclination according to the slope of the vertical straight line segment, perform fitting processing on the vertical straight line segments with similar vertical straight line segment inclination, and select the slope of the vertical straight line segment with the longest line segment in the vertical straight line segment group in the left area of the image as the left straight line slope parameter of the perspective transformation;
[0157] Calculate the slopes of all vertical straight line segments in the vertical straight line segment group in the right area of the image, calculate the corresponding vertical straight line segment inclination according to the slope of the vertical straight line segment, fit the vertical straight line segments with similar vertical straight line segment inclinations, and select the slope of the longest vertical straight line segment in the vertical straight line segment group in the right area of the image as the right straight line slope parameter of the perspective transformation.
[0158] In the above embodiments, by identifying the positions of the horizontal straight line segments in the horizontal straight line segment group in the preprocessed segmented image, the horizontal straight line segment grouping in the upper area of the image and the horizontal straight line segment grouping in the lower area of the image are constructed respectively; the slopes of the horizontal straight line segments in the horizontal straight line segment grouping in the upper area of the image and the horizontal straight line segment grouping in the lower area of the image are calculated respectively, and the corresponding inclination angles of the horizontal straight line segments are calculated, and the slopes of the horizontal straight line segments with the largest number of corresponding horizontal straight line segment inclination angles are used as the upper straight line slope parameters and the lower straight line slope parameters of the perspective transformation respectively.
[0159] In the above embodiments, by identifying the positions of the vertical straight line segments in the vertical straight line segment group in the preprocessed segmented image, a vertical straight line segment grouping in the left area of the image and a vertical straight line segment grouping in the right area of the image are respectively constructed; the slopes of all vertical straight line segments in the vertical straight line segment grouping in the left area of the image and the vertical straight line segment grouping in the right area of the image are respectively calculated, and the corresponding vertical straight line segment inclinations are calculated, and the vertical straight line segments with approximate vertical straight line segment inclinations are fitted, and the slopes of the vertical straight line segments with the longest line segments in the vertical straight line segment grouping in the left area of the image and the vertical straight line segment grouping in the right area of the image are respectively obtained as the left straight line slope parameter and the right straight line slope parameter of the perspective transformation.
[0160] The beneficial effects of the above technology are: by respectively identifying the positions of the horizontal straight line segments in the horizontal straight line segment group and the vertical straight line segments in the vertical straight line segment group in the preprocessed segmented image, and performing corresponding grouping; performing slope analysis and inclination calculation on the horizontal straight line segments in the horizontal straight line segment group in the upper area of the image and the horizontal straight line segment group in the lower area of the image, and performing slope analysis on the vertical straight line segments in the vertical straight line segment group in the left area of the image and the vertical straight line segment group in the right area of the image, to obtain the upper straight line slope parameters, lower straight line slope parameters, left straight line slope parameters, and right straight line slope parameters of the perspective transformation, thereby realizing the acquisition of perspective transformation parameters.
[0161] In the above embodiment, the calculated inclination angle of the horizontal straight line segment is retained with two decimal places and assigned to a double-precision floating point variable.
[0162] In the above embodiments, the horizontal straight line segments in the horizontal straight line segment grouping in the upper area of the image and the horizontal straight line segment grouping in the lower area of the image are processed based on the K-means clustering method to obtain the upper straight line slope parameters and the lower straight line slope parameters of the perspective transformation.
[0163] In the above embodiments, fitting processing is performed on the vertical straight line segments with similar inclination angles in the vertical straight line segment grouping in the left area of the image and the vertical straight line segment grouping in the right area of the image, and the fitting processing methods include clustering method, straight line fitting with a fixed threshold range, piecewise linear regression method, model fitting-random sampling consensus method (PCL RANSAC), etc.
[0164] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A spine image correction method based on image straight line segment information, characterized in that: include, Get the original image; Performing segmentation processing on the original image to obtain an original segmented image; Acquire a segmentation mask of the original segmented image, and calculate a mask edge curve of the segmentation mask; Calculating a group of approximate straight line segments of the original segmented image according to the mask edge curve; Calculating a linear rotation transformation matrix according to the inclination data of each straight line segment in the approximate straight line segment group; comprising: Calculating the slope of each straight line segment of the approximate straight line segment group by the rotation angle, and calculating the inclination data of each straight line segment by the slope of each straight line segment; Obtaining the maximum value of the inclination data and constructing the linear rotation transformation matrix; Performing a rotation transformation on the original segmented image according to the linear rotation transformation matrix to obtain a segmentation transformation image; comprising: Create a canvas; Suppose the width of the canvas is W , the height is H , the rotation angle is α , the width of the original segmented image is w , the height is h ,but W and H The expression is: According to the linear rotation transformation matrix, the segmentation transformation image is rotationally transformed on the canvas to obtain the segmentation transformation image; Performing affine transformation processing according to the segmentation transformation image to obtain a coarse correction segmentation image; comprising: Calculating distance data between the center point of the canvas and the center point of the segmented transformation image, and calculating an affine transformation matrix according to the distance data; Performing an affine transformation operation on the segmented transformation image according to the affine transformation matrix to obtain an affine transformation image; Identifying a valid portion of the affine transformed image and constructing a minimum bounding rectangle; Using the minimum circumscribed rectangle as a boundary, cropping the affine transformed image to obtain the roughly corrected segmented image; Preprocessing the coarsely corrected segmented image to obtain a preprocessed segmented image; Detect the straight line segment information of the preprocessed segmented image by a straight line segment detection model, and construct a horizontal straight line segment group and a vertical straight line segment group; Based on the horizontal straight line segment group and the vertical straight line segment group, a slope parameter of perspective transformation is obtained; comprising: Identify the positions of the horizontal straight line segments in the horizontal straight line segment group in the preprocessed segmented image, and construct a group of horizontal straight line segments in an upper region of the image and a group of horizontal straight line segments in a lower region of the image respectively; Calculate the slopes of all horizontal straight line segments in the horizontal straight line segment group in the image area, and calculate the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; count the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment group in the image area, and use the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the upper straight line slope parameter of the perspective transformation; Calculating the slopes of all horizontal straight line segments in the horizontal straight line segment group in the lower area of the image, and calculating the corresponding horizontal straight line segment inclination angle according to the slope of the horizontal straight line segment; counting the number of horizontal straight line segments corresponding to the horizontal straight line segment inclination angle in the horizontal straight line segment group in the lower area of the image, and taking the slope corresponding to the inclination angle of the horizontal straight line segment with the largest number of horizontal straight line segments as the lower straight line slope parameter of the perspective transformation; Identify the positions of the vertical straight line segments in the vertical straight line segment group in the preprocessed segmented image, and construct a vertical straight line segment grouping in the left region of the image and a vertical straight line segment grouping in the right region of the image respectively; Calculating the slopes of all vertical straight line segments in the vertical straight line segment group in the left area of the image, calculating the corresponding vertical straight line segment inclination angle according to the slope of the vertical straight line segment, performing fitting processing on the vertical straight line segments with similar vertical straight line segment inclination angles, and selecting the slope of the vertical straight line segment with the longest line segment in the vertical straight line segment group in the left area of the image as the left straight line slope parameter of the perspective transformation; Calculating the slopes of all vertical straight line segments in the vertical straight line segment group in the right area of the image, calculating the corresponding vertical straight line segment inclination angle according to the slope of the vertical straight line segment, performing fitting processing on the vertical straight line segments with similar vertical straight line segment inclination angles, and selecting the slope of the vertical straight line segment with the longest line segment in the vertical straight line segment group in the right area of the image as the right straight line slope parameter of the perspective transformation; According to the slope parameter, constructing a minimum circumscribed quadrilateral as a perspective transformation quadrilateral for the preprocessed segmented image, taking the vertices of the perspective transformation quadrilateral as perspective transformation corner points, and calculating a perspective transformation matrix; Performing perspective transformation on the coarse corrected segmented image by using the perspective transformation matrix to obtain a perspective segmented image; The invalid area of the perspective segmented image is identified and cropped to obtain a corrected spine image.
2. The spine image correction method based on image straight line segment information according to claim 1, characterized in that: The step of obtaining the segmentation mask of the original segmented image and calculating the mask edge curve of the segmentation mask includes: Performing grayscale processing on the original segmented image to obtain a grayscale segmented image; Performing noise reduction processing on the grayscale segmented image to obtain a noise-reduced grayscale segmented image; Binarizing the denoised grayscale segmented image using a high threshold parameter to obtain an approximate binary mask; Performing corrosion processing and median filtering processing on the binary mask to obtain the segmentation mask; The edge detection is performed on the segmentation mask based on an edge detection algorithm to obtain the mask edge curve.
3. The spine image correction method based on image straight line segment information according to claim 1, characterized in that: The step of calculating the approximate straight line segment group of the original segmented image according to the mask edge curve comprises: Performing transformation processing on the mask edge curve to obtain a transformed straight line segment group; Multiplying the height of the original segmented image by a preset ratio to obtain a dynamic length threshold; The transformed straight line segment group is filtered according to the dynamic length threshold to obtain the approximate straight line segment group.
4. The spine image correction method based on image straight line segment information according to claim 1, characterized in that: The step of preprocessing the coarsely corrected segmented image to obtain a preprocessed segmented image includes: Acquire the coarsely corrected segmented image; Performing contrast enhancement processing on the coarsely corrected segmented image to obtain an enhanced segmented image; Performing edge sharpening processing on the enhanced segmented image to obtain a sharpened enhanced segmented image; The sharpened and enhanced segmented image is subjected to tensorization processing to obtain a preprocessed segmented image.
5. The spine image correction method based on image straight line segment information according to claim 1, characterized in that: The step of detecting the straight line segments of the preprocessed segmented image by a straight line segment detection model and constructing a horizontal straight line segment group and a vertical straight line segment group comprises: Detecting the straight line segments of the preprocessed segmented image by a straight line segment detection model; Calculating the slope of the straight line segment in the preprocessed segmented image, and obtaining the inclination data of the straight line segment in the preprocessed segmented image; when the inclination data is less than a preset inclination threshold, classifying the straight line segment as a horizontal straight line segment; when the inclination data is greater than the preset inclination threshold, classifying the straight line segment as a vertical straight line segment; A horizontal straight line segment group is constructed according to the horizontal straight line segments in the preprocessed segmented image, and a vertical straight line segment group is constructed according to the vertical straight line segments in the preprocessed segmented image.
Citation Information
Cited By
Ancient book lossless page turning, scanning and repairing integrated method and system
CN122176716A
