A method for removing irrelevant portraits from scenic spot photos

Through convolutional neural network and user interaction screening, combined with image fusion algorithms, the problem of removing irrelevant portraits in scenic spot photos is solved, high-quality, low-complexity photo processing is achieved, and user experience and scenic spot operation efficiency are improved.

CN112446820BActive Publication Date: 2024-09-24ZHEJIANG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011198813.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-31
Publication Date
2024-09-24
Estimated Expiration
2040-10-31

AI Technical Summary

Technical Problem

Existing technology cannot effectively remove irrelevant portraits in scenic photos, resulting in reduced user experience and privacy risks, and the operation process is complicated.

Method used

Convolutional neural network is used for instance segmentation processing, portrait areas are filtered through user interaction, confidence is calculated and visualized, and an image fusion algorithm is used to replace irrelevant portrait areas with background areas to achieve seamless fusion.

Benefits of technology

It improves user experience, ensures photo quality, reduces operational complexity, meets users' needs for exclusive photos, and enhances the management capabilities of scenic spots.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112446820B
    Figure CN112446820B
Patent Text Reader

Abstract

The present invention relates to a method for removing irrelevant portraits from scenic spot photos. A fixed camera is used to obtain a background in a preset shooting area of ​​a scenic spot. When a tourist stands at a preset shooting point, the camera captures the tourist. The tourist selects a satisfactory photo as the original photo. After instance segmentation processing using a convolutional neural network, the tourist marks different portrait areas, judges the relevant portraits, calculates the confidence of the relevant portraits, screens the relevant portrait areas and irrelevant portrait areas, and visualizes the screening results; after the tourist pre-processes, the confirmed irrelevant portraits are removed, and the result image is presented to the tourist. The present invention has strong interactivity, and the tourist can complete the whole process in the gap of sightseeing, and can obtain exclusive photos that completely belong to the relevant person, without worrying about infringing on the privacy of others. The actual quality of the obtained photos is high. Due to the strong interactivity and operability, the demand for tourists to choose services will increase, and the scenic spot can be more orderly managed and business output can be carried out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, general image data processing or generation technology, and in particular to a method for removing irrelevant human portraits from scenic spot photos. Background Art

[0002] Tourism is one of the booming industries at present. Whenever holidays are approaching, many people choose to relax by traveling. In order to attract tourists, scenic spots will provide filming services at some popular attractions.

[0003] However, due to the dense flow of people at popular scenic spots, it is easy for several unfamiliar tourists to appear in the photos taken by users. This not only fails to meet the users' exclusive needs for photos, but also poses a risk of infringing on the privacy of others. At the same time, most scenic spot photo services can only realize the automation of user photo taking and photo retrieval and some basic beauty functions, and cannot remove unfamiliar tourists from users' photos. The actual quality of the photos obtained is not good, and the demand for users to choose this service has also decreased accordingly.

[0004] For scenic spots, removing irrelevant portraits from tourists' photos is an urgent problem to be solved.

[0005] The image processing method mentioned in the patent application number CN201911367741.2 is to process irrelevant portraits that appear in the automatic photo-taking service of the amusement park. This method is to obtain the facial information of the user and the user's related persons in advance, identify the target video frame from the video stream through the characteristic information of these target faces, and then identify the target person area and irrelevant person area in the image, and replace the irrelevant person area with the target person area. Although this method can remove the irrelevant person area of ​​the image, it is done by replacing the target person area, which will cause the areas of many people in the final result image to be repeated, greatly reducing the user's user experience; and this method also requires the user to upload the facial information of the target person at the beginning before the irrelevant person can be removed, which increases the complexity of the entire operation process.

[0006] In summary, the problem of removing irrelevant portraits from photos of tourists in scenic spots has not been well solved yet. Summary of the invention

[0007] The present invention solves the problems existing in the prior art and provides an optimized method for removing irrelevant portraits from scenic spot photos.

[0008] To achieve the purpose of the present invention, the technical solution adopted by the present invention is a method for removing irrelevant portraits from scenic spot photos, the method comprising the following steps:

