Picture batch labeling method and picture batch labeling system
Patent Information
- Application Number
- CN202611100509.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2046-07-23
AI Technical Summary
[0006]本发明申请提供了图片批量标注方法、图片批量标注系统,旨在至少部分解决现有图片标注技术中在图像存在多个相同或相似区域时,难以基于已标注区域对其他相同或相似区域进行识别和批量标注,且在用户对已标注区域进行标注修改后,难以使与其关联的其他相同或相似区域进行同步更新,从而导致图片标注过程存在重复操作较多、标注效率较低、标注结果一致性不足等技术问题
(1)通过响应用户针对待标注图片的矩形绘制操作确定模板矩形,并基于模板矩形限定的模板图像在待标注图片中确定多个匹配区域,可以使用户无需针对多个相同或相似区域逐一绘制矩形标注框。对于包含多个重复区域或相近区域或相似区域的待标注图片,用户仅需完成一次模板矩形绘制,即可基于模板匹配结果在多个匹配区域处生成对应的矩形标注框,从而减少重复框选操作,提高图片标注效率。
Smart Images

Figure CN122618625B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image data annotation technology, specifically relating to image batch annotation methods and image batch annotation systems. Background Technology
[0002] Existing image annotation tools, such as LabelImg, CVAT, and VGG Image Annotator, are typically used to select, classify, and export annotation results for target regions in images to be annotated. Taking rectangular box annotation as an example, users usually draw rectangles corresponding to the target regions one by one in the image display interface using the mouse, and configure category labels, text descriptions, or other annotation information for each rectangle. After completing the annotation, the annotation results can be exported as annotation files in formats such as JSON and XML. Some image annotation tools also provide auxiliary selection functions based on edges, contours, or pre-annotated results to reduce the amount of manual drawing of annotation boxes by users.
[0003] However, existing image annotation methods still mainly rely on users to perform selection and editing operations on each target area one by one. When an image contains multiple identical or similar regular areas, such as multiple table areas in a document image, photo areas in an ID card image, or multiple identical component areas in a product image, users usually need to draw the corresponding rectangle for each target area one by one, resulting in repetitive annotation operations and low efficiency.
[0004] Furthermore, existing image annotation tools typically lack a mechanism to automatically identify and batch-annotate other similar regions based on user-drawn annotation areas. They fail to fully exploit the relationships between repetitive content in images and lack the ability to "draw a template, automatically identify and annotate all similar regions," thus failing to utilize the repetitive features of image content for batch annotation. When a user modifies the position, size, category label, or text description of a particular annotation region, the annotation content of other similar regions usually does not update synchronously, requiring the user to adjust them individually, easily leading to inconsistencies in annotations between different regions.
[0005] Meanwhile, existing rectangular bounding box annotation results are usually based on the rectangular range drawn by the user, and some auxiliary selection methods have limited ability to adapt to the actual edge of the target. When the user's initial drawing position is inaccurate, or when the edge of the target area is relatively obvious but the bounding box is not aligned with the edge, there may be a deviation between the annotation rectangle and the actual outline of the target object, thus affecting the accuracy of the annotation results. Summary of the Invention
[0006] This invention provides a method and system for batch image annotation, aiming to at least partially solve the technical problems in existing image annotation technologies. These problems include the difficulty in identifying and batch-annotating other identical or similar regions based on already annotated regions when multiple identical or similar regions exist in an image, and the difficulty in synchronously updating other associated identical or similar regions after a user modifies an annotated region. This results in numerous repetitive operations, low annotation efficiency, and insufficient consistency in annotation results. This invention enables batch annotation of repetitive regions, improving image annotation efficiency and consistency among multiple identical or similar regions. To achieve the objectives of this invention, the following technical solution is adopted: Firstly, a method for batch image annotation includes: Get the image to be labeled; In response to the rectangle drawing operation for the image to be labeled, a template rectangle is determined; Obtain the template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; Establish a label association relationship between the template rectangle and each of the matching regions. In response to a label addition operation for the template rectangle or any of the matching regions, generate rectangular label boxes at the template rectangle and each of the matching regions respectively, and synchronously apply the determined label information to the rectangular label boxes corresponding to the template rectangle and each of the matching regions. The label information includes the label content and the label position and label size of the corresponding rectangular label box.
[0007] Secondly, an image batch annotation system includes: The image loading and display module is configured to acquire and display the image to be labeled. The rectangle drawing module is configured to determine a template rectangle in response to a rectangle drawing operation on the image to be annotated; The template matching module is configured to acquire a template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; The batch annotation synchronization module is configured to establish an annotation association relationship between the template rectangle and each of the matching regions. In response to an annotation addition operation for the template rectangle or any of the matching regions, it generates rectangular annotation boxes at the template rectangle and each of the matching regions, and synchronously applies the determined annotation information to the rectangular annotation boxes corresponding to the template rectangle and each of the matching regions. The annotation information includes annotation content and the annotation position and annotation size of the corresponding rectangular annotation box.
[0008] Thirdly, an image annotation apparatus includes a processor and a memory, wherein the memory stores a computer program, and when the processor executes the computer program, it executes any of the image batch annotation methods described in the first aspect above.
[0009] Fourthly, a computer-readable storage medium storing instructions that, when executed on a computer, perform any of the image batch annotation methods described in the first aspect above.
[0010] Compared with the prior art, the beneficial technical effects of this invention application are as follows: (1) By responding to the user's rectangle drawing operation on the image to be labeled, a template rectangle is determined, and multiple matching regions are determined in the image to be labeled based on the template image defined by the template rectangle. This eliminates the need for the user to draw rectangular annotation boxes for multiple identical or similar regions one by one. For images to be labeled that contain multiple repeated regions, similar regions, or similar regions, the user only needs to complete the template rectangle drawing once, and the corresponding rectangular annotation boxes can be generated at multiple matching regions based on the template matching results, thereby reducing repeated selection operations and improving image annotation efficiency.
[0011] (2) By converting the template image and the image to be labeled into grayscale images, the normalized correlation coefficient between the template image and each candidate image region is calculated, and the candidate matching regions are screened in order of normalized correlation coefficient from high to low. Candidate image regions with a high degree of similarity to the template image can be retained first. By combining the overlap judgment between candidate matching regions and the distance judgment between candidate matching regions and template rectangle, the situation where the same target region is repeatedly identified as multiple matching regions, the template rectangle itself is repeatedly matched, or the region near the template rectangle is repeatedly identified can be reduced, thereby improving the accuracy of matching region determination and reducing the generation of redundant rectangular annotation boxes.
[0012] (3) By establishing a label association relationship between the template rectangle and each matching area, and responding to the label addition operation for the template rectangle or any matching area, the determined label information is synchronously applied to each associated rectangular label box, so that the label content, label position and label size of multiple similar areas can maintain a corresponding relationship. As a result, users do not need to add or modify label information for each matching area separately, which can reduce repetitive editing operations and manual modification omissions, and improve the label consistency between multiple matching areas.
[0013] (4) By optimizing the outline of the template rectangle initially drawn by the user before template matching, and determining the template image based on the optimized template rectangle, the template image can better fit the actual boundary range of the target object. Specifically, by performing grayscale processing, filtering, edge detection, outline finding, target outline determination, and circumscribed rectangle determination on the local image, the influence of background areas, local textures, irrelevant edges, or adjacent objects on the template image can be reduced, thereby improving the correspondence between the template image and the actual target object and improving the accuracy of subsequent template matching.
[0014] (5) By setting edge sensitivity adjustment and minimum contour area adjustment, users can adjust the edge detection parameters and candidate contour selection conditions according to the edge clarity of the target object, the complexity of the background texture, the level of image noise, and the size of the target object. This allows the contour optimization process to adapt to table areas, ID photo areas, product component areas, industrial inspection areas, or other different types of target image areas. As a result, users do not need to accurately draw the initial template rectangle; they only need to roughly select the target object to obtain an optimized template rectangle that fits the boundary of the target object through contour optimization, thus reducing the operational threshold for users in batch image annotation.
[0015] (6) By saving corresponding state snapshots when operations such as rectangle drawing, annotation clearing, annotation addition, and template matching occur, and restoring the corresponding annotation state in response to undo or redo operations, users can trace back and restore the changes in template rectangles, matching areas, rectangular annotation boxes, and annotation relationships. This reduces the burden of re-executing template drawing, template matching, and batch annotation after erroneous operations, and improves the fault tolerance, operational convenience, and efficiency of the batch annotation process for images.
[0016] (7) By exporting the template rectangle, matching area, rectangular annotation box and annotation relationship as a JSON format file, the batch annotation results of the image can be saved in a structured way, which is convenient for subsequent annotation result review, data management, annotation result recovery, training data conversion or model training processing, and reduces the workload of repeatedly sorting annotation data between different processing links. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating an embodiment of a batch image annotation method according to this invention application; Figure 2 This is a schematic diagram illustrating the composition of an image batch annotation system according to an embodiment of this invention. Figure 3 This is a schematic diagram illustrating an image annotation interactive page for obtaining an image to be annotated according to an embodiment of this invention. Figure 4 This is a schematic diagram illustrating the drawing of a rectangle to determine a template rectangle on an image annotation interactive page according to an embodiment of this invention. Figure 5 This is a schematic diagram of the image annotation interactive page template matching according to an embodiment of this invention application; Figure 6 This is a schematic diagram illustrating the result of generating a rectangular annotation box from a template rectangle in an image annotation interactive page according to an embodiment of this invention. The accompanying drawings are provided to further understand the present invention and form part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation thereof. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0020] As shown in the present invention application and claims, unless the context clearly indicates otherwise, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate that explicitly identified steps and elements are included, and "multiple" includes one, two, or more, and these steps and elements do not constitute an exclusive list; the method or apparatus may also include other steps or elements.
[0021] While this application makes various references to certain modules of the system according to embodiments of the present invention, any number of different modules can be used and run on user terminals and / or servers. The modules are merely illustrative, and different aspects of the system and method may use different modules.
[0022] This invention application uses flowcharts to illustrate the operations performed by the system according to embodiments of the invention. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, various steps can be processed in reverse order or simultaneously, as needed. Furthermore, other operations can be added to these processes, or one or more steps can be removed from them.
[0023] Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein.
[0024] It is worth noting that in this invention application, all data acquisition actions are carried out in compliance with the relevant data protection laws and policies of the country where the location is located, and with the authorization granted by the owner of the relevant device.
[0025] Firstly, such as Figure 1 , Figures 3 to 6 As shown, a method for batch image annotation includes: Get the image to be labeled; In response to the rectangle drawing operation for the image to be labeled, a template rectangle is determined; Obtain the template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; Establish a label association relationship between the template rectangle and each of the matching regions. In response to a label addition operation for the template rectangle or any of the matching regions, generate rectangular label boxes at the template rectangle and each of the matching regions respectively, and synchronously apply the determined label information to the rectangular label boxes corresponding to the template rectangle and each of the matching regions. The label information includes the label content and the label position and label size of the corresponding rectangular label box.
[0026] In some embodiments, the image batch annotation method or system can be used as or applied to browser-based image annotation tools, image data processing platforms, artificial intelligence training data annotation platforms, industrial inspection image processing equipment, document image processing equipment, or other electronic devices capable of displaying images and receiving user interaction. These tools, platforms, or settings can provide interactive pages for image batch annotation, such as... Figures 3 to 6As shown, the batch image annotation interactive page can include an operation control area and an image interaction area. The operation control area can be set at the top and / or side and / or bottom of the batch image annotation interactive page or other positions that are convenient for users to operate. The image interaction area can be set adjacent to the operation control area and is used to display the images to be annotated, as well as annotation results such as template rectangles, matching areas, and rectangular annotation boxes.
[0027] In some embodiments, the image interaction area can be configured to receive rectangular drawing operations and annotation addition operations from the user on the image to be annotated. Specifically, the user can enter the rectangle drawing state through the rectangle drawing control in the operation control area, and determine the template rectangle in the image interaction area by dragging with the mouse, touching and dragging, drawing with a stylus, or other interactive methods; the user can also select the template rectangle or any matching area in the image interaction area and perform operations such as adding annotations.
[0028] In some embodiments, such as Figure 3 As shown, the image to be labeled can be an image imported by the user through an image upload control, or an image read from local storage, a server, an image acquisition device, a database, or other image data sources. The image to be labeled can be in JPG, PNG, BMP, TIFF, or other image formats that can be parsed by image processing programs. After obtaining the image to be labeled, it can be displayed in the image display container, original canvas, or other image display area corresponding to the image interaction area, allowing the user to view the target objects and their distribution within the image.
[0029] In some embodiments, such as Figure 4 As shown, the image interaction area can be configured to receive rectangular drawing operations from the user on the image to be annotated. Rectangle drawing operations can include mouse press, mouse drag, and mouse release operations, as well as touchscreen drag operations, stylus drawing operations, or other interactive operations that can define the rectangle's range. In response to the rectangle drawing operation, the rectangular range selected by the user within the image to be annotated can be determined, and this rectangular range can be defined as the template rectangle.
[0030] Template rectangles can be used to define the target area selected by the user. For example, when the image to be annotated is a scanned document image, the template rectangle can correspond to a table area, stamp area, photo area, signature area, or other recurring layout area in the document; when the image to be annotated is a product image, the template rectangle can correspond to a component, label, hole, assembly structure, or other recurring object area in the product; when the image to be annotated is an industrial inspection image, the template rectangle can correspond to a regular structure area in the product to be inspected.
[0031] In some embodiments, after determining the template rectangle, a template image defined by the template rectangle can be obtained. Specifically, based on the position, width, and height of the template rectangle in the original coordinate system of the image to be labeled, a local image corresponding to the template rectangle can be cropped from the image to be labeled, and this local image can be determined as the template image. The template image may include color features, texture features, edge features, contour features, brightness features, shape features, or other image features used to characterize the image content of the target region.
[0032] In some embodiments, template matching can be performed on the image to be labeled based on a template image to determine at least one matching region. Specifically, the template image can be used as a matching reference, and candidate image regions with a preset degree of similarity to the template image can be searched in the image to be labeled. The candidate image regions that meet the preset matching conditions are then determined as the matching regions. Template matching can employ normalized correlation coefficient matching, squared difference matching, correlation matching, feature point matching, edge matching, depth feature matching, or other matching methods capable of determining the similarity of image regions. This application does not limit the specific methods used.
[0033] For example, a matching window corresponding to the size of the template image can be moved in a sliding window manner in the image to be labeled, and the matching degree or similarity between the candidate image region and the template image can be calculated for candidate image regions at different positions. When the matching degree of the candidate image region is greater than a preset matching threshold, the candidate image region can be determined as the matching region. The preset matching threshold can be set by the user or adaptively determined based on the clarity of the image to be labeled, the texture complexity of the template image, the repetition degree of the target region, or other image features.
[0034] In some embodiments, such as Figure 5 As shown, if multiple regions in the image to be labeled are similar to the template image, multiple matching regions can be identified. These multiple matching regions can correspond to recurring tables, product components of the same specifications, similar ID photo areas, label areas of the same type, or other areas with similar image content in the image to be labeled. Therefore, users do not need to draw rectangles for each recurring region individually; they only need to draw a template rectangle, and the batch image labeling method can identify other matching regions.
[0035] In some embodiments, annotation associations can be established between the template rectangle and each matching region. These associations can indicate that the template rectangle and each matching region belong to the same batch of annotation objects. Specifically, annotation associations can be established through group identifiers, association records, association lists, association tables, object references, mapping relationships, shared attributes, or other data association methods. By establishing annotation associations, the template rectangle and the corresponding rectangular annotation boxes of each matching region can be processed in tandem when the annotation content is updated, without requiring the user to repeatedly perform the same annotation addition operation for each rectangular annotation box.
[0036] In some embodiments, such as Figure 6 As shown, after determining the template rectangle and each matching region, the user can perform a label addition operation on the template rectangle or any matching region. A label addition operation refers to the user triggering at least one operation to add a rectangular label box for the template rectangle or any matching region. Simultaneously or subsequently, based on the established label association relationships, corresponding rectangular label boxes can be generated at the template rectangle and each of the matching regions. The rectangular label boxes can be displayed individually or in combination using borders, semi-transparent filled areas, dashed lines, solid lines, different colored lines, or other visual methods. The rectangular label boxes corresponding to the template rectangle and those corresponding to the matching regions can use different display styles to allow users to distinguish between the template region and the automatically matched regions; alternatively, they can use the same display style to ensure a unified label display effect across multiple identified regions.
[0037] In some embodiments, the information of the added rectangular annotation boxes can be used to constitute annotation information, which may include annotation content and the annotation position and size of the corresponding rectangular annotation boxes. Annotation content may include category name, text description, number, inspection result, defect type, remarks, or other information that can be used to describe the corresponding area. Annotation position can be used to indicate the positional relationship of the corresponding rectangular annotation boxes; annotation size can at least indicate the width and height of the annotation box.
[0038] In some embodiments, after determining the annotation information, it can be synchronously applied to the template rectangle and the corresponding rectangular annotation boxes of each matching area based on the annotation association relationship. Specifically, for other rectangular annotation boxes that have an annotation association relationship with the currently operated rectangular annotation box, the annotation information of the other rectangular annotation boxes can be determined respectively. The annotation information of the other rectangular annotation boxes includes the annotation content, annotation position, and annotation size corresponding to the other rectangular annotation boxes. Thus, regardless of whether the user performs an annotation addition operation at the template rectangle or at any matching area, the template rectangle and each matching area under the same association relationship can maintain corresponding or consistent annotation information.
[0039] In some embodiments, when a user modifies any rectangular annotation box, the system can respond again to the corresponding annotation addition operation, redetermine the annotation information, and synchronously apply the modified annotation information to the template rectangle and the corresponding rectangular annotation boxes of each matching area based on the annotation association relationship. This eliminates the need for users to modify the annotation content of each matching area separately, reducing repetitive editing operations and lowering the possibility of annotation omissions or inconsistencies between different repeating areas.
[0040] Therefore, in the image batch annotation method of this invention, the user can draw a template rectangle, obtain the corresponding template image, and identify multiple matching regions in the image to be annotated, generating rectangular annotation boxes in batches at the template rectangle and the matching regions. Simultaneously, by establishing the annotation association between the template rectangle and the matching regions, the annotation information can be synchronously applied to the rectangular annotation boxes corresponding to each associated region after the user performs an annotation addition operation on any associated region. This reduces the user's workload in drawing annotation boxes, adding annotation content, and modifying annotation information one by one for repetitive regions, improving image annotation efficiency and enhancing the consistency of annotations between multiple similar regions.
[0041] Optionally, the step of performing template matching on the image to be labeled based on the template image to determine at least one matching region includes: Convert the image to be labeled and the template image into grayscale images; Move the matching window corresponding to the template image in the image to be labeled, and calculate the normalized correlation coefficient between the template image and each candidate image region; Candidate image regions with a normalized correlation coefficient greater than a preset matching threshold are identified as candidate matching regions. The candidate matching regions are filtered in descending order of the normalized correlation coefficient to determine the matching regions.
[0042] In some embodiments, a matching window corresponding to the template image can be moved within the image to be labeled, so that the matching window sequentially covers different candidate image regions in the image to be labeled. For each candidate image region, a normalized correlation coefficient can be calculated between the candidate image region and the template image. The normalized correlation coefficient can be used to characterize the degree of image content similarity between the candidate image region and the template image. The higher the normalized correlation coefficient, the closer the texture features, edge features, brightness distribution, contour features, or other image features between the corresponding candidate image region and the template image.
[0043] In some embodiments, the normalized correlation coefficient can be determined using normalized cross-correlation. For example, the value of the normalized correlation coefficient can be within a preset range; the closer the value is to the preset upper limit, the higher the degree of matching between the candidate image region and the template image. Candidate image regions with a normalized correlation coefficient greater than a preset matching threshold can be identified as candidate matching regions, while candidate image regions with a normalized correlation coefficient not greater than the preset matching threshold can be excluded.
[0044] The preset matching threshold can be set by the user or determined based on the clarity of the image to be labeled, the texture complexity of the template image, the similarity between target regions, image acquisition conditions, or labeling accuracy requirements. For example, when the similarity between repeated regions in the image to be labeled and the template image is high, the preset matching threshold can be set to a higher value; when there are changes in illumination, slight deformation, compression distortion, or partial occlusion in the image to be labeled, the preset matching threshold can be set to a relatively lower value to improve the recall of candidate matching regions.
[0045] In some embodiments, after determining multiple candidate matching regions, the normalized correlation coefficient corresponding to each candidate matching region can be obtained, and the candidate matching regions can be sorted in descending order of normalized correlation coefficient. A candidate matching region may include information such as its location, width, height, and normalized correlation coefficient. The sorted candidate matching regions can form a candidate matching region sequence. Candidate matching regions that appear earlier in the sequence have higher normalized correlation coefficients, allowing those whose image content is closer to the template image to participate in subsequent processing first, thus providing a priority basis based on similarity for determining the matching region.
[0046] Therefore, by converting the image to be labeled and the template image into grayscale images and calculating the normalized correlation coefficient between the template image and each candidate image region, the similarity between different candidate image regions and the template image can be quantified. By determining candidate image regions with normalized correlation coefficients greater than a preset matching threshold as candidate matching regions and sorting the candidate matching regions in descending order of normalized correlation coefficients, candidate matching regions with higher similarity can participate in subsequent processing first, improving the orderliness and reliability of the matching region determination process.
[0047] Optionally, the candidate matching regions are filtered according to the normalized correlation coefficient from high to low to determine that the matching regions include: When the overlap area between the current candidate matching region and the determined matching region is greater than a preset ratio of the area of the current candidate matching region, the current candidate matching region is discarded; candidate matching regions whose distance from the template rectangle is less than a preset distance threshold are excluded; and the filtered candidate matching regions are determined as the matching regions.
[0048] In some embodiments, the candidate matching regions can be sorted from high to low according to their normalized correlation coefficients, and the current candidate matching region can be obtained sequentially. Then, the current candidate matching region can be compared with the determined matching regions for overlap and distance determination. Specifically: In some embodiments, the overlap area between the current candidate matching region and each determined matching region can be determined separately. The overlap area can be understood at least as the area of the image region jointly covered by the current candidate matching region and the determined matching regions in the image to be labeled. Specifically, the overlap range in the horizontal direction and the overlap range in the vertical direction can be determined based on the left, right, upper, and lower boundaries of the current candidate matching region and the determined matching regions. When both the horizontal and vertical overlap ranges exist, the overlap area can be determined based on both.
[0049] In some embodiments, the area of the current candidate matching region can be further determined, and the overlap area between the current candidate matching region and any determined matching region can be compared with the area of the current candidate matching region. If the overlap area between the current candidate matching region and any determined matching region is greater than a preset proportion of the area of the current candidate matching region, the current candidate matching region can be discarded. The preset proportion can be 50%, or it can be 30%, 40%, 60%, 70%, or other proportions that can be used to determine whether a candidate matching region belongs to a duplicate matching result; this application does not limit this.
[0050] Understandably, since candidate matching regions are filtered sequentially according to their normalized correlation coefficients from high to low, the normalized correlation coefficient of a confirmed matching region is usually higher than that of the current candidate matching region. Therefore, when the overlap area between the current candidate matching region and the confirmed matching region is greater than a preset ratio, the confirmed matching region can be retained, and the current candidate matching region can be discarded, so that only one matching result with a higher matching degree is retained for the same actual target region.
[0051] In some embodiments, when the current candidate matching region is not discarded due to meeting the overlap area condition, it can also be determined whether the distance between the current candidate matching region and the template rectangle is less than a preset distance threshold. The distance between the current candidate matching region and the template rectangle can be the distance between their center points, the distance between their top-left corner coordinates, the minimum distance between their boundaries, or other distance parameters that can characterize the proximity of the current candidate matching region and the template rectangle.
[0052] The preset distance threshold can be determined based on the width, height, diagonal length, or a preset ratio of the template rectangle. For example, the preset distance threshold can be set to the distance range corresponding to 30% of the width and height of the template rectangle. When the horizontal offset of the current candidate matching region relative to the template rectangle is less than 30% of the template rectangle's width, and the vertical offset is less than 30% of the template rectangle's height, it can be determined that the distance between the current candidate matching region and the template rectangle is less than the preset distance threshold. The preset distance threshold can also be set by the user based on the size of the template image, the resolution of the image to be labeled, and the distribution density of the matching region.
[0053] In some embodiments, when the distance between the current candidate matching region and the template rectangle is less than a preset distance threshold, the current candidate matching region can be excluded. It is understood that the template image defined by the template rectangle is located within the image to be labeled. During template matching, the location of the template rectangle itself or its vicinity usually obtains a high normalized correlation coefficient. If these locations are again identified as matching regions, the template rectangle may exist as both a template region and a matching region, resulting in repeated bounding boxes being generated. By excluding candidate matching regions whose distance to the template rectangle is less than the preset distance threshold, duplicate detection results of the template rectangle itself or its vicinity can be avoided from being identified as new matching regions.
[0054] In some embodiments, for a current candidate matching region that does not meet the overlap area exclusion condition and the template rectangle proximity exclusion condition, the current candidate matching region can be determined as a matching region and added to the determined matching regions. Then, the next candidate matching region can be obtained, and the overlap area judgment, template rectangle distance judgment, and matching region determination operations can be repeated until all candidate matching regions have been filtered.
[0055] Therefore, by filtering candidate matching regions in descending order of normalized correlation coefficient, and by combining the judgment of the overlap area between the current candidate matching region and the determined matching region, as well as the judgment of the distance between the current candidate matching region and the template rectangle, we can prioritize retaining matching regions with high matching degree and independent position. This reduces the situation where the same target region is repeatedly identified, the template rectangle itself is repeatedly matched, and the area near the template rectangle is repeatedly determined as a matching region, thereby improving the accuracy of matching region determination and reducing the possibility of generating redundant rectangular annotation boxes in subsequent batch annotation processes.
[0056] Optionally, before performing template matching on the image to be labeled based on the template image, the method further includes: optimizing the outline of the template rectangle to obtain an optimized template rectangle, and determining the template image based on the optimized template rectangle; The contour optimization of the template rectangle includes: extracting a local image containing the template rectangle and a preset boundary margin from the image to be labeled; converting the local image into a grayscale image and filtering the grayscale image; performing edge detection on the filtered grayscale image and performing contour search based on the edge detection results; determining a target contour with an area greater than a preset minimum contour area from the found contours; determining the circumscribed rectangle of the target contour and mapping the circumscribed rectangle from the local image coordinate system to the coordinate system of the image to be labeled to obtain the optimized template rectangle.
[0057] It can be observed that the template rectangle determined by the user through the rectangle drawing operation may only be a rough selection of the target area, and its boundary may be offset from the edge of the actual target object, or the template rectangle may contain the background area around the target object. By optimizing the outline of the template rectangle before template matching, the template image used for subsequent template matching can be made closer to the actual outline of the target object, reducing the influence of background areas, irrelevant edges, or adjacent objects on the template matching result.
[0058] In some embodiments, a partial image containing a template rectangle and a preset boundary margin can be cropped from the image to be labeled. The preset boundary margin can be understood as the image range extending outward from the left, right, top, and bottom sides of the template rectangle. The preset boundary margin can be a fixed number of pixels, or it can be determined according to a preset proportion of the width, height, or diagonal length of the template rectangle. For example, the preset boundary margin can be 5 pixels, 10 pixels, 20 pixels, or 5% to 20% of the width and / or height of the template rectangle, and this application does not limit it in this way.
[0059] Understandably, if only the image area inside the template rectangle is captured, the local image may lack complete edge information for identifying the target contour if the user-drawn template rectangle does not completely cover the target object, or if the actual edge of the target object is near the boundary of the template rectangle. By retaining a preset boundary margin around the template rectangle, the local image can include both the target image content inside the template rectangle and the edge image content near the template rectangle, thus providing a more complete image basis for subsequent edge detection, contour finding, and determination of the circumscribed rectangle.
[0060] In some embodiments, the local image may have a local image coordinate system, and the image to be labeled may have an original coordinate system. The origin of the local image coordinate system may correspond to the upper left corner of the local image, and the origin of the original coordinate system of the image to be labeled may correspond to the upper left corner of the image to be labeled. The starting position of the local image in the original coordinate system of the image to be labeled can be determined by the position of the template rectangle and a preset boundary margin. Therefore, the contour position or circumscribed rectangle position subsequently determined in the local image can be mapped to the original coordinate system of the image to be labeled based on the starting position of the local image.
[0061] In some embodiments, after acquiring a local image, the local image can be converted into a grayscale image. Grayscale images can be used to reduce the impact of color channel differences on subsequent edge detection processes and reduce the amount of data processing during image processing. Specifically, the corresponding grayscale values can be determined based on the pixel values of the red, green, and blue channels of each pixel in the local image to obtain a grayscale image. Grayscale conversion can be performed using a weighted average method, a brightness extraction method, a maximum value method, an average value method, or other grayscale conversion methods; this application does not limit the specific grayscale conversion methods used.
[0062] In some embodiments, after obtaining a grayscale image, the grayscale image can be filtered. Filtering can be used to reduce noise, compression artifacts, isolated bright spots, isolated dark spots, or local texture disturbances in a local image, thereby making the main edges of the target object clearer. Filtering can include Gaussian filtering, median filtering, mean filtering, bilateral filtering, or other filtering methods capable of reducing image noise.
[0063] For example, Gaussian filtering can be used to smooth grayscale images. The kernel size of the Gaussian filter can be 3×3, 5×5, 7×7, or other sizes, and the filtering intensity can be set according to the image quality of the image to be labeled, the sharpness of the target object's edges, and the noise level. For local images with relatively more noise or more complex texture variations, a larger filtering intensity can be used; for local images with rich edge details or small target object sizes, a smaller filtering intensity can be used to avoid excessive smoothing that could lead to the loss of target edge details.
[0064] In some embodiments, after filtering a grayscale image, edge detection can be performed on the filtered grayscale image to obtain an edge image. Edge pixels in the edge image can be used to represent the locations where pixel brightness, color, or texture changes significantly in a local image, and the boundaries of target objects can typically form continuous or nearly continuous edge contours in the edge image.
[0065] In some embodiments, edge detection can employ Canny edge detection, Sobel edge detection, Prewitt edge detection, Laplacian edge detection, or other processing methods capable of extracting image edge information. For example, Canny edge detection can be used to process the filtered grayscale image, and a high threshold and a low threshold for edge detection can be determined based on an edge sensitivity parameter. For example, the high threshold can correspond to the edge sensitivity parameter, and the high threshold range can be 30-150. The low threshold can be a preset proportion of the high threshold, for example, 0.5 times the high threshold. Of course, the high and low thresholds can also be determined separately by the edge sensitivity parameter, and this application does not limit this.
[0066] In some embodiments, after the user adjusts the edge sensitivity parameters, edge detection, contour finding, and bounding rectangle determination processes can be re-executed on the local image containing the template rectangle based on the updated high and low thresholds to update and optimize the template rectangle. This allows the user to adjust the contour optimization results based on the edge sharpness of the target object in the local image, the complexity of the background texture, or the level of noise.
[0067] In some embodiments, when the edge sensitivity parameter is small, the high and low thresholds for edge detection are relatively low, making the edge detection process more sensitive to changes in pixel brightness or grayscale, and thus detecting more edge information. This is suitable for scenarios where the target object has weak edges, low contrast, or where more edge details need to be preserved. Conversely, when the edge sensitivity parameter is large, the high and low thresholds for edge detection are relatively high, reducing the likelihood of weak edges, local texture edges, or noisy edges being identified as target edges. This is suitable for scenarios where the target object has clear edges, complex background textures, or a lot of noise. Therefore, by adjusting the edge sensitivity, users can adjust the edge detection parameters for table areas, ID photo areas, product component areas, or other different types of target image areas, making the subsequently determined target contour and optimized template rectangle more closely match the boundary of the actual target object, thus improving the accuracy of template image determination.
[0068] In some embodiments, after obtaining the edge image, contour lookup can be performed based on the edge image. A contour can be understood at least as a boundary curve or sequence of boundary pixels composed of interconnected edge pixels. Contour lookup can be used to identify contour information corresponding to different objects, background regions, internal structures, or edge segments in a local image. Contour lookup can employ external contour lookup, hierarchical contour lookup, or other processing methods capable of determining boundary contours from the edge image.
[0069] In some embodiments, after finding multiple contours, the contour area corresponding to each contour can be determined separately. The contour area can be used to characterize the size of the region enclosed by the contour. Contours with a contour area smaller than the current minimum contour area parameter can be excluded from the candidate contour list. Contours with a contour area greater than or equal to the current minimum contour area parameter can be identified as candidate contours and used for subsequent target contour determination. Thus, users can adjust the range of candidate contours participating in the target contour determination by combining the actual size of the target object corresponding to the template rectangle, the noise level in the local image, and the complexity of the background texture. This makes the subsequently obtained optimized template rectangle more closely fit the actual boundary of the expected target object. Furthermore, the target contour, the bounding rectangle of the target contour, and the optimized template rectangle can be re-determined based on the selected candidate contours.
[0070] In some embodiments, when the user reduces the minimum contour area parameter, more contours with smaller areas can be retained, which is suitable for scenarios where the target object is small, has many edge details, or requires the preservation of local structural contours; when the user increases the minimum contour area parameter, more small contours can be excluded, reducing the possibility that contours formed by text strokes, noise edges, local textures, or other non-target image content will be identified as target contours, which is suitable for scenarios where the target object has a large area, complex background textures, or a lot of image noise.
[0071] For example, the preset minimum outline area can be 50 pixels, 100 pixels, 500 pixels, 1000 pixels, or other area thresholds, or it can be adaptively determined based on the area of the template rectangle, the size of the local image, or the expected size of the target object. When the template rectangle corresponds to a large table area, product component area, or ID photo area, a relatively large preset minimum outline area can be set; when the template rectangle corresponds to a small icon, label, hole, or part feature, a relatively small preset minimum outline area can be set.
[0072] In some embodiments, the target contour can be the contour with the largest area among the candidate contours, the candidate contour closest to the center of the template rectangle, or the candidate contour that best matches the aspect ratio, area ratio, shape features, or edge distribution features of the template rectangle. Thus, based on the actual shape of the target object in the image to be labeled, the target contour most likely to correspond to the template target region can be determined from multiple candidate contours.
[0073] In some embodiments, after determining the target contour, the circumscribed rectangle of the target contour can be determined. The circumscribed rectangle can be a rectangular area that can enclose the target contour. Specifically, the minimum x-coordinate, maximum x-coordinate, minimum y-coordinate, and maximum y-coordinate of each contour point in the target contour in the local image coordinate system can be determined. The minimum x-coordinate and minimum y-coordinate determine the position of the upper left corner of the circumscribed rectangle, and the maximum x-coordinate and maximum y-coordinate determine the position of the lower right corner of the circumscribed rectangle, thereby determining the width and height of the circumscribed rectangle.
[0074] In some embodiments, the circumscribed rectangle of the target contour is initially located in the local image coordinate system. To ensure accurate positioning of the template image in the subsequent template matching process, the circumscribed rectangle can be mapped from the local image coordinate system to the original coordinate system of the image to be labeled. Specifically, the coordinates of the upper left corner of the circumscribed rectangle can be translated based on the starting position of the local image in the original coordinate system of the image to be labeled, to obtain the corresponding position of the circumscribed rectangle in the original coordinate system of the image to be labeled. For example, if the upper left corner coordinates of the local image in the original coordinate system of the image to be labeled are (x0, y0), and the upper left corner coordinates of the circumscribed rectangle of the target contour in the local image coordinate system are (xl, yl), then the upper left corner coordinates of the circumscribed rectangle of the target contour in the original coordinate system of the image to be labeled can be (x0+xl, y0+yl). The width and height of the circumscribed rectangle can remain unchanged, or can be appropriately adjusted according to edge detection accuracy, template matching accuracy requirements, or other image processing needs.
[0075] In some embodiments, the bounding rectangle mapped to the original coordinate system of the image to be labeled can be determined as the optimized template rectangle, and a template image can be obtained from the image to be labeled based on the optimized template rectangle. Since the optimized template rectangle can be determined by the bounding rectangle of the target contour, it can better fit the actual boundary range of the target object compared to the template rectangle initially drawn by the user.
[0076] In some embodiments, when no candidate contour with an area greater than the preset minimum contour area is found, or when none of the found candidate contours meet the preset contour conditions, the user-drawn template rectangle can be retained as the optimized template rectangle, or the local image range within the preset boundary margin of the user-drawn template rectangle can be used as the optimized template rectangle. This avoids interruptions in the template matching process due to unclear local image edges, insufficient contrast between the target object and the background, or excessive image noise preventing the determination of the target contour.
[0077] Therefore, in this invention, by cropping a local image containing the template rectangle and a preset boundary margin before template matching, and sequentially performing grayscale processing, filtering, edge detection, contour finding, target contour determination, circumscribed rectangle determination, and coordinate mapping, the user-roughly drawn template rectangle can be adjusted into an optimized template rectangle that more closely resembles the actual contour of the target object. Determining the template image based on the optimized template rectangle reduces the influence of irrelevant background areas in the template image on subsequent template matching, improves the correspondence between the template image and the actual target object, and thus improves the accuracy of the matching region determination.
[0078] Optionally, the image batch annotation method further includes: When a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation is performed, a snapshot of the current annotation state is saved. In response to the undo operation, retrieve the previous state snapshot from the history record and restore the labeled state corresponding to the previous state snapshot; In response to a redo operation, restore the labeled state corresponding to the next state snapshot; The status snapshot includes rectangular annotation box data, template rectangle data, matching region data, and annotation association relationship data.
[0079] In some embodiments, the image batch annotation method may further include an annotation operation history management process. It is understood that an annotation addition operation can refer to a user triggering an operation to add a rectangular annotation box for a template rectangle or any matching area, and an annotation clearing operation can refer to a user triggering an operation to clear a rectangular annotation box for a template rectangle or any matching area, deleting the current rectangular annotation box and its annotation information. When the current rectangular annotation box has annotation association relationships with other rectangular annotation boxes, other associated rectangular annotation boxes and their corresponding annotation information can also be cleared simultaneously. After the user performs operations such as rectangle drawing, annotation clearing, annotation addition, or template matching, the template rectangle, matching area, rectangular annotation boxes, and annotation association relationships in the image to be annotated may all change. If the user mistakenly performs an annotation addition operation, or needs to compare annotation results corresponding to different annotation schemes, if it is impossible to restore the annotation state before the operation, it may be necessary to redraw the template rectangle, re-execute template matching, and re-add annotation information, increasing repetitive operations in the image batch annotation process.
[0080] In some embodiments, when a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation is generated, a state snapshot corresponding to the current annotation state can be saved. The state snapshot can be understood as a data set used to characterize the annotation state of the image to be annotated at the corresponding operation time. The historical records can be stored in the order in which each state snapshot is generated, so as to characterize the annotation state changes corresponding to different operation stages during the batch annotation of images.
[0081] Specifically, after a user determines a template rectangle through a rectangle drawing operation, a state snapshot including the template rectangle data can be saved; after performing template matching based on the template image and determining multiple matching regions, a state snapshot including the template rectangle data, matching region data, and rectangle annotation box data can be saved; after a user performs an annotation addition or deletion operation on the template rectangle or any matching region, an updated state snapshot can be saved. Thus, the annotation states corresponding to different annotation addition operations can be retained in the history record.
[0082] In some embodiments, the status snapshot may include rectangular annotation box data, template rectangle data, matching region data, and annotation association data. The rectangular annotation box data may include at least one of the following: identification information, position, size, display style, valid status, and other data used to characterize the rectangular annotation box; the template rectangle data may include the position, size, template image range, optimization status, and other data used to characterize the template rectangle; the matching region data may include the position, size, matching degree, region identifier, and other data used to characterize the matching region; the annotation association data may include at least one of the following: association records between the template rectangle and each matching region, group identifier, mapping relationship, and other data used to characterize the associated annotation relationship.
[0083] In some embodiments, state snapshots can be generated through object copying, data serialization, structured data storage, JSON data storage, memory caching, or other methods capable of preserving the current annotation state. To prevent subsequent annotation addition operations from affecting the data in the saved state snapshots, the data corresponding to the current annotation state can be independently copied and saved, or the current annotation state can be converted into an independent data structure and saved. Thus, different state snapshots in the historical record can correspond to the annotation states at different operational stages.
[0084] In some embodiments, a current state identifier can be set in the history to indicate the currently displayed or active state snapshot. After a user completes a new rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation, the current annotation state after the operation can be saved as a new state snapshot, and the current state identifier can be updated to this new state snapshot. If the user performs a new annotation adding operation again after restoring to an earlier state in the history, the state snapshot after the current state identifier can be deleted or invalidated, and then the state snapshot corresponding to the new annotation adding operation can be saved. This avoids retaining subsequent states in the history that are inconsistent with the current annotation path.
[0085] In some embodiments, when a user performs an undo operation via the undo control, in response to the undo operation, the system can retrieve the previous state snapshot from the history record before the current state snapshot and restore the corresponding annotation state based on the previous state snapshot. Specifically, the currently displayed template rectangle, matching region, rectangular annotation box, and annotation information can be cleared, and the corresponding template rectangle, matching region, rectangular annotation box, and annotation association relationship can be regenerated based on the template rectangle data, matching region data, rectangular annotation box data, and annotation association relationship data from the previous state snapshot.
[0086] For example, after a user completes template matching, they can add a rectangular label box to one of the matched areas and apply it to multiple matched areas simultaneously. If the user performs an undo operation, the state snapshot before the label addition operation can be restored, allowing multiple matched areas to return to their state without the added rectangular label box. When a user deletes the rectangular label box corresponding to a matched area after template matching, performing an undo operation can restore the state snapshot before the deletion, allowing the deleted rectangular label box, the corresponding matched area, and the corresponding label association to be displayed again.
[0087] In some embodiments, when a user performs a redo operation via the redo control, the annotation state corresponding to the next state snapshot after the current state snapshot in the history can be restored in response to the redo operation. Specifically, the current state identifier can be updated to the next state snapshot, and the corresponding annotation state can be restored based on the rectangular annotation box data, template rectangle data, matching region data, and annotation association data in the next state snapshot.
[0088] In some embodiments, a preset maximum number of historical records can be set. For example, the preset maximum number can be 10, 20, 50, 100, or other numbers. When the number of state snapshots in the historical record reaches the preset maximum number, the oldest state snapshot can be deleted to reserve storage space for subsequent new state snapshots. This allows for the support of undo and redo operations while preventing the continuous increase of historical records from consuming excessive storage resources.
[0089] Therefore, in this invention application, by saving the corresponding state snapshot when a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation occurs, and restoring the previous state snapshot in response to an undo operation and the next state snapshot in response to a redo operation, users can trace back and restore the process of changing template rectangles, matching areas, rectangular annotation boxes, annotation relationships, and annotation information. This reduces the situation of repeatedly executing template drawing, template matching, and batch annotation adding operations after accidental operation, and improves the operability and fault tolerance of the batch annotation process of images.
[0090] Secondly, such as Figures 2 to 6 As shown, an image batch annotation system, which may or may not employ any of the image batch annotation methods described in the first aspect above, includes: The image loading and display module 100 is configured to acquire and display the image to be labeled. The rectangle drawing module 200 is configured to determine a template rectangle in response to a rectangle drawing operation for the image to be annotated; The template matching module 300 is configured to acquire a template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; The batch annotation synchronization module 400 is configured to establish an annotation association relationship between the template rectangle and each of the matching regions. In response to an annotation addition operation for the template rectangle or any of the matching regions, it generates rectangular annotation boxes at the template rectangle and each of the matching regions, and synchronously applies the determined annotation information to the rectangular annotation boxes corresponding to the template rectangle and each of the matching regions. The annotation information includes annotation content and the annotation position and annotation size of the corresponding rectangular annotation box.
[0091] In some embodiments, the image batch annotation system may include an image loading and display module 100, a rectangle drawing module 200, a template matching module 300, and a batch annotation synchronization module 400. The image loading and display module 100, the rectangle drawing module 200, the template matching module 300, and the batch annotation synchronization module 400 may be independent software functional modules, or they may be integrated into the same image annotation program, web application, browser application, image processing program, or artificial intelligence training data processing program. These modules may interact with each other through function calls, event listeners, state management objects, shared data caches, object references, or other software communication methods.
[0092] In some embodiments, the image loading and display module 100 can provide the image to be annotated to the rectangle drawing module 200 and the template matching module 300; the rectangle drawing module 200 can provide the template rectangle data to the template matching module 300 and the batch annotation synchronization module 400; the template matching module 300 can provide the matching area data to the batch annotation synchronization module 400; and the batch annotation synchronization module 400 can provide the rectangle annotation box, annotation relationship, and annotation information to the image loading and display module 100 to display the corresponding annotation results in the image interaction area.
[0093] In some embodiments, such as Figures 3 to 6 As shown, the batch image annotation interactive page can include an operation control area and an image interaction area. The operation control area can be set at the top and sides of the batch image annotation interactive page, and the image interaction area can be set adjacent to the operation control area. The image interaction area can be used to display the image to be annotated, template rectangle, matching area, rectangular annotation box, etc.; the operation control area can be used to provide image loading (corresponding to...). Figures 3 to 6 "Load Image" in the middle), rectangle drawing (corresponding to Figures 3 to 6 (rectangle in the text), smart matching (corresponding to) Figure 4 "Smart matching" and annotation saving (corresponding to) Figure 3"Save Marks" and "Clear Marks" (corresponding to...) Figure 3 "Clear mark" in the middle), undo (corresponding to Figure 3 The "Undo" and "Redo" functions are available in the 'Undo' and 'Redo' functions, respectively. Figure 3 The interactive controls, such as "Redo," can be used in the operation control area. The operation prompt area can also include an operation prompt area, which can be used to display at least one of the following: the operation flow for batch image annotation, the current processing step, completed steps, and subsequent steps to be executed, to guide the user to complete template determination, matching region recognition, and batch annotation processing according to a preset process. For example, the operation prompt area can display the following operation prompts in sequence: (1) "Start Matching": This prompts the user to turn on the smart matching switch, so that the template matching module is in a state where template matching processing is allowed; (2) "Draw Area": This prompts the user to enter the rectangle drawing state through the rectangle drawing control and select the target area in the image interaction area to determine the template rectangle; (3) "Match Detection": This prompts the user to trigger the template matching process through the start matching control after the template rectangle is determined, so as to detect areas similar to the template image in the image to be labeled and determine at least one matching area; (4) "Add Label": This prompts the user to add a rectangular label box in the template rectangle or any matching area; (5) "Automatic Synchronization": This prompts the user that the label content, label position and label size in the current rectangular label box can be automatically synchronized to the corresponding rectangular label boxes of other matching areas based on the label association relationship. Thus, the user can complete the identification and association labeling of repeated or similar areas in the image to be labeled according to the processing flow of "Start Matching - Draw Area - Match Detection - Add Label - Automatic Synchronization" shown in the operation prompt area, reducing the difficulty for the user to understand the batch labeling process of the image.
[0094] In some embodiments, such as Figures 3 to 6 As shown, the image loading and display module 100 includes an image loading unit (corresponding to...) Figures 3 to 6 In the "Load Image" section, in response to the user's operation on the image loading control, the image loading and display module 100 can obtain the image to be labeled and display it in the image interaction area. For example, as shown... Figure 3 As shown, the image to be labeled can be a panel image containing multiple repeating circuit board units. The image loading and display module 100 allows the user to observe the distribution position and image content of each circuit board unit in the image interaction area, providing an image display basis for subsequent template rectangle drawing and matching area determination.
[0095] In some embodiments, the rectangle drawing module 200 may include a rectangle drawing unit (corresponding to...) Figures 3 to 6The rectangle drawing control in the image (which can be simply referred to as "rectangle") can receive user trigger operations on the rectangle drawing control and put the image batch annotation system into rectangle drawing mode. Figure 4 As shown, when in rectangular drawing mode, the user can perform drag-and-drop drawing operations on the target area of the image to be annotated in the image interaction area. For example, the user can perform mouse press, drag, and release operations on a circuit board unit, or perform touch drag, stylus drawing, or other interactive operations that can define the rectangular range, such as translating the image to be annotated. Specifically, the rectangular drawing module 200 can obtain the start and end positions of the user's drag operation and determine the rectangular range based on the start and end positions. Optionally, when the image to be annotated is in a scaled display, panned display, or other non-original display state, the rectangular drawing module 200 can also convert the user's operation position to the original coordinate system of the image to be annotated based on the current scaling ratio, image display offset, or the position of the image display container. The rectangular drawing module 200 can then determine the position, width, and height of the template rectangle based on the converted start and end positions.
[0096] In some embodiments, the rectangle drawing module 200 can send the position, width, and height of the template rectangle to the template matching module 300, so that the template matching module 300 can obtain the template image based on the image area defined by the template rectangle and perform subsequent template matching processing. Optionally, when the image batch annotation system also includes a contour optimization module, the rectangle drawing module 200 can also send the template rectangle to the contour optimization module 500, so that the contour optimization module can optimize the template rectangle and obtain an optimized template rectangle. For example, as shown... Figure 4 As shown, users can draw a template rectangle at one of the circuit board units within the image interaction area. The rectangle corresponding to the template rectangle can be displayed using a first display style, such as a purple border.
[0097] In some embodiments, the template matching module 300 may include an intelligent matching status management unit (corresponding to...) Figure 4 The intelligent matching switch (which can be simply referred to as "intelligent matching") and the matching instruction receiving unit (corresponding to) Figure 4 The "Start Matching" control in the middle can be simply referred to as "Start Matching Same Regions" and the preset matching threshold setting unit (corresponding to...). Figure 4 The matching similarity adjustment control (which can be simply referred to as "matching similarity") and the matching result display unit (corresponding to...) Figure 4 (The matching result prompt area and / or matching similarity display area in the text).
[0098] In some embodiments, the intelligent matching state management unit can receive user activation or deactivation operations for the intelligent matching function, and determine accordingly whether the template matching module 300 is in a state where template matching processing is permitted. Specifically, the intelligent matching switch can be in an Activated state before or after the rectangle drawing module 200 determines the template rectangle. Preferably, after the rectangle drawing module 200 determines the template rectangle, when the intelligent matching switch is in an Activated state, the template matching module 300 can receive a template matching instruction issued by the user through the "Start Matching Same Regions" control, and perform template matching processing based on the template image defined by the template rectangle. Optionally, when the image batch annotation system includes a contour optimization module, the template matching module 300 can determine the template image based on the optimized template rectangle output by the contour optimization module, and perform template matching processing based on the template image.
[0099] In some embodiments, when the smart matching switch is off, the template matching module 300 may temporarily not respond to the template matching command issued by the "Start Matching Same Regions" control, or may set the "Start Matching Same Regions" control to an unavailable state, thereby pausing the process of determining the matching region based on the template image. Turning off the smart matching switch does not affect the display and saving of the determined template rectangle; after the smart matching switch is turned back on, the user can still trigger template matching processing based on the current template rectangle. Therefore, the user can selectively enable or pause the template matching function based on whether it is currently necessary to identify repeating regions in the image to be annotated.
[0100] In some embodiments, the preset matching threshold setting unit can receive a preset matching threshold input by the user through a matching similarity adjustment control, and provide the preset matching threshold to the template matching process. The template matching module 300 can use a template image as a matching benchmark to determine multiple candidate image regions in the image to be labeled, and determine the matching similarity between each candidate image region and the template image; when the matching similarity corresponding to a candidate image region meets the preset matching threshold, the candidate image region can be used as a candidate matching region for subsequent filtering processing. The user can adjust the preset matching threshold according to the clarity of the image to be labeled, the repetition degree of the target region, or the complexity of the background.
[0101] In some embodiments, the template matching module 300 can filter candidate matching regions based on the matching similarity of candidate matching regions, the overlap relationship between candidate matching regions, and the positional relationship between candidate matching regions and the template rectangle, to determine at least one matching region. The processing procedures involved in template matching, such as grayscale processing, normalized correlation coefficient calculation, candidate matching region sorting, overlap suppression, and exclusion of neighboring template regions, can be found in the same or related technical content in the first aspect, and will not be repeated here.
[0102] In some embodiments, such as Figure 5 As shown, the matching result display unit can obtain the number of matching regions determined by the template matching module 300, the position, size, and corresponding matching similarity of each matching region, and output the matching result information to the operation control area for display. The matching result information may include at least one of the following: template regions have been set, template size, number of determined matching regions, number of each matching region, and corresponding matching similarity. For example, as... Figure 5 As shown, it can display "3 identical regions found": Region 1, similarity: 100%, Region 2, similarity: 97%, Region 3, similarity: 97%.
[0103] For example, such as Figure 5 As shown, the image to be labeled can be a panel image containing multiple repeating circuit board units. The user can draw a template rectangle at one of the circuit board units using the rectangle drawing module 200. With the intelligent matching switch on, the user can trigger the template matching module 300 to perform template matching processing using the "Start Matching Same Areas" control. The template matching module 300 can determine multiple matching areas at the remaining repeating circuit board units, and the matching result display unit displays the number of matching areas and the matching similarity corresponding to each matching area in the intelligent matching control area on the right. Thus, the user can intuitively view the template matching results and adjust the preset matching threshold or redefine the template rectangle based on the matching results.
[0104] In some embodiments, after the template matching module 300 determines the matching area, it can send the matching area data to the batch annotation synchronization module 400. The batch annotation synchronization module 400 can generate rectangular annotation boxes at the template rectangle and each matching area, and establish the annotation association relationship between the template rectangle and each matching area. Figure 5 , Figure 6 As shown, the rectangles corresponding to the template rectangles can use the first display style, such as a purple border; the rectangles corresponding to each matching area can use the second display style, such as a blue border. Therefore, users can intuitively distinguish between manually drawn template rectangles and matching areas automatically determined by the template matching module 300; simultaneously, users can also... Figure 5 Select the template rectangle or any matching area corresponding to the blue border, and perform the annotation addition operation. The batch annotation synchronization module 400 can respond to this annotation addition operation, determine the annotation information, and based on the annotation association relationship, synchronously apply the annotation information to the rectangular annotation boxes corresponding to the template rectangle and other matching areas.
[0105] In some embodiments, the template matching module 300 may further include a template clearing unit (not shown). The template clearing unit can receive a user's trigger operation on the clear template control and clear the template state and matching state corresponding to the current template matching task. Specifically, the template clearing unit can clear the current template rectangle, template image, template image processing results, etc., and can also clear the matching result information displayed by the matching result display unit. For example, when a user finds that the template rectangle range is inappropriate, the matching similarity threshold is improperly set, or the number of determined matching regions is abnormal, the user can clear the current template and corresponding matching results using the "Clear Template" control. Afterwards, the user can redraw a new template rectangle using the rectangle drawing module 200 and re-execute the template matching process using the template matching module 300.
[0106] In some embodiments, the batch annotation synchronization module 400 may include a tag saving unit (corresponding to...) Figure 3 The mark-saving control (which can be simply referred to as "mark saving") and the mark-clearing unit (corresponding to...) Figure 3 The system includes a marker clearing control (which can be abbreviated as "marker clearing") and a marker information display unit. The marker saving unit can be used to perform marker saving operations, responding to user triggering operations on the marker saving control, and saving the marker information corresponding to the current batch of marker objects. Specifically, the marker saving unit can determine other rectangular marker boxes that have a marker association relationship with the currently selected rectangular marker box based on the currently selected template rectangle or matching area, and save each associated rectangular marker box and its corresponding marker information.
[0107] In some embodiments, the mark saving operation can retain the template rectangle, the matching area, the corresponding rectangular annotation boxes for each matching area, and the annotation association relationships. That is, the mark saving operation can only save the annotation content added by the user or generated synchronously. After the mark is saved, the user can continue to perform the annotation adding operation again for the template rectangle or any matching area, and the batch annotation synchronization module 400 will synchronously apply the redefined annotation information to each associated rectangular annotation box.
[0108] In some embodiments, the batch annotation synchronization module 400 may further include a marker clearing unit (corresponding to...). Figure 3 The Clear Mark control (or simply "Clear Mark") is used to perform mark clearing operations. Responding to user triggers on the Clear Mark control, it clears the annotation information corresponding to the current batch of annotation objects. Specifically, the Clear Mark unit can determine other rectangular annotation boxes that have annotation relationships with the currently selected rectangular annotation box, based on the currently selected template rectangle or matching area, and delete each associated rectangular annotation box and its corresponding annotation information.
[0109] In some embodiments, the mark clearing operation can retain the template rectangle and the matching area. That is, the mark clearing operation can only clear the annotation content subsequently added by the user or generated synchronously, without clearing the template rectangle, matching area, and matching result already determined by the template matching module 300. After clearing the marks, the user can continue to re-execute the annotation adding operation for the template rectangle or any matching area, and the batch annotation synchronization module 400 will synchronously apply the newly determined annotation information to each associated rectangular annotation box.
[0110] In some embodiments, the marker clearing unit can send the corresponding marker status to the operation history management module 600 before and after the marker clearing operation occurs, so as to save a snapshot of the status before clearing and a snapshot of the status after clearing. Therefore, the user can, after accidentally triggering the marker clearing control, use... Figure 3 The undo control restores the annotation information before it was cleared.
[0111] In some embodiments, such as Figure 6 As shown, the annotation information display unit can obtain the annotation results, such as the number of rectangles and annotation information, determined by the batch annotation synchronization module 400, and output the annotation result information to the operation control area for display. The annotation result information may include at least one of the following: the number of rectangles and annotation information. The annotation information includes the annotation content and the annotation position and size of the corresponding rectangle annotation frame. For example, as... Figure 6 As shown, the number of rectangles can be displayed as "20 rectangles". The annotation information includes: "id":"template-1782985815169","type": "RECT",shape": {"X":13099.033371444899,"Y":31.068009731190614,"width":2655.6099760744573,"height": 3632.674023875437"}, where the annotation content can include at least one of id and type.
[0112] In some embodiments, the configurations of the image loading and display module 100, the rectangle drawing module 200, the template matching module 300, and the batch annotation synchronization module 400 can refer to the same or related technical content in the first aspect, and will not be repeated here. That is to say, the descriptions in the first aspect regarding image acquisition, template rectangle determination, template image acquisition, template matching, candidate matching region filtering, rectangle annotation box generation, annotation association establishment, and annotation information synchronous update can all be applied to the image batch annotation system of the embodiments of this application.
[0113] Therefore, in the image batch annotation system of this invention, the image loading and display module 100 can acquire and display the image to be annotated, the rectangle drawing module 200 can determine the template rectangle in response to user operation, the template matching module 300 can determine multiple matching regions based on the template image, and the batch annotation synchronization module 400 can generate rectangular annotation boxes in batches at the template rectangle and each matching region, and synchronously apply the annotation information determined at any associated region to other associated regions. Through the cooperation between the above modules, the user's operations of drawing annotation boxes, adding annotation content, and modifying annotation information one by one for multiple similar regions can be reduced, thereby improving the efficiency of image batch annotation and the consistency of annotations between multiple matching regions.
[0114] Optionally, the image batch annotation system further includes: The contour optimization module 500 is configured to optimize the contour of the template rectangle before the template matching module performs template matching based on the template image, to obtain an optimized template rectangle, and to determine the template image based on the optimized template rectangle; The operation history management module 600 is configured to record the history of annotation changes during the image annotation process and restore the corresponding annotation state in response to undo or redo operations. The annotation data export module 700 is configured to export the template rectangle, each of the matching regions, and the corresponding annotation information; the annotation data export module 700 is configured to export the template rectangle, each of the matching regions, and the corresponding annotation information as a JSON format file; the JSON format file includes the identification information, type information, shape information, and attribute information of each rectangular annotation box; the shape information includes the position and size of the rectangular annotation box, and the attribute information includes the group identifier corresponding to the annotation association relationship.
[0115] In some embodiments, the contour optimization module 500 can be configured to perform contour optimization on the template rectangle determined by the rectangle drawing module 200 after the rectangle drawing module 200 has drawn the template rectangle, before the template matching module 300 performs template matching based on the template image, to obtain an optimized template rectangle, and then determine the template image based on the optimized template rectangle. It is understood that the template rectangle determined by the user through the rectangle drawing operation may only be a rough selection of the target object, and the template rectangle may include background areas, irrelevant textures, edge noise, or adjacent objects around the target object. The contour optimization module 500 can make the boundary of the template rectangle more closely match the actual contour range of the target object, thereby enabling the template matching module 300 to perform template matching based on the optimized template image.
[0116] In some embodiments, the contour optimization module 500 can provide the position, width, and height of the optimized template rectangle to the template matching module 300. The template matching module 300 can obtain a corresponding local image from the image to be labeled based on the optimized template rectangle and use this local image as the template image. Therefore, the template matching module 300 can determine the matching region in the image to be labeled based on a template image that more closely matches the actual boundary of the target object, reducing the impact of the user's initial rough selection range on the accuracy of template matching.
[0117] In some embodiments, the operation history management module 600 may include a status snapshot recording unit and a revocation instruction response unit (corresponding to...). Figure 3 The undo control (which can be simply called "undo") and the redo instruction response unit (corresponding to...) Figure 3 The redo control (which can be abbreviated as "redo") includes a status snapshot recording unit that can be used to record the annotation change history during the image annotation process, an undo command response unit that can be used to respond to the undo operation issued by the user, and a redo command response unit that can be used to respond to the redo operation issued by the user.
[0118] like Figure 3 As shown, the operation history management module 600 can also be configured to respond to user undo operations via the undo control, retrieve the previous state snapshot from the history record before the current state snapshot, and restore the corresponding annotation state based on the previous state snapshot. It can also respond to user redo operations triggered by the redo control, restoring the annotation state corresponding to the next state snapshot after the current state snapshot. Users can first draw a template rectangle at one of the circuit board units and determine multiple matching areas based on the template rectangle. When users find that the template rectangle range is inappropriate, the number of matching areas is abnormal, or the annotation content is incorrect, they can use the undo control in the operation toolbar above to restore to the corresponding previous annotation state. If users still need to resume subsequent operations after undoing, they can use the redo control to restore the template rectangle, matching areas, rectangular annotation boxes, and annotation information corresponding to the next state snapshot.
[0119] In some embodiments, the annotation data export module 700 may include an export instruction receiving unit, an annotation data collection unit, a data format conversion unit, and a file output unit. The export instruction receiving unit can receive a user's trigger operation for saving annotation controls and trigger the annotation data export module 700 to export the batch annotation results of the current image. The annotation data collection unit can obtain the template rectangle data, matching area data, rectangular annotation box data, and annotation relationship data corresponding to the current image to be annotated. The template rectangle data and matching area data may include the position, width, height, and area identifier of the corresponding area. The rectangular annotation box data may include the identifier information, position, size, display style, and valid status of each rectangular annotation box. The annotation relationship data may include the group identifier, association record, or mapping relationship between the template rectangle and each matching area. The data format conversion unit can convert the obtained annotation data into JSON format data. The JSON format data may include the identifier information, type information, shape information, and attribute information of each rectangular annotation box. The file output unit can save the JSON format data as a JSON format file and output it to a local storage location, a server storage location, a database, or other data storage location. For example, after completing the drawing of the template rectangle, the determination of the matching area, and the synchronization of annotation information, the user saves the batch annotation results of the current image as a JSON format file.
[0120] In some embodiments, the identification information can be used to uniquely identify the corresponding rectangular annotation box; the type information can be used to distinguish the rectangular annotation box corresponding to the template rectangle, the rectangular annotation box corresponding to the matching region, or other types of annotation objects; the shape information can include the position and size of the rectangular annotation box, such as the horizontal coordinate, vertical coordinate, width, and height; the attribute information can include the group identifier corresponding to the annotation association relationship, and other information related to the annotation object. Therefore, the exported JSON format file can not only be used to save the batch annotation results of images, but also retain the template rectangle, the matching region, and the association relationships between each rectangular annotation box, so as to facilitate subsequent annotation result recovery, annotation result verification, training data conversion, model training, or other data processing.
[0121] In some embodiments, the configuration of the contour optimization module 500, the operation history management module 600, and the annotation data export module 700 can be referred to the same or related technical content in the first aspect, and will not be repeated here.
[0122] In some embodiments, the contour optimization module 500 can improve the correspondence between the template image and the actual target object before template matching; the operation history management module 600 can save, revoke, and redo the state changes during the batch annotation process of the image; and the annotation data export module 700 can output the template rectangle, matching area, annotation association relationship, and annotation information in a structured manner.
[0123] Therefore, through the cooperation between the contour optimization module 500, the operation history management module 600, and the annotation data export module 700, the image loading and display module 100, the rectangle drawing module 200, the template matching module 300, and the batch annotation synchronization module 400, the accuracy of template matching can be improved, the possibility of repeated annotation processing after erroneous operation can be reduced, and the batch annotation results of images can be saved and retrieved in JSON format files containing rectangle positions, dimensions, annotation text, and group identifiers.
[0124] Optionally, the contour optimization module is configured to: extract a local image containing the template rectangle and a preset boundary margin from the image to be labeled; perform grayscale processing, filtering processing, and edge detection on the local image; and perform contour search based on the edge detection results; determine a target contour from the found contours that satisfies an area greater than a preset minimum contour area; determine the circumscribed rectangle of the target contour, and map the circumscribed rectangle to the coordinate system of the image to be labeled to obtain the optimized template rectangle.
[0125] In some embodiments, the contour optimization module 500 may include a local image acquisition unit and an edge sensitivity setting unit (corresponding to...). Figure 3 The control adjusts the edge sensitivity (referred to as "edge sensitivity"), and the minimum outline area setting unit (corresponding to...). Figure 3 The system includes a minimum contour area adjustment control (referred to as "minimum contour area"), an image preprocessing and edge detection unit, a contour finding and target contour determination unit, and an outer rectangle mapping unit. Specifically: The local image acquisition unit can extract a local image containing a template rectangle and a preset boundary margin from the image to be labeled. This local image can then be sent to the image preprocessing and edge detection unit. The edge sensitivity setting unit can receive edge sensitivity parameters input by the user through an edge sensitivity adjustment control and provide these parameters to the image preprocessing and edge detection unit. These edge sensitivity parameters can be used to determine the edge response intensity criteria during edge detection, such as the high and low thresholds in Canny edge detection. Users can adjust the edge sensitivity parameters based on the edge clarity of the corresponding area of the template rectangle, the complexity of the background, or the level of image noise. The image preprocessing and edge detection unit can perform grayscale processing, filtering, and edge detection on the local image. The contour search and target contour determination unit... The module 500 can perform contour search based on edge detection results to obtain multiple contours. The contour search and target contour determination unit can determine the contour area corresponding to each contour respectively, and filter out candidate contours with an area greater than the preset minimum contour area based on the preset minimum contour area parameter provided by the minimum contour area setting unit. The circumscribed rectangle mapping unit can determine the circumscribed rectangle of the target contour in the local image coordinate system, and map the circumscribed rectangle to the original coordinate system of the image to be labeled according to the coordinate offset of the local image relative to the image to be labeled, so as to obtain an optimized template rectangle. The optimized template rectangle can include position information, width information and height information. The contour optimization module 500 can send the optimized template rectangle to the template matching module 300 so that the template matching module 300 can determine the template image based on the image area defined by the optimized template rectangle and perform subsequent template matching processing.
[0126] In some embodiments, the minimum contour area setting unit can receive a preset minimum contour area parameter input by the user through the minimum contour area adjustment control, and provide the preset minimum contour area parameter to the contour search and target contour determination unit. The preset minimum contour area parameter can be used to filter out noise contours, local texture contours, or other non-target object contours with small areas. The user can adjust the preset minimum contour area parameter according to the actual size of the target object corresponding to the template rectangle, the noise distribution in the local image, or the degree of edge continuity. When the contour search and target contour determination unit does not find a candidate contour with an area greater than the preset minimum contour area, or when none of the candidate contours meet the preset contour conditions, the contour optimization module 500 can output the initial template rectangle as an optimized template rectangle to the template matching module 300. This avoids interruption of the template matching process due to unclear image edges, insufficient contrast between the target object and the background, or large local image noise.
[0127] For example, such as Figure 3As shown, after a user draws a template rectangle at a circuit board unit within the image interaction area, they can set edge sensitivity parameters using the edge sensitivity adjustment controls and preset minimum contour area parameters using the minimum contour area adjustment controls. The contour optimization module 500 can then perform grayscale processing, filtering, edge detection, contour finding, and target contour determination on the local image corresponding to the template rectangle based on the user-set parameters, and provide the resulting optimized template rectangle to the template matching module 300. Thus, the template matching module 300 can determine matching areas for other repeating circuit board units in the image to be labeled based on a template image that more closely matches the actual boundaries of the circuit board unit.
[0128] In some embodiments, the specific configuration of the contour optimization module 500, the local image cropping method, the grayscale processing method, the filtering processing method, the edge detection method, the contour finding method, the target contour determination method, and the coordinate mapping method can be referred to the same or related technical content in the first aspect, and will not be repeated here.
[0129] Optionally, the operation history management module is configured to save a state snapshot corresponding to the current annotation state when a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation is generated; the state snapshot includes rectangle annotation box data, template rectangle data, matching area data, and annotation association data; in response to the undo operation, the previous state snapshot is obtained from the history record and the annotation state corresponding to the previous state snapshot is restored; in response to the redo operation, the annotation state corresponding to the next state snapshot is restored.
[0130] In some embodiments, the specific configuration, state snapshot composition, historical record storage method, undo processing method, and redo processing method of the operation history management module 600 can be found in the same or related technical content in the first aspect, and will not be repeated here.
[0131] Thirdly, this application provides an image annotation device, including a memory and a processor connected in communication, wherein the memory is used to store a computer program, and the processor is used to read the computer program and execute any of the image batch annotation methods described in the first aspect above.
[0132] Those skilled in the art will understand that the image annotation apparatus includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the image batch annotation method described in any of the first aspects above.
[0133] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, perform any of the image batch annotation methods described in the first aspect above.
[0134] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device via various interfaces and lines.
[0135] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0136] Wherein, if the modules / units integrated in the terminal device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0137] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without creative effort.
[0138] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for batch image annotation, characterized in that, include: Get the image to be labeled; In response to the rectangle drawing operation for the image to be labeled, a template rectangle is determined; Obtain the template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; Establish a label association relationship between the template rectangle and each of the matching regions. In response to a label addition operation for the template rectangle or any of the matching regions, generate rectangular label boxes at the template rectangle and each of the matching regions respectively, and synchronously apply the determined label information to the rectangular label boxes corresponding to the template rectangle and each of the matching regions. The label information includes the label content and the label position and label size of the corresponding rectangular label box. The step of performing template matching on the image to be labeled based on the template image to determine at least one matching region includes: Convert the image to be labeled and the template image into grayscale images; Move the matching window corresponding to the template image in the image to be labeled, and calculate the normalized correlation coefficient between the template image and each candidate image region; Candidate image regions with a normalized correlation coefficient greater than a preset matching threshold are identified as candidate matching regions; The candidate matching regions are filtered in descending order of the normalized correlation coefficient to determine the matching regions; The candidate matching regions are filtered according to the normalized correlation coefficient from high to low to determine that the matching regions include: If the overlap area between the current candidate matching region and the determined matching region is greater than a preset proportion of the area of the current candidate matching region, discard the current candidate matching region; exclude candidate matching regions whose distance from the template rectangle is less than a preset distance threshold; and determine the filtered candidate matching region as the matching region. Before performing template matching on the image to be labeled based on the template image, the method further includes: optimizing the outline of the template rectangle to obtain an optimized template rectangle, and determining the template image based on the optimized template rectangle; The contour optimization of the template rectangle includes: extracting a local image containing the template rectangle and a preset boundary margin from the image to be labeled; converting the local image into a grayscale image and filtering the grayscale image; performing edge detection on the filtered grayscale image and performing contour search based on the edge detection results; determining a target contour with an area greater than a preset minimum contour area from the found contours; determining the circumscribed rectangle of the target contour and mapping the circumscribed rectangle from the local image coordinate system to the coordinate system of the image to be labeled to obtain the optimized template rectangle; The image batch annotation method also includes: When a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation is performed, a snapshot of the current annotation state is saved. In response to the undo operation, retrieve the previous state snapshot from the history record and restore the labeled state corresponding to the previous state snapshot; In response to a redo operation, restore the labeled state corresponding to the next state snapshot; The status snapshot includes rectangular annotation box data, template rectangle data, matching region data, and annotation association relationship data.
2. A batch image annotation system, employing the batch image annotation method described in claim 1, characterized in that, include: The image loading and display module is configured to acquire and display the image to be labeled. The rectangle drawing module is configured to determine a template rectangle in response to a rectangle drawing operation on the image to be annotated; The template matching module is configured to acquire a template image defined by the template rectangle, and perform template matching on the image to be labeled based on the template image to determine at least one matching region; The batch annotation synchronization module is configured to establish an annotation association relationship between the template rectangle and each of the matching regions. In response to an annotation addition operation for the template rectangle or any of the matching regions, it generates rectangular annotation boxes at the template rectangle and each of the matching regions, and synchronously applies the determined annotation information to the rectangular annotation boxes corresponding to the template rectangle and each of the matching regions. The annotation information includes annotation content and the annotation position and annotation size of the corresponding rectangular annotation box.
3. The image batch annotation system according to claim 2, characterized in that, The image batch annotation system also includes: The contour optimization module is configured to optimize the contour of the template rectangle before the template matching module performs template matching based on the template image, to obtain an optimized template rectangle, and to determine the template image based on the optimized template rectangle; The operation history management module is configured to record the history of annotation changes during the image annotation process and restore the corresponding annotation status in response to undo or redo operations. The annotation data export module is configured to export the template rectangle, each of the matching regions, and the corresponding annotation information.
4. The image batch annotation system according to claim 3, characterized in that, The contour optimization module is configured to: A local image containing the template rectangle and a preset boundary margin is extracted from the image to be labeled. The local image is then subjected to grayscale processing, filtering, and edge detection. Based on the edge detection results, a contour is searched. From the searched contours, a target contour that satisfies an area greater than a preset minimum contour area is determined. The circumscribed rectangle of the target contour is determined and mapped to the coordinate system of the image to be labeled to obtain the optimized template rectangle.
5. The image batch annotation system according to claim 4, characterized in that, The operation history management module is also configured to save a status snapshot corresponding to the current annotation status when a rectangle drawing operation, annotation clearing operation, annotation adding operation, or template matching operation is generated; the status snapshot includes rectangle annotation box data, template rectangle data, matching area data, and annotation association relationship data; In response to the undo operation, the previous state snapshot is retrieved from the history record and the labeled state corresponding to the previous state snapshot is restored; In response to the redo operation, the labeled state corresponding to the next state snapshot is restored.
6. The image batch annotation system according to claim 4, characterized in that, The annotation data export module is configured to export the template rectangle, each of the matching regions and the corresponding annotation information as a JSON format file; The JSON format file includes the identification information, type information, shape information, and attribute information of each rectangular annotation box; The shape information includes the position and size of the rectangular annotation box, and the attribute information includes the group identifier corresponding to the annotation association relationship.
Citation Information
Patent Citations
Image labeling method and device, equipment and storage medium
CN117670884A