Medical image-oriented optical character recognition method

Through the combination of convolutional neural network and Transformer model, the recognition problem of complex layout and irregular text in optical character recognition of medical images is solved, accurate text detection and structured output of medical images are achieved, and the recognition accuracy and structure are improved. sex.

CN118587730APending Publication Date: 2024-09-03SOUTHEAST UNIV
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410478452.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-19
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

Existing optical character recognition methods for medical images have limited effectiveness when dealing with complex layouts, irregular texts, and low-contrast images, and are difficult to maintain the semantic structure of text. Traditional methods are insufficient for multi-column, discrete text recognition, and require a large amount of annotated data and Template management, deep learning models face feature gaps and generalization ability challenges in medical image recognition.

Method used

Use convolutional neural network and Transformer model to adjust image orientation through preprocessing, classify document and scene images, use ResNet and FPN for text detection, Seq2Seq model for text recognition, and combine context modeling and feature extraction to achieve structuring output.

Benefits of technology

It improves the accuracy and structure of medical image text recognition, can detect and combine text information more accurately, restores the original structural information, and improves the accuracy and searchability of recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587730A
    Figure CN118587730A
Patent Text Reader

Abstract

The invention discloses a medical image-oriented optical character recognition method, which comprises the following steps of: firstly, training a convolutional neural network model, performing image orientation recognition on a given medical image, rotating according to the orientation of the image, then dividing the rotated image into a document class and a scene class, documents can be images or scanned files such as discharge notes, outpatient cases and the like, and scenes can be medicine package photos. And performing text detection by using a targeted method according to the image category, identifying an image part containing the medical text, and forming a text detection box. And recognizing and extracting the text content according to the text detection box by using a Seq2Seq-based text recognition model. And finally, on the basis of a Transform key information extraction model, capturing context semantic information and space structure information of the image, inferring a semantic relationship and a hierarchical structure of texts in different text detection frames, and combining semantically related texts for structured output, thereby completing an optical character recognition task of the medical image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an optical character recognition method for medical images and belongs to the field of optical character recognition. Background Art

[0002] In recent years, with the rapid growth of digital medical information, the need to extract and recognize text from medical images has become increasingly urgent. Medical reports, medical records, prescriptions, and medical images all contain a large amount of text information. However, traditional medical images are stored in the form of images, and text search and analysis cannot be performed directly. Therefore, extracting text from medical images and converting them into editable and searchable formats is crucial for the management and utilization of medical information. Optical character recognition methods for medical images can automatically recognize and convert text in medical images, such as discharge summaries, outpatient files, physical examination conclusions, drug information, etc. The development of this technology will greatly improve the accessibility and searchability of medical data and promote the efficiency of medical information management and decision-making.

[0003] Traditional optical character recognition methods are usually based on rules or templates. Rule-based optical character recognition methods use pre-defined rules and patterns to identify and extract text in medical images. These rules can include features such as the shape, size, and color of letters and numbers. Template-based optical character recognition methods use pre-built templates to match and recognize text in medical images. These templates can be characters, words, or specific text patterns. By matching with the template, text information is recognized and extracted. In addition, machine learning methods are also widely used in medical image optical character recognition methods. These methods use feature extraction and classification algorithms to recognize text in medical images. Common feature extraction methods include edge detection, shape descriptors, and texture features. Classification algorithms can include support vector machines (SVM), K nearest neighbors (KNN), and random forests.

[0004] However, rule-based methods often have limited processing capabilities for complex layouts and irregular text, and require manual definition and adjustment of rules, making it difficult to cope with various types of medical images. The processing effect on complex layouts, irregular text or low-contrast images is limited. Template-based methods have limited text recognition capabilities for different fonts, sizes and layouts, and require a large amount of template construction and management. As for machine learning methods, there may be limitations in the extraction of complex medical image and text features, and manual design and selection of features are required, which poses certain challenges to the processing and generalization capabilities of large-scale data. In addition, traditional machine learning methods often require large-scale annotated data for training, and their performance degrades significantly when processing large amounts of data.

[0005] The rise of deep learning technology has brought new breakthroughs in the fields of image recognition and optical character recognition. Deep learning models such as convolutional neural networks (CNN) and recurrent neural networks (RNN) have achieved remarkable results in text detection and recognition tasks. These models can automatically learn feature representation and context information, thereby improving the accuracy and robustness of optical character recognition.

[0006] However, deep learning technology still faces some challenges. First, existing technologies often rely on large-scale annotated data, which limits its application in real-world scenarios. Secondly, in medical image-oriented scenarios, the requirements for recognition accuracy are high, and there are many types of medical images. The features of different types of medical images are quite different. For example, the text of scene-type medical images has problems of different scales and deformations, while such features do not exist in document-type medical images. If only a separate model is used to recognize the image, it will be difficult to process it accurately. In addition, the current optical character recognition results are usually output independently in rows, while the special structure of medical images is often multi-column and discrete, which makes the single-line output result of the recognized text contain multiple irrelevant sentences, resulting in the semantic fragmentation and mixing of the text and the loss of the original structural information, which is often what researchers do not expect to see. Summary of the invention

[0007] Technical problem: The present invention provides an optical character recognition method for medical images, which can automatically identify each area containing text information in a given image or scanned copy of a medical document, extract the corresponding medical information text, and combine the blocks into paragraphs with complete semantics according to the contextual semantics to form a structured output of medical information.