[0009] Step 1: Background acquisition: For any scenic spot, a fixed camera is placed in a preset shooting area I of the scenic spot to obtain several background images;

[0010] Step 2: Get photos: When the tourist stands at the preset shooting point, the camera takes a snapshot of the tourist, and the tourist selects a satisfactory photo as the original image S for the next step of processing;

[0011] Step 3: Portrait segmentation: Use a convolutional neural network to perform instance segmentation on the photos selected by tourists;

[0012] Step 4: Portrait screening: After the portrait segmentation of the photo, pre-processing is performed to judge and calculate the relevant portrait confidence, and the relevant portrait area and irrelevant portrait area are screened based on the confidence, and the screening results are visualized;

[0013] Step 5: User interaction: After filtering out irrelevant portraits in the photos, the screening results are presented to the tourists, who edit the screening results;

[0014] Step 6: Portrait removal: First, perform regional background matching to obtain the background region G that best matches the irrelevant portrait region Ω. Then, use the image fusion algorithm to replace the irrelevant portrait region Ω with the corresponding background region G, and seamlessly fuse it into the original image S to achieve irrelevant portrait removal.

[0015] Step 7: Present the result image after portrait removal to the tourists.

[0016] Preferably, step 1 comprises the following steps:

[0017] Step 1.1: Take N background images at a certain time interval every day and name them according to the time of shooting;

[0018] Step 1.2: Use the convolutional neural network to perform portrait segmentation and determine whether the N images contain portraits. If not, store the captured background image in the background image library of the scenic spot. Otherwise, delete the captured background image. If all the N images contain portraits, continue to shoot N background images and repeat step 1.2.

[0019] Step 1.3: Delete the background image M days ago to avoid wasting memory;

[0020] Step 1.4: Mark the preset photographing area I of the photographing point.

[0021] Preferably, in step 3, the convolutional neural network is a Mask-RCNN instance segmentation network.

[0022] Preferably, step 4 comprises the following steps:

[0023] Step 4.1: After the portrait segmentation of the photo, the obtained n mask areas are subjected to image mask processing, and the pixel values ​​in the n mask areas are assigned with n values ​​between m and m+n. The pixel value of the preset photo area I of the picture is set to 255, and the pixel values ​​of other areas are set to 0; n≥0, m+n<255;

[0024] Step 4.2: Make relevant portrait judgments and calculate the relevant portrait confidence;

[0025] Step 4.3: Set a confidence threshold, and screen relevant portrait areas and irrelevant portrait areas based on the confidence. Areas with confidence exceeding the threshold are relevant portrait areas.

[0026] Step 4.4: Visualize the areas identified as relevant portrait areas to facilitate user identification.

[0027] Preferably, the step 4.2 comprises the following steps:

[0028] Step 4.2.1: Calculate the intersection-over-union (IOU) ratio between masks, and use IOU to obtain the confidence value of each mask. IOU ;

[0029] Step 4.2.2: Calculate the horizontal distance HorDis from each mask to the preset photo area I, and use this distance to obtain the portrait confidence Value of each mask. dis ;

[0030] Step 4.2.3: Cluster each mask area and obtain the portrait confidence value of each mask means ;

[0031] Step 4.2.4: Confidence Value IOU 、Value dis 、Value means Weighted addition is performed to obtain the final portrait confidence value.

[0032] Preferably, the step 4.2.1: calculating the intersection-over-union (IOU) ratio between each mask ij , Among them, pixel refers to the pixel value of a certain pixel, pixel∈(Mask i ∩Mask j ) refers to the mask Mask i and Mask j The pixel point in the intersection area, pixel∈Mask i It means in Mask iThe pixel points in the entire area, IOU∈[0,1]; based on IOU, the confidence value of each mask related to the portrait is obtained IOU , take Value IOU The maximum value of

[0033] When Mask i The intersection-over-union (IOU) ratio with the preset photo area I iI If greater than 0, then Value IOU_i The value is 1;

[0034] When Mask i and other portrait areas that intersect with it Mask j The intersection-over-union (IOU) ratio with the preset photo area I iI and IOU jI If it is 0, Mask i With Mask j No pixel falls within region I, and its Value IOU_i The value is 0;

