Image processing method, device, electronic device and storage medium
By annotating the initial image and setting the background crop proportion value and object proportion value, the problem of incomplete targets and low data expansion efficiency in image cropping is solved, efficient and accurate image cropping is achieved, and the generalization ability and prediction of the model are improved. Accuracy.
Patent Information
- Application Number
- CN202210591631.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-05-27
AI Technical Summary
Image cropping methods in the prior art have problems with incomplete targets and low data expansion efficiency. Especially in the helmet classification model, random cropping results in a large number of invalid images and cannot fully utilize the original training data set.
By annotating the initial image and combining the preset background cropping proportion value and object proportion value, the image cropping range is determined, the target cropping boundary information is obtained, and the ratio of the background and the target object in the cropped sub-image is ensured to be reasonably distributed, thereby conducting efficient Accurate image cropping.
It improves the accuracy and efficiency of image cropping, ensuring that the cropped images better meet the needs, thereby improving the generalization ability and prediction accuracy of model training.
Smart Images

Figure CN115018704B
Abstract
Description
Background Art
[0002] With the development of computer technology, deep learning technology has been widely used due to its efficient feature extraction and classification capabilities. In order to improve the robustness of deep learning networks, it is usually necessary to use a large amount of data to train the network. However, in practical applications, there is often a lack of a large amount of data required for training, so it is necessary to expand the training data set through image processing methods.
[0003] In the related art, the training data set can be expanded by cropping the images in the training data set. Specifically, image cropping is divided into the following two methods: Method 1, the complete target in the image is cut out, but in actual applications there is a problem of incomplete target, and the complete target cannot be cut out, and only cutting out the target will remove the background image, and the images in the original training data set cannot be fully utilized; Method 2, randomly cropping the image, but this random cropping has great uncertainty. For example, in training a helmet classification model, an image containing a helmet is randomly cropped to obtain 100 sub-images, and only 10 of them are sub-images containing helmets. Therefore, the remaining 90 images cannot be used to train the helmet classification model. That is, the data set is expanded based on Method 2, the data expansion efficiency is low, and it is difficult to obtain the required images.
[0004] Therefore, how to efficiently and accurately crop images to obtain images that better meet the needs is a problem that needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide an image processing method, device, electronic device and storage medium for efficiently and accurately performing image cropping.
[0006] An image processing method provided in an embodiment of the present application includes:
[0007] Annotating a target object in an initial image to obtain object boundary information of the target object;
[0008] Determining an image cropping range based on the object boundary information and a preset background cropping ratio value, wherein the background cropping ratio value is used to determine: an area of the background area in the initial image that is related to the background area in the cropped initial sub-image;
[0009] Based on the image cropping range and a preset object proportion value, at least two target cropping boundary information are obtained, wherein the object proportion value is used to represent: the proportion of the target object in the cropped initial sub-image to the target object in the initial image;
[0010] The initial image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two initial sub-images corresponding to the initial image.
[0011] In an optional implementation, obtaining at least two target cropping boundary information based on the image cropping range and a preset object ratio value includes:
[0012] Determine, based on the object proportion value, a target object area related to the target object in the initial image;
[0013] Based on the image cropping range and the target object area, obtaining a plurality of candidate cropping boundary information;
[0014] At least two target cropping boundary information are screened out from the plurality of candidate cropping boundary information based on similarities between the respective candidate cropping boundary information.
[0015] In an optional implementation, the number of target cropping boundary information is a preset cropping number; and determining at least two target cropping boundary information based on the similarity between each candidate cropping boundary information includes:
[0016] Determine the similarity between each candidate cropping boundary information based on the intersection-and-union ratio between the cropping frames corresponding to each candidate cropping boundary information;
[0017] Grouping the candidate cropping boundary information, and respectively calculating the sum of similarities of the candidate cropping boundary information contained in each group, each group containing a preset number of candidate cropping boundary information;
[0018] The candidate cropping boundary information contained in the group with the smallest sum of similarities is used as the target cropping boundary information.
[0019] In an optional implementation, obtaining a plurality of candidate cropping boundary information based on the image cropping range and the target object area includes:
[0020] respectively determining an extended distance between each object boundary of the target object region and a cropping boundary corresponding to the image cropping range, wherein each object boundary is parallel to the corresponding cropping boundary;
[0021] Based on each expansion distance, multiple boundary expansions are performed on the target object area to obtain the multiple candidate cropping boundary information.
[0022] In an optional embodiment, the method further includes:
[0023] Performing cyclic iterative training on the classification model in training based on the training sample data set to obtain a trained classification model, wherein each training sample in the training sample data set includes an initial image and at least two initial sub-images corresponding to the initial image;
[0024] Performing motion target detection on a video containing a target object based on a motion detection model to obtain a test sample data set, wherein each test sample in the test sample data set includes a test image and motion boundary information of the target object in the test image;
[0025] Cropping each test image to obtain a test sub-image of each test image;
[0026] The test images and their corresponding test sub-images are respectively input into the trained classification model to obtain classification results of the test images.
[0027] In an optional implementation, the step of inputting the respective test images and the respective test sub-images into the trained classification model to obtain the classification results of the respective test images includes:
[0028] For each test image, perform the following operations:
[0029] For a test image, input the test image and the corresponding test sub-image into the classification model respectively to obtain a classification result of the test image and a classification result of the corresponding test sub-image;
[0030] A weighted average is performed on the classification result of the one test image and the classification result of the corresponding test sub-image, and the classification result after the weighted average is used as the classification result of the one test image.
[0031] In an optional implementation, the cropping of each test image to obtain a test sub-image of each test image includes:
[0032] For each test image, perform the following operations:
[0033] For a test image, determining the image cropping range based on motion boundary information of the test image and the background cropping ratio value;
[0034] Based on the image cropping range and the target object area, obtaining at least two target cropping boundary information;
[0035] The one test image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two test sub-images corresponding to the one test image.
[0036] An image processing device provided in an embodiment of the present application includes:
[0037] A labeling unit, used to label the target object in the initial image to obtain object boundary information of the target object;
[0038] a determining unit, configured to determine an image cropping range based on the object boundary information and a preset background cropping ratio value, wherein the background cropping ratio value is used to determine: an area of the background area in the initial image that is related to the background area in the cropped initial sub-image;
[0039] an acquisition unit, configured to obtain at least two target cropping boundary information based on the image cropping range and a preset object proportion value, wherein the object proportion value is used to represent: a proportion of the target object in the cropped initial sub-image to the target object in the initial image;
[0040] A cropping unit is used to crop the initial image based on the obtained at least two target cropping boundary information to obtain at least two initial sub-images corresponding to the initial image.
[0041] Optionally, the acquiring unit is specifically used for:
[0042] Determine, based on the object proportion value, a target object area related to the target object in the initial image;
[0043] Based on the image cropping range and the target object area, obtaining a plurality of candidate cropping boundary information;
[0044] At least two target cropping boundary information are screened out from the plurality of candidate cropping boundary information based on similarities between the respective candidate cropping boundary information.
[0045] Optionally, the amount of the target cropping boundary information is a preset cropping amount; and the determining unit is specifically configured to:
[0046] Determine the similarity between each candidate cropping boundary information based on the intersection-and-union ratio between the cropping frames corresponding to each candidate cropping boundary information;
[0047] Grouping the candidate cropping boundary information, and respectively calculating the sum of similarities of the candidate cropping boundary information contained in each group, each group containing a preset number of candidate cropping boundary information;
[0048] The candidate cropping boundary information contained in the group with the smallest sum of similarities is used as the target cropping boundary information.
[0049] Optionally, the acquiring unit is specifically used for:
[0050] respectively determining an extended distance between each object boundary of the target object region and a cropping boundary corresponding to the image cropping range, wherein each object boundary is parallel to the corresponding cropping boundary;
[0051] Based on each expansion distance, multiple boundary expansions are performed on the target object area to obtain the multiple candidate cropping boundary information.
[0052] Optionally, the device further comprises a training unit, configured to:
[0053] Performing cyclic iterative training on the classification model in training based on the training sample data set to obtain a trained classification model, wherein each training sample in the training sample data set includes an initial image and at least two initial sub-images corresponding to the initial image;
[0054] Performing motion target detection on a video containing a target object based on a motion detection model to obtain a test sample data set, wherein each test sample in the test sample data set includes a test image and motion boundary information of the target object in the test image;
[0055] Cropping each test image to obtain a test sub-image of each test image;
[0056] The test images and their corresponding test sub-images are respectively input into the trained classification model to obtain classification results of the test images.
[0057] Optionally, the training unit is specifically used for:
[0058] For each test image, perform the following operations:
[0059] For a test image, input the test image and the corresponding test sub-image into the classification model respectively to obtain a classification result of the test image and a classification result of the corresponding test sub-image;
[0060] A weighted average is performed on the classification result of the one test image and the classification result of the corresponding test sub-image, and the classification result after the weighted average is used as the classification result of the one test image.
[0061] Optionally, the training unit is specifically used for:
[0062] For each test image, perform the following operations:
[0063] For a test image, determining the image cropping range based on motion boundary information of the test image and the background cropping ratio value;
[0064] Based on the image cropping range and the target object area, obtaining at least two target cropping boundary information;
[0065] The one test image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two test sub-images corresponding to the one test image.
[0066] An electronic device provided in an embodiment of the present application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above-mentioned image processing methods.
[0067] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to perform the steps of any one of the above-mentioned image processing methods.
[0068] An embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any one of the above-mentioned image processing methods.
[0069] The beneficial effects of this application are as follows:
[0070] The embodiments of the present application provide an image processing method, device, electronic device and storage medium. The present application can determine the boundary of the target object by marking the target object in the initial image, and then perform image cropping in combination with the boundary of the object, and the preset background cropping ratio value and object proportion value. By setting the background cropping ratio value, the background area in the initial image can appear in the cropped initial sub-image as needed, and by setting the object proportion value, it can be ensured that part of the target image can appear in the cropped sub-image. Therefore, the image processing method in the present application fully considers the background area and the target object in the image, quantitatively analyzes the ratio of the two in the cropped image, and can efficiently and accurately crop the image to obtain an image that better meets the needs; further, when other processing is performed based on the obtained cropped image, the processing efficiency and accuracy can be further improved, such as when performing model training, the generalization ability of the model can be improved, and the accuracy of model prediction can be improved.
[0071] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0073] Figure 1 is a schematic diagram of an initial image in an embodiment of the present application;
[0074] Figure 2 An optional schematic diagram of an application scenario in an embodiment of the present application;
[0075] Figure 3 is a flowchart of an implementation of an image processing method in an embodiment of the present application;
[0076] Figure 4 A schematic diagram of a method for marking a target object in an embodiment of the present application;
[0077] Figure 5 A schematic diagram of an image cropping range in an embodiment of the present application;
[0078] Figure 6 A schematic diagram of an image expansion method in an embodiment of the present application;
[0079] Figure 7 A schematic diagram of a method for obtaining candidate cropping boundary information in an embodiment of the present application;
[0080] Figure 8 This is a schematic diagram of the overall process of an image processing method in an embodiment of the present application;
[0081] Fig. 9 A schematic diagram of the structure of an image processing device in an embodiment of the present application;
[0082] Fig.10 A schematic diagram of a hardware structure of an electronic device to which an embodiment of the present application is applied;
[0083] Fig.11 The present invention is a schematic diagram of the hardware structure of another electronic device to which the embodiments of the present application are applied. DETAILED DESCRIPTION
[0084] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0085] The following is an introduction to some concepts involved in the embodiments of the present application.
[0086] Object boundary information: refers to the boundary of the target object in the initial image. The target object can be marked by a rectangular box, and each rectangular box tightly surrounds the target object. The object boundary information can be represented by the coordinates of the rectangular box. Figure 1 As shown, the rectangular frame 1 represents the area where the fully surrounded target object is located.
[0087] Background cropping ratio value: indicates the ratio of the background area in the cropped initial sub-image to the background area in the initial image. For example, when the background cropping ratio value is b, it means that the background area in the cropped initial sub-image comes from an area that is b times the size of the target object. The range of image cropping in the initial image is determined by the background cropping ratio value. Figure 1 Rectangular frame 2 is the image cropping range determined according to the background cropping ratio value, rectangular frame 3 and rectangular frame 4 are initial sub-images in two different situations, rectangular frame 3 is the cropping result that fully surrounds the target object, and rectangular frame 4 is the initial sub-image after the cropped image that does not fully surround the target object.
[0088] Object proportion value: refers to the ratio of the target object in the cropped initial sub-image to the target object in the initial image. According to the object proportion value, the part of the target object that must be included in the cropped initial sub-image can be determined.
[0089] Target cropping boundary information: used to crop the image according to the target cropping boundary information. The target cropping boundary information is screened out from the candidate cropping boundary information and can be represented by a cropping box.
[0090] Greedy algorithm: It is a simpler and faster design technology for some optimal solution problems. The characteristic of greedy algorithm is that it proceeds step by step, often based on the current situation to make the best choice according to a certain optimization measure, without considering various possible overall situations. It saves a lot of time that must be spent to exhaust all possibilities to find the optimal solution. It uses a top-down, iterative method to make successive greedy choices. Each greedy choice simplifies the problem into a smaller sub-problem. Through each step of greedy choice, an optimal solution to the problem can be obtained. Although it is necessary to ensure that the local optimal solution can be obtained at each step, the resulting global solution is sometimes not necessarily the optimal, so the greedy algorithm does not require backtracking.
[0091] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0092] like Figure 2 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes two terminal devices 210 and a server 220.
[0093] In the embodiment of the present application, the terminal device 210 includes but is not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals and other devices; the terminal device may be installed with a client related to image processing, which may be software (such as a browser, drawing software, etc.), or a web page, a small program, etc. The server 220 is a background server corresponding to the software or web page, small program, etc., or a server specifically used for image processing, which is not specifically limited in the present application. The server 220 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0094] It should be noted that the image processing method in the embodiment of the present application can be executed by an electronic device, and the electronic device can be a server 220 or a terminal device 210, that is, the method can be executed by the server 220 or the terminal device 210 alone, or can be executed by the server 220 and the terminal device 210 together. For example, when the method is executed by the server 220 and the terminal device 210 together, the terminal device 210 sends the initial image to the server 220, and the server 220 marks the target object in the initial image, obtains the object boundary information of the target object, and determines the image cropping range based on the object boundary information and the preset background cropping ratio value, and then obtains at least two target cropping boundary information based on the image cropping range and the preset object ratio value, and finally crops the initial image based on the at least two target cropping boundary information obtained, respectively, to obtain at least two initial sub-images corresponding to the initial image, and sends the initial image and the corresponding sub-image to the terminal device 210.
[0095] In an optional implementation, the terminal device 210 and the server 220 may communicate with each other via a communication network.
[0096] In an optional implementation, the communication network is a wired network or a wireless network.
[0097] It should be noted that Figure 2 The figure is only an example. In fact, the number of terminal devices and servers is not limited and is not specifically limited in the embodiments of the present application.
[0098] In an embodiment of the present application, when there are multiple servers, the multiple servers can form a blockchain, and the servers are nodes on the blockchain; as in the image processing method disclosed in the embodiment of the present application, the initial image and the corresponding sub-image involved can be saved on the blockchain.
[0099] In addition, the embodiments of the present application can be applied to various scenarios, including not only image processing scenarios, but also including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios.
[0100] The image processing method provided by the exemplary embodiment of the present application is described below in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this regard.
[0101] See also Figure 3 As shown, it is an implementation flow chart of an image processing method provided in an embodiment of the present application. Taking the execution subject as a server as an example, the specific implementation process of the method includes the following steps S31-S34:
[0102] S31: The server marks the target object in the initial image to obtain object boundary information of the target object;
[0103] Among them, the target object can be marked by a rectangular box, and each rectangular box tightly surrounds the target object, such as Figure 4 As shown, it is a schematic diagram of a method for marking a target object in an embodiment of the present application, wherein a worker wearing a safety helmet is the target object, and the target frame is a rectangular frame for marking the target object in the initial image. Furthermore, the object boundary information can be represented by the coordinates of the rectangular frame, for example, by the coordinates of the lower left corner and the upper right corner of the rectangular frame, or by the coordinates of the center point and the width and height of the rectangular frame, which is not specifically limited in the present application.
[0104] S32: The server determines the image cropping range based on the object boundary information and a preset background cropping ratio value;
[0105] The background cropping ratio value is used to determine the area of the background area in the initial image that is related to the background area in the cropped initial sub-image. For example, the background cropping ratio value can be set to a number greater than or equal to 1. For example, if the background cropping ratio value is set to 2.5, the background in the cropped initial sub-image comes from 2.5 times the size of the surrounding area of the target object, which limits the cropping range of the image.
[0106] like Figure 5 As shown in the figure, taking the background cropping ratio value of 2.5 as an example, the shadow part is the image cropping range, and the background area in the cropped initial sub-image can only be taken from the shadow part, and will not be taken from the area other than the shadow part in the initial image (i.e. Figure 5 ).
[0107] In an embodiment of the present application, the user can set the background cropping ratio value according to the needs, and perform image cropping within a determined image cropping range, thereby removing irrelevant areas in the initial image and obtaining an image that better meets the needs.
[0108] S33: The server obtains at least two target cropping boundary information based on the image cropping range and the preset object ratio value;
[0109] The object ratio value is used to represent: the proportion of the target object in the cropped initial sub-image to the target object in the initial image. The object ratio value (occlusion threshold) is between 0 and 1, for example, it is set to 0.5. Based on the object ratio value, it is possible to determine the part of the target object that must be included in the cropped initial sub-image. For example, if the object ratio value is 0.5, Figure 6As shown, the shaded part is the part of the target object that must be included according to the object proportion value, rectangular frame 1 is the image cropping range, and rectangular frame 2 is the object boundary information of the target object. Within the image cropping range, the part of the target object that must be included is taken as the center, and it is expanded up, down, left, and right until the boundary of the image cropping range is reached, so that at least two target cropping boundary information can be obtained.
[0110] In the embodiment of the present application, the portion of the target object that must be included in the cropped sub-image can be limited by a preset object ratio value, thereby avoiding target loss caused by random cropping, and the cropped sub-image can better meet the needs.
[0111] Considering that based on the preset object ratio value and background cropping ratio value, a lot of candidate cropping boundary information that meets the requirements can be obtained to crop the corresponding initial sub-image. In order to maximize the use of the target object and further improve the difference between the initial sub-images, the candidate cropping boundary information can also be screened to obtain the target cropping boundary information in the following way:
[0112] In an optional implementation, step S33 may be implemented as the following steps S41-S43:
[0113] S41: determining a target object region related to the target object in the initial image based on the object proportion value;
[0114] S42: obtaining a plurality of candidate cropping boundary information based on the image cropping range and the target object area;
[0115] S43: based on the similarities between the respective candidate cropping boundary information, at least two target cropping boundary information are screened out from the plurality of candidate cropping boundary information.
[0116] Specifically, the target object area determined according to the object proportion value, that is, the part of the target object that must be included in the cropped sub-image, see Figure 6 The shaded part in the image is expanded up, down, left, and right to the boundary of the image cropping range with the target object area as the center within the image cropping range, and multiple candidate cropping boundary information (candidate cropping boxes) can be obtained. Then, based on the similarity between the candidate cropping boundary information, the target cropping boundary information is screened out. For example, n candidate cropping boundary information with the smallest sum of similarities can be screened out from m candidate cropping boundaries as the target cropping boundary information, where m and n are both positive integers, and m is greater than n.
[0117] By determining the target cropping boundary information based on the above method, the target object can be maximized, the differences between the cropped initial sub-images are maximized, and the types of the initial sub-images are effectively enriched.
[0118] In an optional implementation, step S42 may be implemented as follows:
[0119] First, the extension distances between each object boundary of the target object area and the cropping boundary corresponding to the image cropping range are determined respectively; then, based on each extension distance, multiple boundary extensions are performed on the basis of the target object area to obtain multiple candidate cropping boundary information.
[0120] Here, each object boundary is parallel to the corresponding clipping boundary, for example, Figure 6 The upper cropping boundary of the image cropping range is parallel to the upper object boundary of the target object area. Within the image cropping range, with the target object area as the center, based on various expansion distances, the image is expanded up, down, left, and right until the cropping boundary, and multiple candidate cropping boundary information can be obtained. It should be noted that each expansion can obtain one candidate cropping boundary information by expanding in any direction of up, down, left, and right, and the image can also be expanded in multiple directions at the same time.
[0121] See also Figure 7 , which is a schematic diagram of a method for obtaining candidate cropping boundary information in an embodiment of the present application, wherein rectangular box 1 represents the image cropping range, rectangular box 2 represents the target object, the black part represents the target object area, the shaded part represents the target object area, the lower left corner coordinates of rectangular box 2 where the target object is located are (x1, y1), the upper right corner coordinates are (x2, y2), the object ratio value is a, and the background cropping ratio value is b. Then, the length of the upper cropping boundary of the image cropping range is (x2-x1)*b, the length of the left cropping boundary is (y2-y1)*b, the upper object boundary of the target object area is (x2-x1)*a, and the length of the left cropping boundary is (y2-y1)*a. The lengths of the left extension distance and the right extension distance are [(x2-x1)*(b-1)+(x2-x1)*(1-a)] / 2, and the lengths of the upper extension distance and the lower extension distance are [(y2-y1)*(b-1)+(y2-y1)*(1-a)] / 2. Each extension distance is divided into five parts. For example, there are 5*5*5*5=625 candidate cropping boundary information in the upper, lower, left and right directions. Figure 7 Only three candidate cropping boundary information are given as examples, and each candidate cropping boundary information satisfies: Area(candidate cropping boundary information)∩(target object) / Area(target object)>a.
[0122] It should be noted that here, the target object area is located in the middle of the target object and in the middle of the image cropping range. Therefore, the left extension distance and the right extension distance are equal, and the upper extension distance and the lower extension distance are equal. In fact, the sum of the left extension distance and the right extension distance is certain, and the sum of the upper extension distance and the lower extension distance is certain. The size of each extension distance can be set according to actual needs, and this article does not make specific limitations.
[0123] In an optional implementation, the amount of target cropping boundary information is a preset cropping amount; step S43 may be implemented as follows:
[0124] First, the similarities between the candidate cropping boundary information are determined based on the intersection-and-union ratios between the cropping frames corresponding to the candidate cropping boundary information; then, the candidate cropping boundary information are grouped, and the sum of the similarities of the candidate cropping boundary information contained in each group is calculated, each group containing a preset number of candidate cropping boundary information; finally, the candidate cropping boundary information contained in the group with the smallest sum of similarities is used as the target cropping boundary information.
[0125] Specifically, the intersection-and-union ratio can be used as a condition to measure the similarity. For example, m candidate cropping boundary information is obtained, and the preset cropping number is n. The m candidate cropping boundary information is grouped, and each group contains n candidate cropping boundary information. For the candidate cropping boundary information in each group, the intersection-and-union ratio between each candidate cropping boundary information and other candidate cropping boundary information is calculated respectively, and the candidate cropping boundary information contained in the group with the smallest sum of the intersection-and-union ratios is used as the target cropping boundary information.
[0126] Optionally, a greedy algorithm is used to solve the n candidate cropping boundary information with the smallest total intersection-and-union ratio among the m candidate cropping boundary information, and there are a total of m*(m-1) / 2 intersection-and-union ratios to be calculated.
[0127] The core of the greedy algorithm is to select a measurement standard according to the problem, which is the minimum total intersection and union ratio between m candidate cropping boundary information in this application, and then arrange these multiple inputs into the order required by this measurement standard, and input one quantity at a time in this order. If this input and the current partial optimal solution under this measurement cannot produce a feasible solution, then this input is not added to this partial solution, which ensures that a local optimal solution can be obtained, and it is easier and faster to find the n candidate cropping boundary information with the minimum total intersection and union ratio, saving a lot of time that must be spent to exhaust all possibilities to find the optimal solution.
[0128] Through the above method, when the object proportion value is a, the cropping boxes with the smallest n similarities and the smallest sum of intersection and union ratios (that is, the cropping boxes determined based on the target cropping boundary information) can be obtained.
[0129] S34: The server crops the initial image based on the obtained at least two target cropping boundary information respectively to obtain at least two initial sub-images corresponding to the initial image.
[0130] Specifically, the initial object is cropped according to the cropping frame determined by the target cropping boundary information to obtain an initial sub-image.
[0131] In an embodiment of the present application, by marking the target object in the initial image, the boundary of the target object can be determined, and then the image can be cropped in combination with the boundary of the object, and the preset background cropping ratio value and object proportion value. By setting the background cropping ratio value, the background area in the initial image can appear in the cropped initial sub-image as needed, and by setting the object proportion value, it can be ensured that part of the target image can appear in the cropped sub-image. Therefore, the image processing method in the present application fully considers the background area and the target object in the image, quantitatively analyzes the ratio of the two in the cropped image, and can efficiently and accurately perform image cropping to obtain an image that better meets the needs; further, when other processing is performed based on the obtained cropped image, the processing efficiency and accuracy can be further improved. For example, when performing model training, the generalization ability of the model can be improved, and the accuracy of model prediction can be improved.
[0132] In an optional implementation, after obtaining the initial sub-image corresponding to the initial image based on the above steps S31-S34, the following steps may be further performed:
[0133] S51: performing cyclic iterative training on the classification model in training based on the training sample data set to obtain a trained classification model, wherein each training sample in the training sample data set includes an initial image and at least two initial sub-images corresponding to the initial image;
[0134] S52: performing motion target detection on the video containing the target object based on the motion detection model to obtain a test sample data set, where each test sample in the test sample data set includes a test image and motion boundary information of the target object in the test image;
[0135] S53: cropping each test image to obtain a test sub-image of each test image;
[0136] S54: Input each test image and its corresponding test sub-image into the trained classification model to obtain the classification result of each test image.
[0137] Specifically, based on steps S31-S34, multiple initial images are cropped to obtain initial sub-images corresponding to each initial image, a training sample data set is constructed based on the initial image and the initial sub-image, and a suitable deep learning model (i.e., the classification model in training) is selected for training to obtain a target image classification model (i.e., a trained classification model). Since the training sample data set contains images with different occlusion degrees and background information, the robustness of the classification model is relatively high. In actual use, the motion detection model can be applied to a video containing the motion of the target object, and a test image containing the target object and the motion boundary information of the target object can be obtained. Based on the image processing method in steps S31-S34, the test image is cropped to obtain a test sub-image of each test image, and the obtained test sub-image is an image containing a plurality of targets with different occlusion degrees and background ratios. Finally, the acquired test image and test sub-image are input into the classification model, and the test time data enhancement (TTA) technology is used, that is, the classification results of the input test image and test sub-image are weighted averaged to obtain the result, so as to improve the reliability of the overall prediction.
[0138] In an optional implementation, step S53 may be implemented as follows:
[0139] For a test image, first, based on the motion boundary information of the test image and the background cropping ratio value, the image cropping range is determined; then, based on the image cropping range and the target object area, at least two target cropping boundary information are obtained; finally, based on the at least two target cropping boundary information obtained, the test image is cropped to obtain at least two test sub-images corresponding to the test image.
[0140] Specifically, for the process of cropping the test image to obtain the test sub-image, refer to the embodiment of cropping the initial image to obtain the initial sub-image, which will not be described in detail here.
[0141] In an optional implementation, step S54 may be implemented as follows:
[0142] For a test image, firstly, a test image and a corresponding test sub-image are respectively input into the classification model to obtain a classification result of the test image and a classification result of the corresponding test sub-image; then, the classification result of the test image and the classification result of the corresponding test sub-image are weightedly averaged, and the classification result after the weighted average is used as the classification result of a test image.
[0143] Specifically, taking test image 1 and the corresponding test sub-image 11 and test sub-image 12 as an example, after inputting test image 1, test sub-image 11 and test sub-image 12 into the classification model, the probability that test image 1 belongs to category 1 is 0.6, the probability that test sub-image 11 belongs to category 1 is 0.2, and the probability that test sub-image 12 belongs to category 1 is 0.7. After averaging the above three classification results, the probability that test image 1 belongs to category 1 is 0.5.
[0144] In an embodiment of the present application, the optimal solution for cropping can be given within the given fixed parameters such as the object proportion value, the background cropping ratio value, and the preset cropping quantity. The similarity between images is minimized, and the model is trained based on the cropped images. The model has a stronger generalization ability and can be applied to the prediction results of the TTA technology model to better utilize the target and background information and improve the accuracy of the model prediction.
[0145] See also Figure 8 , which is a schematic diagram of the overall flow of an image processing method in an embodiment of the present application, comprising the following steps:
[0146] S81: Acquire an image dataset containing a target object;
[0147] S82: manually annotate the obtained image data set. Here, rectangular box annotation is taken as an example, and each box tightly surrounds the target.
[0148] S83: Perform data enhancement on the obtained labeled image using an image cropping algorithm to obtain a target cropped data enhancement data set.
[0149] S84: Use the obtained target cropping data to enhance the data set, select a suitable deep learning model for training, and obtain a target image classification model;
[0150] S85: applying a motion detection algorithm to the video containing the target motion, obtaining an image containing the target and the coordinates of the target;
[0151] S86: applying an image cropping algorithm to the obtained image containing the target and the coordinates of the target to obtain a plurality of cropped data enhanced images with different occlusion degrees and background ratios;
[0152] S87: Input the obtained cropped data enhanced image into the target image classification model, and use the TTA technology to perform weighted averaging on the classification results of the input multiple images to obtain the result.
[0153] Among them, after the target in the given image is determined, the image cropping algorithm in S83 uses the target proportion (i.e., object proportion value) and the background cropping range (i.e., background cropping ratio) within the fixed parameter range to crop a fixed number of pictures (the fixed number is a positive integer greater than or equal to 1), and uses the above two conditions to crop the target to maximize utilization, that is, the difference between the fixed number of cropped pictures is the largest. In S85, the motion detection algorithm is applied to the video containing the target motion. The target recognition result is greatly affected by the scene. In a high probability, only part of the moving target can be detected. The detection result is similar to the result of the cropping algorithm in S83, and the occlusion ratio can be controlled. For this situation, there will be a good recognition effect.
[0154] In the embodiment of the present application, from the perspective of image target cropping, the background area and target object information can be taken into account, and the ratio between the two in the cropped image can be quantitatively analyzed, which can be better used for data enhancement and TTA technology in predicted images.
[0155] Based on the same inventive concept, the present application also provides an image processing device. Fig. 9 As shown, it is a schematic diagram of the structure of an image processing device 900, which may include:
[0156] A labeling unit 901 is used to label the target object in the initial image to obtain the object boundary information of the target object;
[0157] A determination unit 902 is used to determine an image cropping range based on object boundary information and a preset background cropping ratio value, wherein the background cropping ratio value is used to determine: an area related to a background area in an initial image and a background area in a cropped initial sub-image;
[0158] An acquisition unit 903 is used to obtain at least two target cropping boundary information based on the image cropping range and a preset object ratio value, where the object ratio value is used to represent: the ratio of the target object in the cropped initial sub-image to the target object in the initial image;
[0159] The cropping unit 904 is configured to crop the initial image based on the at least two target cropping boundary information obtained to obtain at least two initial sub-images corresponding to the initial image.
[0160] Optionally, the acquiring unit 903 is specifically configured to:
[0161] Determine, based on the object proportion value, a target object region related to the target object in the initial image;
[0162] Based on the image cropping range and the target object area, multiple candidate cropping boundary information is obtained;
[0163] At least two target cropping boundary information are screened out from the plurality of candidate cropping boundary information based on the similarity between each candidate cropping boundary information.
[0164] Optionally, the amount of target cropping boundary information is a preset cropping amount; the determining unit 902 is specifically configured to:
[0165] Determine the similarity between each candidate cropping boundary information based on the intersection-and-union ratio between the cropping frames corresponding to each candidate cropping boundary information;
[0166] Grouping each candidate cropping boundary information, and respectively calculating the sum of similarities of the candidate cropping boundary information contained in each group, each group containing a preset number of candidate cropping boundary information;
[0167] The candidate cropping boundary information contained in the group with the smallest sum of similarities is used as the target cropping boundary information.
[0168] Optionally, the acquiring unit 903 is specifically configured to:
[0169] Determining respectively the extension distance between each object boundary of the target object region and the cropping boundary corresponding to the image cropping range, wherein each object boundary is parallel to the corresponding cropping boundary;
[0170] Based on each expansion distance, multiple boundary expansions are performed on the target object area to obtain multiple candidate cropping boundary information.
[0171] Optionally, the device further comprises a training unit 905, for
[0172] Performing cyclic iterative training on the classification model in training based on the training sample data set to obtain a trained classification model, wherein each training sample in the training sample data set includes an initial image and at least two initial sub-images corresponding to the initial image;
[0173] Based on the motion detection model, a video containing a target object is subjected to motion target detection to obtain a test sample data set, wherein each test sample in the test sample data set includes a test image and motion boundary information of the target object in the test image;
[0174] Cropping each test image to obtain a test sub-image of each test image;
[0175] Each test image and its corresponding test sub-image are respectively input into the trained classification model to obtain the classification result of each test image.
[0176] Optionally, the training unit 905 is specifically used for:
[0177] For each test image, perform the following operations:
[0178] For a test image, input a test image and a corresponding test sub-image into a classification model respectively to obtain a classification result of the test image and a classification result of the corresponding test sub-image;
[0179] The classification result of a test image and the classification result of the corresponding test sub-image are weighted and averaged, and the classification result after weighted average is used as the classification result of a test image.
[0180] Optionally, the training unit 905 is specifically used for:
[0181] For each test image, perform the following operations:
[0182] For a test image, based on motion boundary information of the test image and a background cropping ratio value, determining an image cropping range;
[0183] Based on the image cropping range and the target object area, obtaining at least two target cropping boundary information;
[0184] A test image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two test sub-images corresponding to the test image.
[0185] In an embodiment of the present application, by marking the target object in the initial image, the boundary of the target object can be determined, and then the image can be cropped in combination with the boundary of the object, and the preset background cropping ratio value and object proportion value. By setting the background cropping ratio value, the background area in the initial image can appear in the cropped initial sub-image as needed, and by setting the object proportion value, it can be ensured that part of the target image can appear in the cropped sub-image. Therefore, the image processing method in the present application fully considers the background area and the target object in the image, quantitatively analyzes the ratio of the two in the cropped image, and can efficiently and accurately perform image cropping to obtain an image that better meets the needs; further, when other processing is performed based on the obtained cropped image, the processing efficiency and accuracy can be further improved. For example, when performing model training, the generalization ability of the model can be improved, and the accuracy of model prediction can be improved.
[0186] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0187] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0188] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. In one embodiment, the electronic device may be a server, such as Figure 2 In this embodiment, the structure of the electronic device can be as follows: Fig.10 As shown, it includes a memory 1001 , a communication module 1003 and one or more processors 1002 .
[0189] The memory 1001 is used to store computer programs executed by the processor 1002. The memory 1001 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0190] The memory 1001 may be a volatile memory, such as a random-access memory (RAM); the memory 1001 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 1001 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1001 may be a combination of the above memories.
[0191] The processor 1002 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 1002 is used to implement the above-mentioned image processing method when calling the computer program stored in the memory 1001 .
[0192] The communication module 1003 is used to communicate with terminal devices and other servers.
[0193] The specific connection medium between the memory 1001, the communication module 1003 and the processor 1002 is not limited in the embodiment of the present application. Fig.10 In the embodiment, the memory 1001 and the processor 1002 are connected via a bus 1004. The bus 1004 is connected to the processor 1002 via a bus 1004. Fig.10 The connections between the other components are only for illustration and are not intended to be limiting. The bus 1004 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Fig.10 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or one type of bus.
[0194] The memory 1001 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the image processing method of the embodiment of the present application. The processor 1002 is used to execute the above-mentioned image processing method, such as Figure 3 shown.
[0195] In another embodiment, the electronic device may also be other electronic devices, such as Figure 2 The terminal device 210 shown in FIG. 1 is a terminal device 210 shown in FIG. 1 . In this embodiment, the structure of the electronic device can be as follows: Fig.11 As shown, it includes: a communication component 1110, a memory 1120, a display unit 1130, a camera 1140, a sensor 1150, an audio circuit 1160, a Bluetooth module 1170, a processor 1180 and other components.
[0196] The communication component 1110 is used to communicate with the server. In some embodiments, a wireless fidelity (WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user to send and receive information through the WiFi module.
[0197] The memory 1120 can be used to store software programs and data. The processor 1180 executes various functions and data processing of the terminal device 210 by running the software programs or data stored in the memory 1120. The memory 1120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least two disk storage devices, flash memory devices, or other volatile solid-state storage devices. The memory 1120 stores an operating system that enables the terminal device 210 to run. In the present application, the memory 1120 can store an operating system and various application programs, and can also store a computer program for executing the image processing method of the embodiment of the present application.
[0198] The display unit 1130 may also be used to display information input by the user or information provided to the user and a graphical user interface (GUI) of various menus of the terminal device 210. Specifically, the display unit 1130 may include a display screen 1132 disposed on the front of the terminal device 210. The display screen 1132 may be configured in the form of a liquid crystal display, a light emitting diode, etc. The display unit 1130 may be used to display the image processing user interface in the embodiment of the present application, etc.
[0199] The display unit 1130 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the terminal device 210. Specifically, the display unit 1130 may include a touch screen 1131 arranged on the front of the terminal device 210, which can collect user touch operations on or near it, such as clicking a button, dragging a scroll box, etc.
[0200] The touch screen 1131 may be covered on the display screen 1132, or the touch screen 1131 and the display screen 1132 may be integrated to realize the input and output functions of the terminal device 210, and the integrated touch screen may be referred to as a touch display screen. In the present application, the display unit 1130 may display the application and the corresponding operation steps.
[0201] The camera 1140 can be used to capture still images, and users can post comments on the images taken by the camera 1140 through the application. The camera 1140 can be one or more. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the processor 1180 to convert it into a digital image signal.
[0202] The terminal device may further include at least one sensor 1150, such as an acceleration sensor 1151, a distance sensor 1152, a fingerprint sensor 1153, and a temperature sensor 1154. The terminal device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.
[0203] The audio circuit 1160, the speaker 1161, and the microphone 1162 can provide an audio interface between the user and the terminal device 210. The audio circuit 1160 can transmit the electrical signal converted from the received audio data to the speaker 1161, which is converted into a sound signal for output. The terminal device 210 can also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 1162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1160 and converted into audio data, and then the audio data is output to the communication component 1110 to be sent to, for example, another terminal device 210, or the audio data is output to the memory 1120 for further processing.
[0204] The Bluetooth module 1170 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol. For example, the terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 1170 to exchange data.
[0205] The processor 1180 is the control center of the terminal device. It uses various interfaces and lines to connect various parts of the entire terminal. It executes various functions of the terminal device and processes data by running or executing software programs stored in the memory 1120 and calling data stored in the memory 1120. In some embodiments, the processor 1180 may include one or more processing units; the processor 1180 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1180. In the present application, the processor 1180 can run the operating system, application programs, user interface display and touch response, as well as the image processing method of the embodiment of the present application. In addition, the processor 1180 is coupled to the display unit 1130.
[0206] In some possible implementations, various aspects of the image processing method provided by the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the image processing method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 3 Follow the steps shown in .
[0207] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0208] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, apparatus, or device.
[0209] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.
[0210] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0211] Computer programs for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The computer program may be executed entirely on the user electronic device, partially on the user device, as a separate software package, partially on the user electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In the case of a remote electronic device, the remote electronic device may be connected to the user electronic device via any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external electronic device (e.g., via the Internet using an Internet service provider).
[0212] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0213] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0214] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain a computer-usable computer program.
[0215] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0216] These computer program commands may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer readable memory produce an article of manufacture comprising a command device, the command device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0217] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide the instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0218] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0219] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. An image processing method, characterized in that: The method includes: Annotating a target object in an initial image to obtain object boundary information of the target object; Determining an image cropping range based on the object boundary information and a preset background cropping ratio value, wherein the background cropping ratio value is used to determine: an area of the background area in the initial image that is related to the background area in the cropped initial sub-image; Determine, based on the object proportion value, a target object area related to the target object in the initial image, wherein the object proportion value is used to represent: a proportion of the target object in the cropped initial sub-image to the target object in the initial image; Based on the image cropping range and the target object area, obtaining a plurality of candidate cropping boundary information; Based on the similarities between the respective candidate cropping boundary information, at least two target cropping boundary information are selected from the plurality of candidate cropping boundary information; The initial image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two initial sub-images corresponding to the initial image.
2. The method according to claim 1, characterized in that The amount of target cropping boundary information is a preset cropping amount; The selecting at least two target cropping boundary information from the plurality of candidate cropping boundary information based on the similarity between the respective candidate cropping boundary information includes: Determine the similarity between each candidate cropping boundary information based on the intersection-and-union ratio between the cropping frames corresponding to each candidate cropping boundary information; Grouping the candidate cropping boundary information, and respectively calculating the sum of similarities of the candidate cropping boundary information contained in each group, each group containing a preset number of candidate cropping boundary information; The candidate cropping boundary information contained in the group with the smallest sum of similarities is used as the target cropping boundary information.
3. The method according to claim 1, characterized in that The obtaining of a plurality of candidate cropping boundary information based on the image cropping range and the target object area includes: respectively determining an extended distance between each object boundary of the target object region and a cropping boundary corresponding to the image cropping range, wherein each object boundary is parallel to the corresponding cropping boundary; Based on each expansion distance, multiple boundary expansions are performed on the target object area to obtain the multiple candidate cropping boundary information.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Performing cyclic iterative training on the classification model in training based on the training sample data set to obtain a trained classification model, wherein each training sample in the training sample data set includes an initial image and at least two initial sub-images corresponding to the initial image; Performing motion target detection on a video containing a target object based on a motion detection model to obtain a test sample data set, wherein each test sample in the test sample data set includes a test image and motion boundary information of the target object in the test image; Cropping each test image to obtain a test sub-image of each test image; The test images and their corresponding test sub-images are respectively input into the trained classification model to obtain classification results of the test images.
5. The method according to claim 4, characterized in that The step of inputting the respective test images and respective test sub-images into the trained classification model to obtain classification results of the respective test images comprises: For each test image, perform the following operations: For a test image, input the test image and the corresponding test sub-image into the classification model respectively to obtain a classification result of the test image and a classification result of the corresponding test sub-image; A weighted average is performed on the classification result of the one test image and the classification result of the corresponding test sub-image, and the classification result after the weighted average is used as the classification result of the one test image.
6. The method according to claim 4, characterized in that The step of cropping each test image to obtain a test sub-image of each test image includes: For each test image, perform the following operations: For a test image, determining the image cropping range based on motion boundary information of the test image and the background cropping ratio value; Based on the image cropping range and the target object area, obtaining at least two target cropping boundary information; The one test image is cropped based on the obtained at least two target cropping boundary information respectively to obtain at least two test sub-images corresponding to the one test image.
7. An image processing device, characterized in that: include: A labeling unit, used to label the target object in the initial image to obtain object boundary information of the target object; a determining unit, configured to determine an image cropping range based on the object boundary information and a preset background cropping ratio value, wherein the background cropping ratio value is used to determine: an area of the background area in the initial image that is related to the background area in the cropped initial sub-image; an acquisition unit, configured to determine a target object region related to the target object in the initial image based on an object proportion value, wherein the object proportion value is used to represent: a proportion of the target object in the cropped initial sub-image to the target object in the initial image; and to obtain a plurality of candidate cropping boundary information based on an image cropping range and the target object region; Based on the similarities between the respective candidate cropping boundary information, at least two target cropping boundary information are selected from the plurality of candidate cropping boundary information; The cropping unit is used to crop the initial image based on the obtained at least two target cropping boundary information to obtain at least two initial sub-images corresponding to the initial image.
8. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: It includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any method described in claims 1 to 6.
10. A computer program product, characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any one of the methods described in claims 1 to 6.
Citation Information
Cited By
Image cutting method based on target proportion constraint
CN122865852A