[0008] Technical solution: The optical character recognition method for medical images of the present invention first loads a trained neural network model, identifies the orientation of a given medical image, and corrects the orientation of the image. Then, a classification task is performed based on the corrected image to obtain two subdivided categories of the image. Different methods are used for the two different categories to perform text detection on the image, and the image portion containing the medical text is selected to form a detection frame. Then, a text recognition model is trained to identify and extract the text content based on the detection frame. Finally, a Transformer-based model is used to perform context modeling and feature extraction. The semantics and hierarchical structure of the text, as well as the relationship between elements, are inferred. Related texts are combined for structured output.

[0009] The optical character recognition method for medical images of the present invention comprises the following steps:

[0010] Step 1: First, process the image. Given a scanned copy of a medical image or document as input, these images can include patient discharge summaries, outpatient files, physical examination conclusions, drug images, etc. The input image is preprocessed, including resizing, cropping, or padding operations to ensure image consistency and ease of processing. The convolutional neural network model is used to predict and adjust the orientation of the image to obtain a rectified image. Before proceeding to the following steps, the input image is classified.

[0011] Step 2: Secondly, perform text detection on the classified images. For document images, use a binarization algorithm to process the classified images to obtain a binary image, and then use the connected region analysis to obtain the text detection frame. For scene images, use a neural network with a ResNet architecture to extract the text area coordinates and record the text detection frame information.

[0012] Step 3: Then, based on the detection box information of the text area obtained in step 2, text recognition is performed. The feature is that the input image is divided into small blocks. These small blocks are converted into one-dimensional image embeddings, and for each small block, its image embedding and its corresponding position embedding are concatenated as the input of the Seq2Seq model, which is trained end-to-end to predict the character sequence and obtain the recognized text.

[0013] Step 4: Finally, based on the position information in step 2 and the recognized text obtained in step 3, the text, position, and visual information are integrated to extract key information and output structured text. It is characterized in that: text embedding is obtained based on the recognized text obtained in step 3. Position embedding is obtained based on the detection box in step 2. Feature information of the input image is extracted and visual embedding is formed. The text, position, and visual embedding information are combined as input to the text detection model. Context modeling and feature extraction are performed. The semantics and hierarchical structure of the text, as well as the relationship between elements, are inferred. Related texts are combined to output structured text.

[0014] In a preferred embodiment of the method of the present invention, in step 1, the direction of the image is adjusted as follows:

[0015] 1-1 Build a convolutional neural network. For the image to be trained, resize, crop or pad it to a fixed size image, such as 1024*1024 pixels, as the input of the model. The model predicts and outputs a continuous value, indicating the rotation angle of the image. Use the training set labeled as the rotation angle to train the model, and optimize the model parameters by minimizing the cross entropy loss of the difference between the predicted rotation angle and the true label.

[0016] After the model training is completed, the image to be recognized needs to be preprocessed in the same way to resize it to the same size. Then, the image is input into the trained model, and the model will predict the rotation angle of the image. According to the predicted angle, the image is rotated and corrected accordingly.

[0017] 1-2 According to 1-1, image features are learned by training a convolutional neural network: the model input passes through 5 convolutional layers, and nonlinear mapping is performed using the RELU activation function. Maximum pooling and normalization are used between each convolutional layer to extract features. The extracted features are then mapped to categories through a fully connected layer.

[0018] In the preferred embodiment of the method of the present invention, the process of classifying the medical image and detecting the text area in step 1 is as follows:

[0019] Using convolutional neural networks, images are divided into document-type medical images and scene-type medical images. The model uses the same convolutional neural network architecture as in step 1, and the training images are two types of medical images labeled as document and scene. Different text detection methods are used for these two types of medical images.

[0020] In the preferred embodiment of the method of the present invention, the processing flow of the document-type medical images in step 2 is as follows:

[0021] (1) The input image to be detected first passes through the ResNet feature extraction network, and after sampling at different levels, feature maps of different sizes are obtained to extract the high-level feature representation of the image. Then, through the FPN (Feature Pyramid Network) module, the feature maps of different levels are fused. Starting from the top feature map, its size is increased by upsampling, and then it is added element by element with the feature map of the lower level to fuse the feature information of different levels and obtain a feature map F of unified scale. The feature map F will undergo a series of convolution and transposition operations to obtain the segmentation probability map P (Probability Map) and the threshold map T (Threshold Map).

[0022] (2) Then, the binary map of the text area is obtained by performing a differential operation on the two feature maps P and T. Finally, a connected region analysis is performed. Using the four-connectivity method, each pixel of the binary map is traversed in a breadth-first manner, adjacent pixels are assigned to the same region, and a unique label is assigned to each region. Different connected regions are created based on the labeled pixels to form a single-line text detection box.

[0023] (3) Binarization is performed using the following method:

[0024]

[0025] Where B is an approximate binary image, B i,j represents the binary value of the i-th row and j-th column in the approximate binary image; P is the segmentation probability map obtained through a series of convolution and transposition operations, P i,j represents the value of the i-th row and j-th column of the probability map; T is the adaptive threshold map learned from the network, T i,j represents the value of the i-th row and j-th column of the adaptive threshold map; k represents the amplification factor, which is set to 50 based on experience.

[0026] In the preferred embodiment of the method of the present invention, the processing flow of the scene-based medical images in step 2 is as follows:

[0027] (1) The image to be detected passes through the FPN feature pyramid network based on ResNet, whose operation is similar to the processing of document images, and then outputs four prediction results with the same size as the original image through a 3×3 full convolution layer: Figure P: The probability map of a certain pixel point in the image to be detected belonging to the center line pixel point of the text; Text center offset map D1: The x and y direction distance of a certain pixel point in the image to be detected from the center of the text detection box to which it belongs; Text vertex offset map D2: The x and y direction distance of a certain pixel point in the image to be detected from the four vertices of the text detection box to which it belongs; Text border offset map D3: The x and y direction distance of a certain pixel point in the image to be detected from the upper and lower margins of the text detection box to which it belongs, where the text detection box is the minimum circumscribed quadrilateral determined to be the text area, and the text center line area is the area obtained after the upper and lower boundaries of the text detection box are shrunk to 20%, while the left and right boundaries remain unchanged.

[0028] (2) Then, the pixel points are classified at the pixel level using the overall information, and the fragmented and separated pixels with the same characteristics are classified into the same text area. The probability map P is filtered by threshold, and the false positive pixels with probability lower than a certain value are removed. Then, for each pixel in the processed probability map P, the four vertex coordinates of the corresponding text detection box are obtained according to the text vertex bias map D2, and non-maximum suppression is performed to remove the overlapping text detection boxes to obtain the required text detection box and its center point. The text detection box will be used as the overall information; according to the text center bias map D1, the geometric center point of the text area to which the pixel points belonging to the text in the probability map P belong is calculated. The center point will be used as the pixel information. When the calculated geometric center point coincides with or is close to the center point of the detection box, the pixel point will be classified into the text area corresponding to the text detection box. The remaining unselected pixels will be re-clustered and classified through this step, and all pixels above the threshold will be divided into different texts. According to the pixels belonging to the same text, the probability map P is re-corrected.

[0029] (3) Based on the above, the text centerline is sampled, and the spacing between the sampling points is the same. According to the information provided by the text border offset map D3, the upper and lower boundary positioning points on the sampling points of the text centerline are calculated, and the obtained boundary positioning points are connected in a clockwise direction starting from the upper left corner to obtain the final text detection frame.

[0030] In a preferred embodiment of the method of the present invention, step 3 performs text recognition based on the detection frame information of the text area obtained in step 2, and the specific steps are as follows:

[0031] 3-1 The input image is divided into small blocks. These small blocks are linearly transformed through Linear Projection and converted into one-dimensional image embeddings. For each small block, its image embedding and its corresponding position embedding are concatenated as the input of the Seq2Seq model, which is trained end-to-end to predict character sequences and obtain recognized text.

[0032] 3-2 In the encoder part of the Seq2Seq model, each input first passes through a normalization layer (LN), and then a multi-head self-attention layer (MSA) is used to determine the relationship between feature vectors. The multi-head attention mechanism is used to allow the model to jointly focus on information from different representation subspaces at different positions. The number of attention heads is h. The outputs of LN and MSA are residually connected and then passed through a normalization layer, and then a feedforward neural network is used for feature extraction. The feedforward neural network consists of 2 layers and is activated using GELU. Finally, the output of the feedforward neural network is residually connected again to output the recognition result. The present invention uses the [GO] tag to mark the beginning of the text prediction, and [s] indicates the end or space.

[0033] The input to the first encoder block is denoted as t0 and is calculated as follows:

[0034]

[0035] The output of the multi-head attention layer is as follows:

[0036] t′ l =MSA(LN(t l-1 ))+t l-1

[0037] The output of the feedforward neural network is as follows:

[0038] t l =F(LN(t′ l ))+t′ l

[0039] Finally, word predictions are formed via linear projection:

[0040]

[0041] Among them, x class Represents the category information of the input image. This category embedding is added to the beginning of the sequence to ensure that the model can take into account the category to which the entire sequence belongs when processing the sequence. represents the embedding of the nth small block, E pos represents the position embedding of all N small blocks. l Where l, l = 1, 2, ..., L, L is the number of encoder blocks, and the Transformer encoder consists of a total of L encoder blocks. i Represents the i-th character recognized, where i = 1, 2, ..., S, S represents the maximum length of the character sequence that can be recognized plus 2 special characters [GO] and [s], and N < S. Linear() is a linear transformation operation that projects the output of the feedforward neural network into the predicted character.

[0042] In the preferred embodiment of the method of the present invention, step 4 extracts key information to achieve structured output, and the specific process is as follows:

[0043] 4-1 Text embedding is performed based on the recognized text obtained in step 3, wherein the steps are as follows: first, N-gram is used for word segmentation, and the segmented words are used as network tags. <cls>Mark, add later <sep>Mark, if the maximum length is not reached, use <pad>Token completion. Use a Transformer encoder similar to BERT to encode the input text to form a text embedding. And combine the one-dimensional relative position information, the two-dimensional position information and the segment vector, as follows:

[0044] Text i =TokEmb(w i )+PosEmb1D(w i )+PosEmb2D(w i )+Segment(S i )

[0045] Among them, TokEmb(w i ) represents the character w obtained by the encoder i Text embedding; one-dimensional relative position information PosEmb1D(w i ) represents the character w i Index of the two-dimensional position information PosEmb2D(w i ) represents the character w i The embedding of coordinate information of Segment(S i ) represents the segmentation vector of the text. For scene images, its value is A, and for document images, its value is B.