[0035] Among them, v is used to judge Mask i With Mask j The degree of intersection;

[0036] Get Value IOU The maximum value of .

[0037] Preferably, in step 4.2.2, HorDis=|CenterX-IX|, wherein CenterX is the horizontal coordinate of the center point of the minimum circumscribed quadrilateral of the mask area, and IX is the horizontal coordinate of the center of the preset photographing area I; The value D is the threshold of the distance between the two regions, which is set to the image width.

[0038] Preferably, the step 4.2.3 comprises the following steps:

[0039] Select the center point of the preset photographing area I and the center point of any mask area as the initial centers of the two clusters, and let the former be the center of the relevant portrait class and the latter be the center of the irrelevant portrait class;

[0040] Calculate the mask Mask i The distance dis from the region to the two cluster centers, Among them, (x, y) is Mask i The coordinates of the points in the cluster, (X, Y) is the cluster center, and PixelNum is the Mask. i The total number of pixels in the Mask iThe category is classified into the category with the center closer to the two cluster centers; the center of the relevant portrait category and the irrelevant portrait category is iteratively calculated by taking the mean value of the pixel coordinates within the category;

[0041] For two cluster centers, until the distance between the new cluster center and the previous cluster center after iterative update is less than the threshold, it is considered to have reached a stable state and the iteration ends, otherwise it continues to iterate and update; use the two cluster centers in the stable state to make category judgments and calculate Value means ,

[0042] Preferably, step 6 comprises the following steps:

[0043] Step 6.1: Take the minimum bounding rectangle [a, b, w, h] for each irrelevant portrait mask, and select the corresponding irrelevant portrait region Ω for background matching as [a, b, k*w, k*h], where a and b are the horizontal and vertical coordinates of the center of the rectangle, w and h are the width and height of the rectangle, and k is the magnification factor of the irrelevant portrait region; make a difference between each irrelevant portrait region Ω and the corresponding irrelevant portrait mask, and determine the surrounding area of ​​each irrelevant portrait mask as the local background area;

[0044] Step 6.2: Perform color space conversion on each local background area, converting the RGB color space into the HSV color space;

[0045] Step 6.3: Calculate the HSV color space histogram and perform normalization;

[0046] Step 6.4: Compare the histogram correlation of each processed local background area with the corresponding area in each background image, and calculate the similarity using the correlation measurement formula;

[0047] Step 6.5: Select the J background images with the highest similarity, exclude the background images with similarity lower than the threshold D among the J background images, sort the images filtered by similarity according to the time when the background images were taken, and select the background image closest to the current time as the matching result;

[0048] Step 6.6: Perform image fusion, replace the irrelevant portrait area Ω with the corresponding background area G of the matching background image, and achieve seamless fusion on the original image S.

[0049] The present invention provides an optimized method for removing irrelevant portraits from scenic spot photos. A fixed camera is used to obtain a background in a preset shooting area I of the scenic spot. When a tourist stands at a preset shooting point, the camera captures the tourist, and the tourist selects a satisfactory photo as an original photo S. After instance segmentation processing is performed on the photo selected by the tourist using a convolutional neural network, the tourist marks different portrait areas, then judges and calculates relevant portrait confidences to obtain relevant portrait confidences, screens relevant portrait areas and irrelevant portrait areas based on the confidences, and visualizes the screened results. After pre-processing by the tourist, confirmed irrelevant portraits are removed, and finally the result image is presented to the tourist.

[0050] The present invention has strong interactivity, and tourists can complete the whole process in their spare time during sightseeing, and can obtain exclusive photos belonging to the relevant persons without worrying about infringing on the privacy of others. The photos obtained are of high actual quality. Due to the strong interactivity and operability, tourists' demand for this service will increase, and the scenic spot can be managed in a more orderly manner and carry out business output. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 is a flow chart of the present invention;

[0052] Figure 2 Schematic diagram of an embodiment of the present invention, wherein a is the original image, b is the image after portrait segmentation and irrelevant portrait screening, and c is the result image after portrait removal. DETAILED DESCRIPTION

[0053] The present invention is further described in detail below in conjunction with embodiments, but the protection scope of the present invention is not limited thereto.

[0054] The invention relates to a method for removing irrelevant portraits from scenic spot photos, and the method comprises the following steps.

[0055] Step 1: Background acquisition: For any scenic spot, a fixed camera is placed in a preset shooting area I of the scenic spot to obtain several background images.

[0056] The step 1 comprises the following steps:

[0057] Step 1.1: Take N background images at a certain time interval every day and name them according to the time of shooting;

[0058] Step 1.2: Use the convolutional neural network to perform portrait segmentation and determine whether the N images contain portraits. If not, store the captured background image in the background image library of the scenic spot. Otherwise, delete the captured background image. If all the N images contain portraits, continue to shoot N background images and repeat step 1.2.

[0059] Step 1.3: Delete the background image M days ago to avoid wasting memory;

[0060] Step 1.4: Mark the preset photographing area I of the photographing point.

[0061] In the present invention, the preset shooting area is generally the "best" shooting point selected by the scenic spot based on the actual experience of the photographer, the objective environment of the scenic spot, changes in public opinion, etc. This area may change, but it is basically stable in the short term.

[0062] In the present invention, N and M are obviously numbers greater than 0. Generally speaking, N can be 5 and M can be 10.

[0063] In the present invention, the convolutional neural network of step 1.2 includes but is not limited to the Mask-RCNN instance segmentation network.

[0064] Step 2: Get photos: When the tourist stands at the preset shooting point, the camera takes a snapshot of the tourist, and the tourist selects a satisfactory photo as the original image S for the next step of processing.

[0065] Step 3: Portrait segmentation: Use a convolutional neural network to perform instance segmentation on the photos selected by tourists.

[0066] In step 3, the convolutional neural network is a Mask-RCNN instance segmentation network.

[0067] In the present invention, step 3 processes the segmentation result and marks different portrait areas, which can facilitate tourists to make choices in the subsequent process.

[0068] In the present invention, convolutional neural networks include but are not limited to Mask-RCNN instance segmentation networks.

[0069] In the present invention, when the convolutional neural network adopts the Mask-RCNN instance segmentation network, a model that achieves the best effect on the portrait segmentation dataset is selected for deployment, and the entire training and deployment process can adopt the PyTorch framework or the Tensorflow framework.

[0070] Step 4: Portrait screening: After the portrait segmentation of the photo, pre-processing is performed, the relevant portraits are judged and the relevant portrait confidence is calculated, and the relevant portrait areas and irrelevant portrait areas are screened based on the confidence, and the screening results are visualized.

[0071] The step 4 comprises the following steps:

[0072] Step 4.1: After the portrait segmentation of the photo, the obtained n mask areas are subjected to image mask processing, and the pixel values ​​in the n mask areas are assigned with n values ​​between m and m+n. The pixel value of the preset photo area I of the picture is set to 255, and the pixel values ​​of other areas are set to 0; n≥0, m+n<255;

[0073] Step 4.2: Make relevant portrait judgments and calculate the relevant portrait confidence;

[0074] The step 4.2 comprises the following steps:

[0075] Step 4.2.1: Calculate the intersection-over-union (IOU) ratio between masks, and use IOU to obtain the confidence value of each mask. IOU ;

[0076] Step 4.2.1: Calculate the intersection-over-union (IOU) ratio between each mask ij , Among them, pixel refers to the pixel value of a certain pixel, pixel∈(Mask i ∩Mask j ) refers to the mask Mask i and Mask j The pixel point in the intersection area, pixel∈Mask i It means in Mask i The pixel points in the entire area, IOU∈[0,1]; based on IOU, the confidence value of each mask related to the portrait is obtained IOU , take Value IOU The maximum value of

[0077] When Mask i The intersection-over-union (IOU) ratio with the preset photo area I iI If greater than 0, then Value IOU_i The value is 1;

[0078] When Mask i and other portrait areas that intersect with it Mask j The intersection-over-union (IOU) ratio with the preset photo area I iI and IOU jI If it is 0, Mask i With Mask j No pixel falls within region I, and its Value IOU_i The value is 0;