[0046] 4-2 Position embedding is performed based on the detection box information obtained in step 2, wherein the steps are as follows: i ,y i ) represents the center coordinate of the detection box, w i and h i Represents the width and height of the detection box. Convert this information into an embedded vector Pos i as follows:

[0047] PosEmb2Dx=Linear(x i ,y i , w i )

[0048] PosEmb2Dy=Linear(x i ,y i ,h i )

[0049] Pos i =Concatenate(PosEmb2Dx, PosEmb2Dy)

[0050] Among them, Linear() represents a linear projection operation, which transforms the input vector (x i ,y i , w i ) and (x i ,y i ,h i ) is projected into the embedding vector space, and Concatenate() represents the concatenation operation.

[0051] 4-3 extracts image features and forms visual embedding, which is characterized by the following steps: extracts image features through ResNet-FPN and converts them into embedding vectors, and combines the two-dimensional position information and segmentation vectors, as follows:

[0052] Vis i =VisTokEmb(G i )+PosEmb2D(G i )+Segment(S i )

[0053] Among them, G i An image representing the area contained in a single text detection box, VisTokEmb(G i ) represents the image G extracted by ResNet-FPN and converted into a one-dimensional image i Embedding; two-dimensional position information PosEmb2D (G i ) represents the image G i The embedding of coordinate information of Segment(S i ) represents the segment vector of the image, and its value is C.

[0054] 4-4 The model receives information from three modalities - text, position and image, and integrates it into text / position / visual embedding. The details are as follows:

[0055] Input i =Concatenate(Vis i , Text i )+Pos i

[0056] Output i =Linear(Encoder(Input i ))

[0057] The text and visual embedding vectors are concatenated. Concatenate() represents the concatenation operation, which embeds the visual embedding vector Vis i and text embedding vector Text i Splice and add position embedding Pos i , get the final embedding vector Input i . Embed the vector Input i Input to the Transformer encoder for encoding, Encoder() represents the encoder, Linear() represents a linear projection operation, and after two steps, it is finally converted into the label sequence Output i And output, combine related texts according to the label sequence for structured output.

[0058] The optical character recognition method for medical images proposed in the present invention pre-processes the medical images before text recognition, and adopts targeted text detection methods according to the characteristics of different categories of medical images, so as to detect text information more accurately. Then, text recognition is performed through the Seq2Seq model. After text recognition, key information is extracted, the context information of the recognized text is analyzed, and the combination and structured output of related texts are realized. The recognition accuracy and structure of medical images are greatly improved.

[0059] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0060] Compared with the traditional optical character recognition method for medical images, the present invention uses a convolutional neural network to classify images before the text detection stage, and divides the images into document-type medical images and scene-type medical images. Different methods of text detection are performed according to the image categories, which can obtain more accurate results. Document-type medical images are usually pure text types with certain special structures, such as discharge summaries, while scene-type medical images are usually scene pictures with mixed graphics and text, such as drug pictures. These two types of pictures have different characteristics. Using unique text detection methods for different types of images can make the detection of text areas more accurate. However, the traditional optical character recognition method for medical images does not distinguish between these two types. When the same model is used for processing, there is a problem of failure to detect some text areas, and the subsequent recognition steps cannot be completed.

[0061] Compared with the traditional optical character recognition method for medical images, the present invention performs a key information extraction step after optical character recognition, performs context modeling and feature extraction, infers the semantics and hierarchical structure of the text, as well as the relationship between elements, combines related texts, and outputs structured texts. The text information in medical images has its unique shape and structural characteristics, usually multiple long texts in blocks and multiple columns distributed at the same horizontal position. The present invention combines the layout of medical images, analyzes and identifies the context information and semantic information of a single line of text, and splices the text areas with relevant semantics to restore the original structural information of the text in the medical image. The traditional optical character recognition method for medical images does not take into account the unique structure of medical images, but only recognizes single-line or multi-line text separately, which will cause multiple paragraphs of text information to be mixed together, not only making the semantics of the recognized text confusing, but also requiring more manpower for subsequent processing of the text. In the field of optical character recognition of medical images, the accuracy of the recognition results and the restoration of structural information are not as good as the present invention.

[0062] Experimental analysis proves that the optical character recognition method for medical images proposed by the present invention can accomplish the task of text recognition and extraction of any given medical image. Whether it is the accuracy of text recognition or the restoration of the structural information of the text in the original image, the present invention is in a leading position in these aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 is a schematic diagram of the basic process of the present invention;

[0064] Figure 2 is a schematic diagram of a model for identifying image directions and categories in the present invention;

[0065] Figure 3 is a schematic diagram of a text recognition model in the present invention;

[0066] Figure 4 Schematic diagram of the Transformer encoder module in the text recognition model of the present invention;

[0067] Figure 5 It is a schematic diagram of the model structure for extracting key information in the present invention. DETAILED DESCRIPTION

[0068] The implementation process of the present invention is described in detail below in conjunction with the embodiments and the accompanying drawings.

[0069] Example: See Figure 1-Figure 5 , an optical character recognition method for medical images, including the following four steps:

[0070] 1) First, process the image. Given an image or scanned copy of a medical document as input, these images can include patient discharge summaries, outpatient files, physical examination conclusions, drug images, etc. The input image is preprocessed, including resizing, cropping, or padding operations to ensure image consistency and ease of processing. The trained convolutional neural network model is used to predict and adjust the orientation of the image to obtain a rectified image. The detailed steps are as follows:

[0071] Since the medical images to be identified are not positive, in most cases, these images will be tilted or rotated at different angles when scanned or photographed, which will affect the detection of the text area and the recognition of the text content, so a convenient method is needed to predict the direction of the image and make adjustments, so the present invention. Construct a convolutional neural network, for the image to be trained, adjust it to a fixed size image, such as 1024*1024 pixels, by resizing, cropping or padding, etc., as the input of the model, the model predicts and outputs a continuous value, indicating the rotation angle of the image. Use a training set labeled as the rotation angle for model training, and optimize the model parameters by minimizing the cross entropy loss of the difference between the predicted rotation angle and the true label.

[0072] After the model training is completed, the image to be recognized needs to be preprocessed in the same way to resize it to the same size. Then, the image is input into the trained model, and the model predicts a continuous value as the rotation angle of the image. According to the predicted angle, the image can be rotated accordingly to obtain the corrected image.

[0073] Here combined Figure 2 The structure of the model is as follows: the model input passes through 5 convolutional layers, and the RELU activation function is used for nonlinear mapping. Maximum pooling and normalization are used between each convolutional layer to extract features. The extracted features are then mapped to categories through a fully connected layer. 2) The input image is then divided into categories. Medical images can generally be divided into document-type medical images and scene-type medical images. Document-type medical images are usually pure text types with certain special structures, such as discharge summaries, while scene-type medical images are usually scene images such as drug images that are mixed with graphics and text. These two types of images have different characteristics, and unique text detection methods are used for different types of images. Using convolutional neural networks, images are divided into document-type medical images and scene-type medical images. The specific process of classifying medical images and detecting text areas is as follows:

[0074] The same convolutional neural network architecture as in step 1 is used, and the training images are two types of medical images labeled as document and scene. The image to be recognized is input into the trained model, which extracts the features of the image and then maps the features to the type of the image. After the image is classified, different text detection methods are used according to the type of the image.

[0075] (1) Document-type medical images are usually pure text images with specific structural information. The text in such images is usually distributed in the form of book paragraphs, or there is structural information such as wireframes. The processing flow for such medical images is as follows:

[0076] The input image to be detected first passes through the ResNet feature extraction network, and after sampling at different levels, feature maps of different sizes are obtained to extract high-level feature representations of the image. Then, through the FPN (Feature Pyramid Network) module, the feature maps of different levels are fused. Starting from the top feature map, its size is increased by upsampling, and then it is added element by element with the feature map of the lower level to fuse the feature information of different levels and obtain a feature map F of a unified scale. The feature map F will undergo a series of convolution and transposition operations to obtain the segmentation probability map P (Probability Map) and the threshold map T (Threshold Map).

[0077] Then, the binary map of the text area is obtained by performing a differential operation on the two feature maps P and T. Finally, a connected region analysis is performed. Using the four-connectivity method, each pixel of the binary map is traversed in a breadth-first manner, adjacent pixels are assigned to the same region, and a unique label is assigned to each region. Different connected regions are created based on the labeled pixels to form a single-line text detection box.

[0078] The following method is used for binarization:

[0079]

[0080] Where B is an approximate binary image, B i,j represents the binary value of the i-th row and j-th column in the approximate binary image; P is the segmentation probability map obtained through a series of convolution and transposition operations, P i,j represents the value of the i-th row and j-th column of the probability map; T is the adaptive threshold map learned from the network, T i,j represents the value of the i-th row and j-th column of the adaptive threshold map; k represents the amplification factor, which is set to 50 based on experience.

[0081] (2) Compared with the above-mentioned document-type medical images, scene-type medical images are usually mixed scene images such as drug images with graphics and text. Such text has problems of different scales and deformation. The processing flow for such images is as follows:

[0082] The image to be detected is passed through the FPN feature pyramid network based on ResNet, whose operation is similar to the processing of document images, and then the 3×3 full convolution layer outputs four prediction results with the same size as the original image: Figure P: The probability map of a certain pixel point of the image to be detected belonging to the pixel point of the text center line; Text center offset map D1: The x and y direction distance of a certain pixel point of the image to be detected from the center of the text detection box to which it belongs; Text vertex offset map D2: The x and y direction distance of a certain pixel point of the image to be detected from the four vertices of the text detection box to which it belongs; Text border offset map D3: The x and y direction distance of a certain pixel point of the image to be detected from the upper and lower margins of the text detection box to which it belongs, where the text detection box is the minimum circumscribed quadrilateral determined to be the text area, and the text center line area is the area obtained after the upper and lower boundaries of the text detection box are shrunk to 20%, while the left and right boundaries remain unchanged.