[0079] Among them, v is used to judge Mask i With Mask j The degree of intersection;

[0080] Get Value IOU The maximum value of .

[0081] Step 4.2.2: Calculate the horizontal distance HorDis from each mask to the preset photo area I, and use this distance to obtain the portrait confidence Value of each mask. dis ;

[0082] In step 4.2.2, HorDis=|CenterX-IX|, where CenterX is the horizontal coordinate of the center point of the minimum circumscribed quadrilateral of the mask area, and IX is the horizontal coordinate of the center of the preset photographing area I; The value D is the threshold of the distance between the two regions, which is set to the image width.

[0083] Step 4.2.3: Cluster each mask area and obtain the portrait confidence value of each mask means ;

[0084] The step 4.2.3 comprises the following steps:

[0085] Select the center point of the preset photographing area I and the center point of any mask area as the initial centers of the two clusters, and let the former be the center of the relevant portrait class and the latter be the center of the irrelevant portrait class;

[0086] Calculate the mask Mask i The distance dis from the region to the two cluster centers, Among them, (x, y) is Mask i The coordinates of the points in the cluster, (X, Y) is the cluster center, and PixelNum is the Mask. i The total number of pixels in the Mask i The category is classified into the category with the center closer to the two cluster centers; the center of the relevant portrait category and the irrelevant portrait category is iteratively calculated by taking the mean value of the pixel coordinates within the category;

[0087] For two cluster centers, until the distance between the new cluster center and the previous cluster center after iterative update is less than the threshold, it is considered to have reached a stable state and the iteration ends, otherwise it continues to iterate and update; use the two cluster centers in the stable state to make category judgments and calculate Value means ,

[0088] Step 4.2.4: Confidence Value IOU 、Value dis 、Value means Weighted addition is performed to obtain the final portrait confidence value.

[0089] Step 4.3: Set a confidence threshold, and screen relevant portrait areas and irrelevant portrait areas based on the confidence. Areas with confidence exceeding the threshold are relevant portrait areas.

[0090] Step 4.4: Visualize the areas identified as relevant portrait areas to facilitate user identification.

[0091] In the present invention, the mask refers to the area obtained after the convolutional neural network.

[0092] In the present invention, n in step 4.1 is the number of portrait areas obtained after the convolutional neural network. The value range of n depends on the number of portraits in the picture, and is greater than or equal to 0, m+n<255, and 255 is the maximum value of the pixel point.

[0093] In the present invention, in step 4.2.1,

[0094] When Mask i The intersection-over-union (IOU) ratio with the preset photo area I iI Greater than 0, that is, Mask i When there are pixels in the preset photo area I, then Value IOU_i The value is 1;

[0095] When Mask i and other portrait areas that intersect with it Mask j The intersection-over-union (IOU) ratio with the preset photo area I iI and IOU jI If it is 0, Mask i With Mask j No pixel falls within region I, and its Value IOU_i The value is 0;

[0096] The third case requires first judging the Mask i With Mask j The degree of intersection. Generally speaking, v is a number between 0 and 1, such as v is 0.1. Of course, it can also be fine-tuned around this value according to the actual situation to adapt to different scenarios.

[0097]

[0098] Finally, take the maximum value of ValueIOU.

[0099] In the present invention, step 4.2.2, wherein HorDis is the lateral distance from the center point of the Mask area to the preset photographing area I, which is calculated by the absolute value of the difference in the horizontal coordinates of the center points of the two areas; generally speaking, K is greater than 0, such as K is 3, and can be fine-tuned around this value according to actual conditions to adapt to different scenes.

[0100] In the present invention, step 4.2.3 first randomly selects a mask as a presumed irrelevant portrait, and then performs subsequent operations; wherein, continued iteration is to recalculate the mask Mask i The distance dis from the region to the two cluster centers is calculated, followed by reclassification, recalculation of the two cluster centers, and confirmation of whether the distance change is less than a threshold.