[0083] 2-5) Then use the overall information to perform pixel-level classification on the pixels, and classify the fragmented and separated pixels with the same characteristics into the same text area. Perform threshold filtering on the probability map P, remove the false positive pixels with probability lower than a certain value, and then obtain the corresponding four vertex coordinates of the text detection box for each pixel in the processed probability map P according to the text vertex bias map D2, and perform non-maximum suppression to remove the overlapping text detection boxes to obtain the required text detection box and its center point. The text detection box will be used as the overall information; according to the text center bias map D1, calculate the geometric center point of the text area to which the pixel belonging to the text in the probability map P belongs. The center point will be used as pixel information. When the calculated geometric center point coincides with or is close to the center point of the detection box, the pixel will be classified into the text area corresponding to the text detection box. The remaining unselected pixels will be re-aggregated and classified through this step, and all pixels above the threshold will be divided into different texts. According to the pixels belonging to the same text, the probability map P is re-corrected.

[0084] On the basis of the above, the text centerline is sampled, and the spacing of the sampling points is the same. According to the information provided by the text border offset map D3, the upper and lower boundary positioning points on the sampling points of the text centerline are calculated, and the obtained boundary positioning points are connected in a clockwise direction starting from the upper left corner to obtain the final text detection frame.

[0085] 3) Based on the detection frame information of the text area obtained in step 2), text recognition is performed. Figure 3 Illustration of the text recognition model structure diagram.

[0086] The input image is divided into small blocks. These small blocks are linearly transformed through Linear Projection and converted into one-dimensional image embeddings. For each small block, its image embedding is concatenated with its corresponding position embedding as the input of the Seq2Seq model, which is trained end-to-end to predict character sequences and obtain recognized text.

[0087] In the encoder part of the Seq2Seq model, each input first passes through a normalization layer (LN), and then a multi-head self-attention layer (MSA) is used to determine the relationship between feature vectors. The multi-head attention mechanism is used to allow the model to jointly focus on information from different representation subspaces at different positions. The number of attention heads is h. The outputs of LN and MSA are residually connected and then passed through a normalization layer, and then a feedforward neural network is used for feature extraction. The feedforward neural network consists of 2 layers and is activated using GELU. Finally, the output of the feedforward neural network is residually connected again to output the recognition result. The present invention uses the [GO] tag to mark the beginning of the text prediction, and [s] indicates the end or space.

[0088] The input to the first encoder block is denoted as t0 and is calculated as follows:

[0089]

[0090] The output of the multi-head attention layer is as follows:

[0091] t′ l =MSA(LN(t l-1 ))+t l-1

[0092] The output of the feedforward neural network is as follows:

[0093] t l =F(LN(t′ l ))+t′ l

[0094] Finally, word predictions are formed via linear projection:

[0095]

[0096] Among them, x class Represents the category information of the input image. This category embedding is added to the beginning of the sequence to ensure that the model can take into account the category of the entire sequence when processing the sequence. represents the embedding of the nth small block, E pos represents the position embedding of all N small blocks. l Where l, l = 1, 2, ..., L, L is the number of encoder blocks, and the Transformer encoder consists of a total of L encoder blocks. i Represents the i-th character recognized, where i = 1, 2, ..., S, S represents the maximum length of the character sequence that can be recognized plus 2 special characters [GO] and [s], and N < S. Linear() is a linear transformation operation that projects the output of the feedforward neural network into the predicted character.

[0097] 4) Finally, extract key information and output paragraphs. Figure 4 Schematic diagram of the model structure for key information extraction.

[0098] Based on the recognized text obtained in step 3), text embedding is performed, characterized in that the steps are as follows: first, N-gram is used for word segmentation, and the segmented words are used as network tags. <cls>Mark, add later <sep>Mark, if the maximum length is not reached, use <pad>Token completion. Use a Transformer encoder similar to BERT to encode the input text to form a text embedding. And combine the one-dimensional relative position information, the two-dimensional position information and the segment vector, as follows:

[0099] Text i =TokEmb(w i )+PosEmb1D(w i )+PosEmb2D(w i )+Segment(S i )

[0100] Among them, TokEmb(w i ) represents the character w obtained by the encoder i Text embedding; one-dimensional relative position information PosEmb1D(w i ) represents the character w i Index of the two-dimensional position information PosEmb2D(w i ) represents the character w i The embedding of coordinate information of Segment(S i ) represents the segmentation vector of the text. For scene images, its value is A, and for document images, its value is B.

[0101] Based on the detection box information obtained in step 2), the position embedding is performed, which is characterized by the following steps: using (x i ,y i ) represents the center coordinate of the detection box, w i and h i Represents the width and height of the detection box. Convert this information into an embedded vector Pos i as follows:

[0102] PosEmb2Dx=Linear(x i ,y i , w i )

[0103] PosEmb2Dy=Linear(x i ,y i ,h i )

[0104] Pos i =Concatenate(PosEmb2Dx, PosEmb2Dy)

[0105] Among them, Linear() represents a linear projection operation, which transforms the input vector (x i ,y i , w i ) and (x i ,y i ,h i ) is projected into the embedding vector space, and Concatenate() represents the concatenation operation.

[0106] Extracting image features and forming visual embedding, characterized by the following steps: extracting image features through ResNet-FPN and converting them into embedding vectors, and combining two-dimensional position information and segmentation vectors, as follows:

[0107] Vis i =VisTokEmb(G i )+PosEmb2D(G i )+Segment(S i )

[0108] Among them, G i An image representing the area contained in a single text detection box, VisTokEmb(G i ) represents the image G extracted by ResNet-FPN and converted into a one-dimensional image i Embedding; two-dimensional position information PosEmb2D (G i ) represents the image G i The embedding of coordinate information of Segment(S i ) represents the segment vector of the image, and its value is C.

[0109] The model receives information from three modalities - text, position, and image, and incorporates it into text / position / visual embedding. The details are as follows:

[0110] Input i =Concatenate(Vis i , Text i )+Pos i

[0111] Output i =Linear(Encoder(Input i ))

[0112] The text and visual embedding vectors are concatenated. Concatenate() represents the concatenation operation, which embeds the visual embedding vector Vis i and text embedding vector Text i Splice and add position embedding Pos i , get the final embedding vector Input i . Embed the vector Input i Input to the Transformer encoder for encoding, Encoder() represents the encoder, Linear() represents a linear projection operation, and after two steps, it is finally converted into the label sequence Output i And output. i The model converts the name into a BIO sequence and outputs it. It then combines related texts according to the BIO sequence for structured output. For example, for a document-like image such as a discharge summary, information such as name, such as "name: xx", will be converted by the model into a BIO sequence such as "O, O, O, B-name, I-name", where B represents the starting position of the name and I represents the internal position of the name. Then, related texts are combined and the name is output as a single text segment. For a scene-like image such as a drug image, information such as the drug name, such as "xx brand amoxicillin capsules", will be converted by the model into a BIO sequence such as "O, O, O, B-drug, I-drug, I-drug, I-drug, I-drug", and after the combination of related texts, the drug name will be output as a single text segment, even if it is in the same text detection box as the instructions for use.

[0113] The optical character recognition method for medical images proposed in the present invention divides the categories of medical images before text recognition, and adopts targeted text detection methods for the text features of different types of medical images, which can detect text information more accurately. After text recognition, key information is extracted, the context information of the recognized text is analyzed, and the combination and structured output of related texts are realized. The recognition accuracy and structure of medical images are greatly improved.

[0114] The above embodiments are only preferred implementation modes of the present invention. It should be pointed out that ordinary technicians in this technical field can make several improvements and equivalent substitutions without departing from the principles of the present invention. These technical solutions after improvements and equivalent substitutions to the claims of the present invention all fall within the protection scope of the present invention.< / pad> < / sep> < / cls> < / pad> < / sep> < / cls>

Claims

1. An optical character recognition method for medical images, characterized in that: The method comprises the following steps: Step 1: First, process the image. Given a scanned copy of a medical image or document as input, these images include patient discharge summaries, outpatient files, physical examination conclusions, and drug images. Preprocess the input image, including resizing, cropping, or padding operations to ensure image consistency and ease of processing. Use the convolutional neural network model to predict and adjust the orientation of the image to obtain the corrected image. Classify the input image before performing the following steps. Step 2: Secondly, perform text detection on the classified images. For document images, use a binarization algorithm to process the classified images to obtain a binary image. The binary image is analyzed through connected regions to obtain a text detection frame. For scene images, use a neural network with a ResNet architecture to extract the coordinates of the text area and record the text detection frame information. Step 3: Then, based on the detection box information of the text area obtained in step 2, text recognition is performed. The input image is divided into small blocks, which are converted into one-dimensional image embeddings. For each small block, its image embedding is concatenated with its corresponding position embedding as the input of the Seq2Seq model, which is trained end-to-end to predict the character sequence and obtain the recognized text. Step 4: Finally, based on the position information in step 2 and the recognized text obtained in step 3, the text, position, and visual information are integrated to extract key information and output structured text. Text embedding is obtained based on the recognized text obtained in step 3, and position embedding is obtained based on the detection box in step 2. The feature information of the input image is extracted and visual embedding is formed. The text, position, and visual embedding information are combined as the input of the text detection model to perform context modeling and feature extraction. The semantics and hierarchical structure of the text, as well as the relationship between elements, are combined with related texts to output structured text. This is to be specific in order to complete the medical text recognition task.

2. The optical character recognition method for medical images according to claim 1, characterized in that: In step 1, adjust the direction of the image as follows: 1-1 Build a convolutional neural network. For the image to be trained, resize, crop or pad it to a fixed size as the input of the model. The model predicts and outputs a continuous value, indicating the rotation angle of the image. Use the training set labeled as the rotation angle for model training. Optimize the model parameters by minimizing the cross entropy loss of the difference between the predicted rotation angle and the true label. After the model training is completed, the image to be recognized needs to be preprocessed in the same way, and it needs to be adjusted to the same size. Then, the image is input into the trained model. The model will predict the rotation angle of the image and perform corresponding rotation correction on the image according to the predicted angle. 1-2 According to 1-1, image features are learned by training a convolutional neural network: the model input passes through 5 convolutional layers, and non-linear mapping is performed using the RELU activation function. Maximum pooling and normalization are used between each convolutional layer to extract features, and then the extracted features are mapped to categories through a fully connected layer.

3. The optical character recognition method for medical images according to claim 1, characterized in that: The document classification task process in step 1 is as follows: the model adopts the same architecture as the convolutional neural network for adjusting the image orientation, and the training images are marked as document-type medical images and scene-type medical images.