[0101] In the present invention, step 4.2.4 sets the confidence value IOU 、Value dis 、Value means By weighted addition, we can get the final value of human confidence, Value = α·Value IOU +β·Value dis +χ·Value means ; Among them, α+β+χ=1, the values ​​of α, β, and χ are between 0 and 1. In this example, the values ​​of α, β, and χ are set to 0.5, 0.3, and 0.2, respectively. They can be fine-tuned around these values ​​according to actual conditions to adapt to different scenarios.

[0102] In the present invention, the confidence threshold is obviously greater than 0, and can generally be set to 0.8, and can be fine-tuned around this value according to actual conditions to adapt to different scenarios.

[0103] Step 5: User interaction: After filtering out irrelevant portraits in the photos, the filtering results are presented to the tourists, who edit the filtering results.

[0104] In the present invention, visitors can edit the screening results through a touch screen or other means, and can even change the category to which the portrait area belongs; in actual applications, irrelevant portrait areas and relevant portrait areas can be distinguished by different colors. By clicking on a red Mask, the user can change the color of the Mask from red to blue, i.e., change the judgment of irrelevant portraits in the area; by clicking on a blue Mask, the user can change it to red, i.e., identify the area as an irrelevant portrait area; if the user has no intention of changing the final result, the user can click a confirmation button to confirm the screening of the irrelevant portrait area.

[0105] Step 6: Portrait removal: First, perform regional background matching to obtain the background region G that best matches the irrelevant portrait region Ω. Then, use the image fusion algorithm to replace the irrelevant portrait region Ω with the corresponding background region G, and seamlessly merge it into the original image S to achieve irrelevant portrait removal.

[0106] The step 6 comprises the following steps:

[0107] Step 6.1: Take the minimum bounding rectangle [a, b, w, h] for each irrelevant portrait mask, and select the corresponding irrelevant portrait region Ω for background matching as [a, b, k*w, k*h], where a and b are the horizontal and vertical coordinates of the center of the rectangle, w and h are the width and height of the rectangle, and k is the magnification factor of the irrelevant portrait region; make a difference between each irrelevant portrait region Ω and the corresponding irrelevant portrait mask, and determine the surrounding area of ​​each irrelevant portrait mask as the local background area;

[0108] Step 6.2: Perform color space conversion on each local background area, converting the RGB color space into the HSV color space;

[0109] Step 6.3: Calculate the HSV color space histogram and perform normalization;

[0110] Step 6.4: Compare the histogram correlation of each processed local background area with the corresponding area in each background image, and calculate the similarity using the correlation measurement formula;

[0111] Step 6.5: Select the J background images with the highest similarity, exclude the background images with similarity lower than the threshold D among the J background images, sort the images filtered by similarity according to the time when the background images were taken, and select the background image closest to the current time as the matching result;

[0112] Step 6.6: Perform image fusion, replace the irrelevant portrait area Ω with the corresponding background area G of the matching background image, and achieve seamless fusion on the original image S.

[0113] In the present invention, the image fusion algorithm adopts the Poisson fusion method, and different image fusion algorithms can be used according to actual conditions to adapt to different scenes. Poisson fusion can better eliminate the traces of splicing on the basis of retaining the gradient information of the original image. Its core idea is to reconstruct the image pixels in the synthesis area by interpolation method based on the gradient information of the original image and the boundary information of the target image.

[0114] In the present invention, k in step 6.1 is obviously greater than 0, and can generally be taken as 2. Of course, it can also be fine-tuned near this value according to actual conditions to adapt to different scenes; if one side of the background matching area exceeds the image boundary, it is necessary to add an area with the same area as the part exceeding the image boundary on the side that does not exceed the image boundary; if both sides of the background matching area exceed the image boundary, the entire image is used as the background matching area; if there is a Mask in the background matching area, it is necessary to remove the Mask area in the area for matching.

[0115] In the present invention, step 6.2 converts the pixel value of RGB to the values ​​of the three components H, S, and V in the HSV space through the conversion formula of converting RGB to HSV. This is a well-known technology in the art and can be processed by those skilled in the art.