4. The optical character recognition method for medical images according to claim 3, characterized in that: The processing flow for document-type medical images is as follows: (1) The input image to be detected first passes through the ResNet feature extraction network, and after sampling at different levels, feature maps of different sizes are obtained to extract the high-level feature representation of the image. Then, through the FPN (Feature Pyramid Network) module, the feature maps of different levels are fused. Starting from the top feature map, its size is increased by upsampling, and then it is added element by element with the feature map of the lower level to fuse the feature information of different levels and obtain a feature map F of unified scale. The feature map F will undergo a series of convolution and transposition operations to obtain the segmentation probability map P (Probability Map) and the threshold map T (Threshold Map). (3) Then, by performing a differential operation on the two feature maps P and T, a binary map of the text area is obtained. Finally, a connected region analysis is performed. Using the four-connectivity method, each pixel of the binary map is traversed in a breadth-first manner, adjacent pixels are assigned to the same region, and a unique label is assigned to each region. Different connected regions are created based on the labeled pixels to form a single-line text detection box. (3) Use the following method to perform binarization: Where B is an approximate binary image, B i,j represents the binary value of the i-th row and j-th column in the approximate binary image; P is the segmentation probability map obtained through a series of convolution and transposition operations, P i,j represents the value of the i-th row and j-th column of the probability map; T is the adaptive threshold map learned from the network, T i,j represents the value of the i-th row and j-th column of the adaptive threshold map; k represents the amplification factor, which is set to 50 based on experience.

5. The optical character recognition method for medical images according to claim 3, characterized in that: The processing flow for scene-based medical images is as follows: (1) The image to be detected passes through the FPN feature pyramid network based on ResNet, and then outputs four prediction results with the same size as the original image through a 3×3 full convolution layer: Figure P: The probability map of a certain pixel point in the image to be detected belonging to the center line pixel point of the text; Text center offset map D1: The x and y direction distance between a certain pixel point in the image to be detected and the center of the text detection box to which it belongs; Text vertex offset map D2: The x and y direction distance between a certain pixel point in the image to be detected and the four vertices of the text detection box to which it belongs; Text border offset map D3: The x and y direction distance between a certain pixel point in the image to be detected and the upper and lower margins of the text detection box to which it belongs, where the text detection box is the minimum circumscribed quadrilateral determined to be the text area, and the text center line area is the area obtained after the upper and lower boundaries of the text detection box are shrunk to 20%, while the left and right boundaries remain unchanged. (2) Then, the pixel-level classification method is used to classify the pixels at the pixel level using the overall information. The fragmented and separated pixels with the same characteristics are classified as belonging to the same text, and the probability map P is corrected again. The text detection box and its center point obtained by calculating and processing the probability map P and the text center offset map D1 are used as the overall information, and the text geometric center obtained by calculating and processing the probability map P and the text vertex offset map D2 is used as the pixel-level information. (3) Based on the above, the text center line obtained from the corrected probability map P is sampled with the same spacing between the sampling points. According to the information provided by the text border offset map D3, the upper and lower boundary positioning points on the sampling points of the text center line are calculated. The obtained boundary positioning points are connected in a clockwise direction starting from the upper left corner to obtain the final text detection frame.

6. The optical character recognition method for medical images according to claim 1, characterized in that: In step 3, text recognition is performed on the area containing text information divided in step 2, and the specific process is as follows: 3-1 The input image is divided into small blocks, which are linearly transformed through Linear Projection and converted into one-dimensional image embeddings. For each small block, its image embedding is concatenated with its corresponding position embedding as the input of the Seq2Seq model. The model is trained end-to-end to predict the character sequence and obtain the recognized text. In the encoder part of the Seq2Seq model, each input first passes through a normalization layer (LN), and then passes through a multi-head self-attention layer (MSA) to determine the relationship between feature vectors. The outputs of LN and MSA are residually connected and then pass through a normalization layer. A feedforward neural network is then used for feature extraction. Finally, the output of the feedforward neural network passes through a residual connection again to output the recognition result. The [GO] tag is used to mark the beginning of the text prediction, and [s] indicates the end or space.

7. The optical character recognition method for medical images according to claim 1, characterized in that: Step 4 extracts key information and implements paragraph output. The specific process is as follows: 4-1 Based on the recognized text obtained in step 3, text embedding is performed as follows: first use N-gram to segment words, and the segmented words are used as network tags, and then add <cls>Mark, add later <sep>Mark, if the maximum length is not reached, use <pad> Token completion uses a Transformer encoder similar to BERT to encode the input text to form a text embedding, combining one-dimensional relative position information, two-dimensional position information, and segment vectors.< / pad> < / sep> < / cls> 4-2 Based on the detection box information obtained in step 2, the position is embedded as follows: Use (x i ,y i ) represents the center coordinate of the detection box, w i and h i Represents the width and height of the detection box, converting this information into position embedding, 4-3 Extract image features and form visual embedding. The steps are as follows: extract image features through ResNet-FPN and convert them into embedding vectors, and combine them with two-dimensional position information and segmentation vectors. 4-4The model receives information from three modalities - text, position and image, and integrates it into text / position / visual embedding. The text and visual embedding vectors are concatenated and added with the position embedding to obtain the final embedding vector. The embedding vector is input into the Transformer encoder for encoding and finally converted into a label sequence and output. The relevant text is combined according to the label sequence for structured output.

Citation Information

Cited By

  • Robot demonstrator interface information identifying and reading method

    CN119964140A

  • OCR intelligent image classification processing platform

    CN120014647A

  • Medical document intelligent identification method and system based on OCR (Optical Character Recognition)

    CN121095967A

  • Drug package multi-scale OCR (optical character recognition) and matching method oriented to complex background

    CN121121718A