[0116] In the present invention, in step 6.5, J is obviously greater than 0 and can generally be set to 7. First, the background images with similarity lower than the threshold D among the J background images are excluded. The similarity threshold D is obviously greater than 0. If it is set to 0.85, it can be fine-tuned near this value according to the actual situation to adapt to different scenes. Then, the pictures that have been screened by similarity are sorted according to the time when the background images were taken, and the background image closest to the current time is selected as the matching result.

[0117] Step 7: Present the result image after portrait removal to the tourists.

[0118] In the present invention, in conjunction with the specification Figure 2 The effect diagram of the embodiment is shown:

[0119] Figure 2 a in the figure is the original image, and the selection box in the figure is the artificially set optimal shooting area I;

[0120] Figure 2 b in the figure is the image after portrait segmentation and irrelevant portrait screening, where the masked area on the left represents the irrelevant portrait area, and the masked area on the right represents the relevant portrait area;

[0121] The Value obtained after the mask area on the left is filtered out by irrelevant portraits IOU =0,Value dis =0.671, Value means = -1, the final value is 0.0013, which is less than the set threshold of 0.8, so it is irrelevant to the portrait area, and the entire area is set to the first color;

[0122] The value of the mask area on the right after filtering out irrelevant portraits is obtained. IOU =1,Value dis =0.741, Value means = 1. The final value is 0.9223, which is greater than the set threshold of 0.8, so it is related to the portrait area, and the entire area is set to the second color;

[0123] There is a clear difference between the first and second colors in practical applications;

[0124] Figure 2 The c in the figure is the result image after portrait removal. To prevent infringement of the privacy of the people in the photo, the facial area of ​​the people in the photo is mosaicked.

Claims

1. A method for removing irrelevant portraits from scenic spot photos, characterized by: The method comprises the following steps: Step 1: Background acquisition: For any scenic spot, a fixed camera is placed in a preset shooting area I of the scenic spot to obtain several background images; Step 2: Get photos: When the tourist stands at the preset shooting point, the camera takes a snapshot of the tourist, and the tourist selects a satisfactory photo as the original image S for the next step of processing; Step 3: Portrait segmentation: Use a convolutional neural network to perform instance segmentation on the photos selected by tourists; Step 4: Portrait screening: After the portrait segmentation of the photo, pre-processing is performed, the relevant portraits are judged and the relevant portrait confidence is calculated, and the relevant portrait areas and irrelevant portrait areas are screened based on the confidence, and the screening results are visualized; Step 4 includes the following steps: Step 4.1: After the portrait segmentation of the photo, the obtained n mask areas are subjected to image mask processing, and the pixel values ​​in the n mask areas are assigned with n values ​​between m and m+n. The pixel value of the preset photo area I of the picture is set to 255, and the pixel values ​​of other areas are set to 0; n≥0, m+n<255; Step 4.2: Perform relevant portrait judgment and calculate the relevant portrait confidence, including the following steps: Step 4.2.1: Calculate the intersection-over-union (IOU) ratio between masks, and use IOU to obtain the confidence value of each mask. IOU ; When Mask i The intersection-over-union (IOU) ratio with the preset photo area I iI If greater than 0, then Value IOU_i The value is 1; when the mask i And other portrait area masks that intersect with it j The intersection-over-union (IOU) ratio with the preset photo area I iI and IOU jI If it is 0, Mask i With Mask j No pixel falls within region I, and its Value IOU_i The value is 0; Among them, v is used to judge Mask i With Mask j The degree of intersection; Get Value IOU The maximum value of Step 4.2.2: Calculate the horizontal distance HorDis from each mask to the preset photo area I, and use this distance to obtain the portrait confidence Value of each mask. dis , Among them, the value D is the threshold of the distance between the two regions; Step 4.2.3: Cluster each mask area and obtain the portrait confidence value of each mask means , including the following steps: Select the center point of the preset photo area I and the center point of any mask area as the initial centers of the two clusters, let the former be the center of the relevant portrait class, and the latter be the center of the irrelevant portrait class; calculate the mask Mask i The distance dis from the region to the two cluster centers, Mask i The category is classified into the category of the center that is closer to the two cluster centers; the center of the relevant portrait category and the irrelevant portrait category is iteratively calculated by using the mean value of the pixel coordinates within the category; for the two cluster centers, until the distance between the new cluster center and the previous cluster center after iterative update is less than the threshold, it is considered to have reached a stable state and the iteration ends, otherwise it continues to iterate and update; use the two cluster centers in the stable state to make category judgments and calculate the Value means , Step 4.2.4: Confidence Value IOU 、Value dis 、Value means Weighted addition is performed to obtain the final confidence value of the portrait; Step 4.3: Set a confidence threshold, and screen relevant portrait areas and irrelevant portrait areas based on the confidence. Areas with confidence exceeding the threshold are relevant portrait areas. Step 4.4: Visualize the areas identified as relevant portrait areas to facilitate user identification; Step 5: User interaction: After filtering out irrelevant portraits in the photos, the screening results are presented to the tourists, who edit the screening results; Step 6: Portrait removal: First, perform regional background matching to obtain the background region G that best matches the irrelevant portrait region Ω. Then, use the image fusion algorithm to replace the irrelevant portrait region Ω with the corresponding background region G, and seamlessly fuse it into the original image S to achieve irrelevant portrait removal. Step 7: Present the result image after portrait removal to the tourists.

2. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: The step 1 comprises the following steps: Step 1.1: Take N background images at a certain time interval every day and name them according to the time of shooting; Step 1.2: Use the convolutional neural network to perform portrait segmentation and determine whether the N images contain portraits. If not, store the captured background image in the background image library of the scenic spot. Otherwise, delete the captured background image. If all the N images contain portraits, continue to shoot N background images and repeat step 1.

2. Step 1.3: Delete the background image M days ago to avoid wasting memory; Step 1.4: Mark the preset photographing area I of the photographing point.

3. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: In step 3, the convolutional neural network is a Mask-RCNN instance segmentation network.

4. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: Step 4.2.1: Calculate the intersection-over-union (IOU) ratio between each mask ij , Among them, pixel refers to the pixel value of a certain pixel, pixel∈(Mask i ∩Mask j ) refers to the mask Mask i and Mask j The pixel point in the intersection area, pixel∈Mask i It means in Mask i The pixels in the entire area, IOU∈[0,1].

5. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: In step 4.2.2, HorDis = |CenterX-IX|, where CenterX is the horizontal coordinate of the center point of the smallest circumscribed quadrilateral of the mask area, and IX is the horizontal coordinate of the center of the preset photographing area I; the value D is set to the image width.

6. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: Among them, (x, y) is Mask i The coordinates of the points in the cluster, (X, Y) is the cluster center, and PixelNum is the Mask. i The total number of pixels in the Mask i Classes are grouped into the class with the center that is closer to the two cluster centers.

7. The method for removing irrelevant portraits from scenic spot photos according to claim 1, characterized in that: The step 6 comprises the following steps: Step 6.1: Take the minimum bounding rectangle [a, b, w, h] for each irrelevant portrait mask, and select the corresponding irrelevant portrait region Ω for background matching as [a, b, k*w, k*h], where a and b are the horizontal and vertical coordinates of the center of the rectangle, w and h are the width and height of the rectangle, and k is the magnification factor of the irrelevant portrait region; make a difference between each irrelevant portrait region Ω and the corresponding irrelevant portrait mask, and determine the surrounding area of ​​each irrelevant portrait mask as the local background area; Step 6.2: Perform color space conversion on each local background area, converting the RGB color space into the HSV color space; Step 6.3: Calculate the HSV color space histogram and perform normalization; Step 6.4: Compare the histogram correlation of each processed local background area with the corresponding area in each background image, and use the correlation measurement formula to calculate the similarity; Step 6.5: Select the J background images with the highest similarity, exclude the background images with similarity lower than the threshold D among the J background images, sort the images that have been screened by similarity according to the time when the background images were taken, and select the background image closest to the current time as the matching result; Step 6.6: Perform image fusion, replace the irrelevant portrait area Ω with the corresponding background area G of the matching background image, and achieve seamless fusion on the original image S.