Image cropping method and device, electronic equipment and storage medium

By determining and flipping the mask image during surround shooting to identify the cropping area, the problem of inaccurate image cropping is solved, thus improving the accuracy of image cropping and the display effect.

CN115249253BActive Publication Date: 2026-01-27BEIJING CHENGSHI WANGLIN INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210841399.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2026-01-27
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

Existing image cropping methods suffer from inaccurate cropping during surround shooting, resulting in cropping that is too large or too small, affecting the final display effect.

Method used

By acquiring multiple images after homography transformation, a first mask image is determined, which is then flipped to obtain a second mask image. The target region is then determined with the center point of the image as the center, and cropping is performed based on this region.

Benefits of technology

It achieves relatively accurate cropping within overlapping areas of multiple images, resulting in ideal cropping effects and ensuring the quality of image display.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115249253B_ABST
    Figure CN115249253B_ABST
Patent Text Reader

Abstract

The application provides an image cropping method and device, electronic equipment and storage medium, wherein the method comprises: in the case of loop shooting a target object and obtaining a plurality of first images after homographic transformation, determining a first target mask image according to a plurality of first mask images corresponding to the plurality of first images, the first target mask image being determined based on pixel values corresponding to pixel points of the plurality of first mask images; performing flip processing on the first target mask image to obtain a second target mask image; determining a target region with the image center point as the center according to the second target mask image; and cropping the plurality of first images according to the target region. The application can determine a suitable cropping region in the overlapping region of the plurality of first mask images, and can relatively accurately crop the images based on the determined cropping region, so as to achieve an ideal cropping effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image cropping method, apparatus, electronic device and storage medium. Background Technology

[0002] Currently, after capturing multiple images of the subject by taking a panoramic shot, these images need to be corrected. Then, for each corrected image, an area of ​​the same size is cropped, and the final display result of the subject is determined based on the cropped area.

[0003] When cropping a region on an image, if the cropped area is too large, it will cut into the black background formed by image correction; if the cropped area is too small, the final display effect will be unsatisfactory.

[0004] This shows that existing cropping methods suffer from inaccurate cropping when cropping images. Summary of the Invention

[0005] This application provides an image cropping method, apparatus, electronic device, and storage medium to solve the problem of inaccurate cropping when cropping images.

[0006] In a first aspect, embodiments of this application provide an image cropping method, including:

[0007] When a target object is photographed in a circular manner and multiple first images are obtained after homography transformation, a first target mask image is determined based on the first mask images corresponding to the multiple first images. The first target mask image is determined based on the pixel values ​​corresponding to the pixel points of the multiple first mask images.

[0008] The first target mask image is flipped to obtain the second target mask image;

[0009] Determine the target region centered on the image center point based on the second target mask image;

[0010] The multiple first images are cropped according to the target region.

[0011] Secondly, embodiments of this application provide an image cropping device, including:

[0012] The first determining module is used to determine a first target mask image based on the first mask images corresponding to the multiple first images when the target object is photographed in a circular manner and multiple first images after homography transformation are obtained. The first target mask image is determined based on the pixel values ​​corresponding to the pixel points of the multiple first mask images.

[0013] The first acquisition module is used to flip the first target mask image to acquire the second target mask image;

[0014] The second determining module is used to determine a target region centered on the center point of the image based on the second target Mask image;

[0015] The cropping module is used to crop the plurality of first images according to the target region.

[0016] Thirdly, embodiments of this application provide an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the image cropping method described in the first aspect above.

[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the image cropping method described in the first aspect above.

[0018] The technical solution of this application embodiment determines a first target mask image based on the first mask images corresponding to multiple first images, flips the first target mask image to obtain a second target mask image, and determines a target region based on the second target mask image. A suitable cropping region can be determined in the overlapping area corresponding to multiple first mask images. After determining the target region, multiple first images are cropped according to the target region. Image cropping can be performed relatively accurately based on the suitable cropping region to achieve the ideal cropping effect. Attached Figure Description

[0019] Figure 1a A diagram illustrating that the camera's shooting trajectory deviates from the panoramic shooting path;

[0020] Figure 1b A diagram showing that the camera's shooting trajectory is consistent with the panoramic shooting track;

[0021] Figure 2 A schematic diagram illustrating the image cropping method provided in an embodiment of this application;

[0022] Figure 3a One of the schematic diagrams illustrating the corrected image provided in the embodiments of this application;

[0023] Figure 3b A second schematic diagram illustrating the corrected image provided in an embodiment of this application;

[0024] Figure 4This is a schematic diagram illustrating the determination of the target line segment and the target location provided in an embodiment of this application;

[0025] Figure 5 A schematic diagram illustrating the target image after background replacement provided in an embodiment of this application;

[0026] Figure 6 This is a schematic diagram of the image cropping device provided in an embodiment of this application;

[0027] Figure 7 This is a schematic diagram of the electronic device structure provided in the embodiments of this application. Detailed Implementation

[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0029] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

[0030] In the various embodiments of this application, it should be understood that the sequence number of each process described below does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0031] The image cropping method provided in this application is applied to panoramic shooting scenarios. During the process of panoramic shooting of the target object, vertical and horizontal shaking may occur, causing the camera to deviate from the panoramic shooting track. (See [link to relevant documentation]). Figure 1a The image shown illustrates a specific instance where the camera's shooting trajectory deviates from the panoramic shooting path. Therefore, a homography transformation is needed on the initial captured image to obtain... Figure 1b The image is taken from the camera position shown. After homography transformation of the initial image, a corrected image is obtained. The corrected image is then cropped to obtain the Region of Interest (ROI). The cropped image is then processed to generate the final display result of the target object. However, the accuracy of image cropping is difficult to control, and it is easy to crop too much or too little, affecting the cropping effect.

[0032] This application provides an image cropping method to address the aforementioned problems in panoramic shooting scenarios. This method can crop images relatively accurately and achieve ideal cropping results. The image cropping method provided in the embodiments of this application is described below; see [link to relevant documentation]. Figure 2 As shown, the method includes:

[0033] Step 201: After taking a panoramic photo of the target object and obtaining multiple first images after homography transformation, determine a first target mask image based on the first mask images corresponding to the multiple first images. The first target mask image is determined based on the pixel values ​​corresponding to the pixel points of the multiple first mask images.

[0034] After capturing multiple initial images of the target object through a surround-scan photography process, homography transformation is performed on these initial images to obtain corresponding corrected images. After processing each corrected image, multiple first images are obtained. Then, for each of these first images, a first mask image is obtained. The pixel values ​​in the first mask image are either 0 or a target value. The target value can be 1 or 255, or any other value. For simplicity, the pixel values ​​in the first mask image are typically set to 0 or 1, or 0 or 255.

[0035] After acquiring multiple first mask images, a first target mask image is determined based on the multiple first mask images. The first target mask image is determined based on the pixel values ​​corresponding to the pixels of the multiple first mask images. The first target mask image includes the overlapping areas corresponding to the multiple first mask images.

[0036] Step 202: Flip the first target mask image to obtain the second target mask image.

[0037] After determining the first target mask image, it undergoes a flipping process, including horizontal and vertical flipping. Each subsequent flip is based on the result of the previous flip, and the object of the subsequent flip is the intermediate image determined by the previous flip. Furthermore, the flipping process can proceed either horizontally first and then vertically, or vertically first and then horizontally. The second target mask image is obtained through these two flipping processes.

[0038] Step 203: Determine the target region centered on the center point of the image based on the second target Mask image.

[0039] After determining the second target mask image, a target region is determined based on a preset rule, using the center point of the second target mask image as the center. It should be noted that since the first target mask image includes overlapping areas corresponding to multiple first mask images, and the second target mask image is determined based on the first target mask image, by using the center point of the second target mask image as the center to determine the target region, a suitable cropping region can be determined within the overlapping areas corresponding to multiple first mask images.

[0040] Step 204: Crop the multiple first images according to the target region.

[0041] After determining the target region, image cropping can be performed on each first image based on the target region. During cropping, based on the target region determined on the second target mask image and the corresponding target region determined on the first image, cropping is performed along the boundary line of the target region, which can perform image cropping relatively accurately and achieve the ideal cropping effect.

[0042] In the above-described implementation process of this application, a first target mask image is determined based on the first mask images corresponding to multiple first images. The first target mask image is then flipped to obtain a second target mask image. A target region is determined based on the second target mask image. A suitable cropping region can be determined in the overlapping area corresponding to multiple first mask images. After determining the target region, multiple first images are cropped based on the target region. Image cropping can be performed relatively accurately based on the suitable cropping region to achieve the ideal cropping effect.

[0043] The first image in this embodiment is an image determined after processing the corrected image. The process of obtaining the first image is described below. The method further includes: taking panoramic photos of the target object and performing homography transformation on the multiple photos taken to obtain multiple corrected images; for each corrected image, adjusting the center point of the target object in the corrected image to the center point of the corrected image to obtain the first image corresponding to the corrected image.

[0044] After taking panoramic photos of the target object, multiple initial images are acquired. Due to camera shake during the panoramic shooting process, homography transformation is performed on the initial images to obtain corresponding corrected images. After acquiring multiple corrected images corresponding to the initial images, for each corrected image, the center point of the target object in the corrected image is adjusted to coincide with the center point of the corrected image, thus obtaining the first image corresponding to the corrected image. By moving the center point of the target object to the center point of the corrected image, the center of the target object in multiple first images coincides with the center of the first image, ensuring the subsequent flipping process can proceed. Specifically, when moving the center point of the target object to the center point of the corrected image, the entire corrected image can be translated to achieve this purpose.

[0045] For example, if the target object is a car, multiple initial images of the car are obtained by taking panoramic photos of the car, and homography transformation is performed on these images to determine multiple corresponding corrected images. Figure 3a as well as Figure 3b This is a schematic diagram for correcting an image. Figure 3a as well as Figure 3b The black area in the image is generated by homography transformation. The center point of the car does not coincide with the center of the corrected image. At this time, it is necessary to translate the corrected image so that the center point of the car coincides with the center of the corrected image.

[0046] In the above implementation process of this application, after acquiring multiple correction images, the center point of the target object is adjusted to the center point of the correction image for each correction image. This can ensure that the center of the target object in multiple first images coincides with the center of the first image, and can guarantee the subsequent flipping process.

[0047] The process of determining the first target mask image based on multiple first mask images is described below. Determining the first target mask image based on the first mask images corresponding to the multiple first images includes: performing a pixel-by-pixel comparison of the multiple first mask images; for any pixel among a preset number of pixels, determining its pixel value to be 0 when the pixel values ​​corresponding to the multiple first mask images are all 0, or when the pixel values ​​corresponding to the multiple first mask images are distinct; for any pixel among the preset number of pixels, determining its pixel value to be a target value when the pixel values ​​corresponding to the multiple first mask images are all target values; and generating the first target mask image based on the determined pixel values ​​corresponding to the preset number of pixels; wherein each first mask image corresponds to a preset number of pixels.

[0048] When determining the first target mask image based on the first mask images corresponding to multiple first images, a pixel-by-pixel comparison can be performed on the multiple first mask images. Since the multiple first mask images correspond to the same size, each first mask image corresponds to a preset number of pixels. The pixel-by-pixel comparison of the multiple first mask images can be performed in a specific order, such as row-by-row from top to bottom, from left to right, or column-by-column, or other comparison methods.

[0049] For a given pixel among a preset number of pixels, the pixel values ​​corresponding to multiple first mask images are compared. If the pixel values ​​corresponding to multiple first mask images are all 0, then the pixel value of the current pixel is determined to be 0. If the pixel values ​​corresponding to multiple first mask images are different, then the pixel value of the current pixel is also determined to be 0. If the pixel values ​​corresponding to multiple first mask images are all target values, then the pixel value of the current pixel is determined to be the target value, where the target value can be 1 or 255. Each first mask image corresponds to a preset number of pixels. After determining the pixel values ​​corresponding to the preset number of pixels through pixel-by-pixel comparison, a first target mask image is generated based on the determined pixel values ​​corresponding to the preset number of pixels.

[0050] In this embodiment, the first target mask image is an image regenerated based on the pixel values ​​of multiple first mask images, corresponding to a preset number of pixels. The pixel value of each pixel is determined based on the pixel values ​​corresponding to the multiple first mask images. By generating an image based on the pixel values ​​of the multiple first mask images, a first target mask image including the overlapping areas corresponding to the multiple first mask images can be obtained.

[0051] The above-described implementation process of this application generates a first target mask image that includes the overlapping region corresponding to the multiple first mask images based on the pixel values ​​of the pixels of the multiple first mask images, and can determine a suitable cropping region in the overlapping region corresponding to the multiple first mask images.

[0052] The following describes the flipping process. When flipping the first target mask image to obtain the second target mask image, the process includes: flipping the first target mask image in a first direction to obtain a first intermediate mask image; comparing the first target mask image and the first intermediate mask image pixel by pixel to determine a second intermediate mask image; flipping the second intermediate mask image in a second direction to obtain a third intermediate mask image; and comparing the second intermediate mask image and the third intermediate mask image pixel by pixel to determine the second target mask image. Wherein, the first direction is horizontal and the second direction is vertical, or the first direction is vertical and the second direction is horizontal.

[0053] When flipping the first target mask image, it can be flipped horizontally first and then vertically, or vice versa. The flipping process is described in detail below. First, the first target mask image is flipped in a first direction to obtain the first intermediate mask image. This first direction can be horizontal or vertical, and the center point of the first target mask image is used as the symmetry point during the flipping process. After determining the first intermediate mask image through the flipping process, the first target mask image and the first intermediate mask image are compared pixel by pixel. The second intermediate mask image is generated through this pixel-by-pixel comparison.

[0054] Then, the second intermediate mask image is flipped in a second direction. This second direction can be either vertical or horizontal; specifically, when the first direction is horizontal, the second direction is vertical, and vice versa. The center point of the second intermediate mask image is used as the point of symmetry during the flipping process. After flipping the second intermediate mask image, a third intermediate mask image is obtained. A pixel-by-pixel comparison is then performed between the second and third intermediate mask images to determine the second target mask image.

[0055] The process of comparing the first target mask image and the first intermediate mask image pixel by pixel to determine the second intermediate mask image includes:

[0056] For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both 0, or when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are different, the pixel value of the pixel is determined to be 0.

[0057] For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both target values, the pixel value of the pixel is determined to be the target value;

[0058] A second intermediate mask image is generated based on the pixel values ​​corresponding to the predetermined number of pixels.

[0059] The first target mask image corresponds to a preset number of pixels.

[0060] The first target mask image is generated based on multiple first mask images, corresponding to a preset number of pixels. The first intermediate mask image is generated based on the first target mask image after flipping, also corresponding to a preset number of pixels. For any pixel among the preset number of pixels, the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are compared. When the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both 0, the pixel value of the current pixel is determined to be 0. When the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are different, the pixel value of the current pixel is determined to be 0. When the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both target values, the pixel value of the current pixel is determined to be the target value, which can be 1 or 255. After comparing each pixel of the first target mask image and the first intermediate mask image and determining the pixel values ​​corresponding to the preset number of pixels, the second intermediate mask image is generated based on the determined pixel values ​​corresponding to the preset number of pixels.

[0061] Accordingly, when performing a pixel-by-pixel comparison between the second intermediate mask image and the third intermediate mask image to determine the second target mask image, the process includes:

[0062] For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are both 0, or when the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are different, the pixel value of the pixel is determined to be 0.

[0063] For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are both target values, the pixel value of the pixel is determined to be the target value;

[0064] A second target mask image is generated based on the pixel values ​​corresponding to the predetermined number of pixels.

[0065] The second intermediate mask image corresponds to a preset number of pixels, and the third intermediate mask image is generated based on the second intermediate mask image, also corresponding to a preset number of pixels. For any pixel among the preset number of pixels, the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are compared. When the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are both 0, the pixel value of the current pixel is determined to be 0; when the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are different, the pixel value of the current pixel is determined to be 0; when the pixel values ​​corresponding to the second intermediate mask image and the third intermediate mask image are both target values, the pixel value of the current pixel is determined to be the target value, where the target value can be 1 or 255. After comparing each pixel of the second intermediate mask image and the third intermediate mask image and determining the pixel values ​​corresponding to the preset number of pixels, the second target mask image is generated based on the determined pixel values ​​corresponding to the preset number of pixels.

[0066] In the above implementation process of this application, by performing a first-direction flipping process on the first target mask image to obtain an intermediate image, and performing a second-direction flipping process on the intermediate image to determine the second target mask image, a second target mask image including a symmetrical region can be obtained, so as to determine the cropping region based on the second target mask image.

[0067] The process of determining the target region is described below. When determining the target region centered on the image center point based on the second target mask image, it includes: determining the target position based on the intersection of the target line segment and the boundary line of the first region in the second target mask image; determining a first distance parameter and a second distance parameter based on the horizontal and vertical distances between the target position and the image center point of the second target mask image; and determining the target region centered on the image center point of the second target mask image based on the first distance parameter and the second distance parameter. The target line segment is the line segment determined by the image center point of the second target mask image and any vertex of the second target mask image, and the pixel values ​​of the pixels within the first region are non-zero target values.

[0068] After determining the second target mask image, the target line segment is determined based on the line connecting the center point of the second target mask image to any one of the four vertices of the second target mask image. See also Figure 4The diagram illustrates a specific method for determining a target line segment based on the line connecting the center point of the second target mask image to its top-left vertex. Since the second target mask image is generated through horizontal and vertical flipping, it is symmetrical about both the horizontal and vertical center lines. Therefore, the target line segment can be determined based on the line connecting the image center to any vertex. For example, the target line segment can be determined based on the line connecting the image center to its top-right vertex, or based on the line connecting the image center to its bottom-right vertex, or based on the line connecting the image center to its bottom-left vertex.

[0069] Based on the different pixel values ​​corresponding to pixels, the second target mask image is divided into a first region where the pixel value is the target value, and a second region where the pixel value is 0. For the first region in the second target mask image, the pixel values ​​of the pixels within it and on its boundaries are all non-zero target values; for example, the pixel value can be 1 or 255. In this embodiment, the first region includes multiple pixels with target values. It can be understood that the region in the second target mask image where the pixel value is non-zero target value is the first region, and the boundary line of the first region is the region dividing line between the first and second regions. After determining the target line segment, the target position is determined based on the intersection point of the target line segment and the boundary line of the first region in the second target mask image. See also... Figure 4 As shown, the target line segment is determined by connecting the center point of the second target Mask image with the upper left vertex, and the target position is determined by the intersection point P of the target line segment and the boundary line of the symmetrical polygon (first region).

[0070] After determining the target location, the horizontal and vertical distances between the target location and the center point of the second target mask image are obtained. A first distance parameter is determined based on the horizontal distance, and a second distance parameter is determined based on the vertical distance. Then, based on the first and second distance parameters, the target region centered on the center point of the second target mask image is determined.

[0071] Among them, determining the target area based on the first distance parameter and the second distance parameter includes:

[0072] The length and width of the target region are determined based on twice the first distance parameter and twice the second distance parameter; the target region is determined based on the image center point of the second target mask image as the center point, according to the length and width of the target region.

[0073] After determining the first distance parameter and the second distance parameter, the length of the target region is determined by twice the first distance parameter, and the width of the target region is determined by twice the second distance parameter. The target region is determined based on the length of the target region, the width of the target region, and the center point of the second target mask image, and the center point of the target region coincides with the center point of the second target mask image.

[0074] In the above implementation process of this application, by determining the target line segment, determining the target position based on the intersection of the target line segment and the boundary line of the first region, and determining the distance parameters based on the horizontal and vertical distances between the target position and the center point of the image, the target region can be determined based on the distance parameters and the center point of the second target Mask image.

[0075] It should be noted that the center point of the second target mask image coincides with the center points of multiple first images. After determining the target region on the second target mask image, the corresponding target region on each first image can be determined based on the center point. Then, cropping can be performed along the boundary line of the target region to achieve relatively accurate image cropping and achieve the desired cropping effect.

[0076] In one embodiment of this application, after cropping the plurality of first images according to the target region, the method further includes: performing image stitching processing on the plurality of target images corresponding to the plurality of first images to obtain a three-dimensional display animation corresponding to the target object; wherein, the target image is an image determined after cropping the first image.

[0077] After cropping multiple first images, corresponding target images are obtained. Since these target images correspond to different shooting angles, they can be stitched together to obtain a 3D animation of the target object, showcasing it from all angles. It should also be noted that during the generation of the 3D animation, image background replacement and hiding of privacy information can also be performed. See [link / reference] Figure 5 The image shown is a schematic diagram of the target image after the background of the target object has been replaced.

[0078] The above implementation process generates a 3D display animation based on the cropped target image, which can display the target object from all angles and achieve an effective panoramic display effect.

[0079] This application provides an image cropping device, see [link to relevant documentation]. Figure 6 As shown, it includes:

[0080] The first determining module 601 is used to determine a first target mask image based on the first mask images corresponding to the multiple first images when the target object is photographed in a circular manner and multiple first images after homography transformation are obtained. The first target mask image is determined based on the pixel values ​​corresponding to the pixel points of the multiple first mask images.

[0081] The first acquisition module 602 is used to flip the first target mask image to acquire the second target mask image;

[0082] The second determining module 603 is used to determine a target region centered on the center point of the image based on the second target Mask image;

[0083] The cropping module 604 is used to crop the plurality of first images according to the target region.

[0084] Optionally, the device further includes:

[0085] The second acquisition module is used to acquire multiple corrected images after taking a panoramic photo of the target object and performing homography transformation on the multiple captured images.

[0086] The third acquisition module is used to adjust the center point of the target object in each correction image to the center point of the correction image, and acquire the first image corresponding to the correction image.

[0087] Optionally, the first determining module includes:

[0088] The first comparison submodule is used to perform pixel-by-pixel comparison of multiple first Mask images;

[0089] The first determining submodule is used to determine the pixel value of any pixel point among a preset number of pixels to be 0 when the pixel values ​​corresponding to the multiple first Mask images are all 0, or when the pixel values ​​corresponding to the multiple first Mask images are different.

[0090] The second determining submodule is used to determine the pixel value of any pixel point among a preset number of pixels as the target value when the pixel values ​​corresponding to the plurality of first Mask images are all target values.

[0091] The first generation submodule is used to generate the first target Mask image based on the pixel values ​​corresponding to the predetermined number of pixels.

[0092] Each first mask image corresponds to a preset number of pixels.

[0093] Optionally, the first acquisition module includes:

[0094] The first acquisition submodule is used to perform a first-direction flipping process on the first target Mask image to obtain a first intermediate Mask image;

[0095] The first comparison and determination submodule is used to perform a pixel-by-pixel comparison between the first target mask image and the first intermediate mask image to determine the second intermediate mask image.

[0096] The second acquisition submodule is used to perform a second-direction flipping process on the second intermediate mask image to obtain a third intermediate mask image;

[0097] The second comparison and determination submodule is used to perform a pixel-by-pixel comparison between the second intermediate mask image and the third intermediate mask image to determine the second target mask image.

[0098] Wherein, the first direction is a horizontal direction and the second direction is a vertical direction, or the first direction is a vertical direction and the second direction is a horizontal direction.

[0099] Optionally, the first comparison and determination submodule includes:

[0100] The first determining unit is configured to determine the pixel value of any pixel point among a preset number of pixels to be 0 when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both 0, or when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are different.

[0101] The second determining unit is used to determine the pixel value of any pixel point among a preset number of pixels as the target value when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both target values.

[0102] The generation unit is used to generate the second intermediate mask image based on the pixel values ​​corresponding to a predetermined number of pixels.

[0103] The first target mask image corresponds to a preset number of pixels.

[0104] Optionally, the second determining module includes:

[0105] The third determination submodule is used to determine the target position based on the intersection point of the target line segment and the boundary line of the first region in the second target Mask image;

[0106] The fourth determining submodule is used to determine the first distance parameter and the second distance parameter based on the horizontal distance and the vertical distance between the target location and the image center point of the second target Mask image;

[0107] The fifth determining submodule is used to determine the target region centered on the image center point of the second target Mask image based on the first distance parameter and the second distance parameter;

[0108] The target line segment is the line segment defined by the center point of the second target mask image and any vertex of the second target mask image, and the pixel value of the pixel point in the first region is a non-zero target value.

[0109] Optionally, the fifth determining submodule includes:

[0110] The third determining unit is used to determine the length and width of the target area based on twice the first distance parameter and twice the second distance parameter;

[0111] The fourth determining unit is used to determine the target region based on the length and width of the target region, using the center point of the second target mask image as the center point.

[0112] Optionally, the device further includes:

[0113] The stitching acquisition module is used to perform image stitching processing on multiple target images corresponding to the multiple first images after the cropping module crops the multiple first images according to the target area, so as to obtain the three-dimensional display animation corresponding to the target object;

[0114] The target image is the image determined by cropping the first image.

[0115] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0116] This application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described image cropping method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0117] For example, Figure 7 A schematic diagram of the physical structure of an electronic device is shown. (For example...) Figure 7As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to perform the following steps: In the case of taking a panoramic photo of the target object and acquiring multiple first images after homography transformation, determining a first target mask image based on the first mask images corresponding to the multiple first images, wherein the first target mask image is determined based on the pixel values ​​corresponding to the pixels of the multiple first mask images; flipping the first target mask image to obtain a second target mask image; determining a target region centered on the image center point based on the second target mask image; and cropping the multiple first images based on the target region. The processor 710 may also execute other schemes in the embodiments of this application, which will not be further described here.

[0118] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0119] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described image cropping method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0120] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0121] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0122] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0123] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0124] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0125] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0126] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0127] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0128] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0129] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An image cropping method, characterized in that, include: When a target object is photographed in a circular manner and multiple first images are obtained after homography transformation, a first target mask image is determined based on the first mask images corresponding to the multiple first images. The first target mask image is determined based on the pixel values ​​corresponding to the pixels of the multiple first mask images, and the first target mask image includes the overlapping area corresponding to the multiple first mask images. The first target mask image is flipped in a first direction to obtain a first intermediate mask image; The first target mask image and the first intermediate mask image are compared pixel by pixel to determine the second intermediate mask image; The second intermediate mask image is flipped in the second direction to obtain the third intermediate mask image; the first direction and the second direction are perpendicular to each other. The second intermediate mask image and the third intermediate mask image are compared pixel by pixel to determine the second target mask image; Determine the target region centered on the image center point based on the second target mask image; The multiple first images are cropped according to the target region.

2. The method according to claim 1, characterized in that, The method further includes: After taking panoramic photos of the target object and performing homography transformation on the multiple captured images, multiple corrected images are obtained. For each corrected image, the center point of the target object in the corrected image is adjusted to the center point of the corrected image to obtain the first image corresponding to the corrected image.

3. The method according to claim 1, characterized in that, The step of determining the first target mask image based on the first mask images corresponding to the plurality of first images includes: Perform pixel-by-pixel comparison on multiple first Mask images; For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the multiple first Mask images are all 0, or when the pixel values ​​corresponding to the multiple first Mask images are distinct, the pixel value of the pixel is determined to be 0. For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the plurality of first Mask images are all target values, the pixel value of the pixel is determined to be the target value; The first target mask image is generated based on the pixel values ​​corresponding to the predetermined number of pixels. Each first mask image corresponds to a preset number of pixels.

4. The method according to claim 1, characterized in that, The step of comparing the first target mask image and the first intermediate mask image pixel by pixel to determine the second intermediate mask image includes: For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both 0, or when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are different, the pixel value of the pixel is determined to be 0. For any pixel among a preset number of pixels, when the pixel values ​​corresponding to the first target mask image and the first intermediate mask image are both target values, the pixel value of the pixel is determined to be the target value; The second intermediate mask image is generated based on the pixel values ​​corresponding to the predetermined number of pixels. The first target mask image corresponds to a preset number of pixels.

5. The method according to claim 1, characterized in that, Determining the target region centered on the image center point based on the second target mask image includes: The target location is determined based on the intersection of the target line segment and the boundary line of the first region in the second target Mask image; The first distance parameter and the second distance parameter are determined based on the horizontal distance and the vertical distance between the target location and the image center point of the second target Mask image; Based on the first distance parameter and the second distance parameter, the target region centered on the image center point of the second target mask image is determined; The target line segment is the line segment defined by the center point of the second target mask image and any vertex of the second target mask image, and the pixel value of the pixel point in the first region is a non-zero target value.

6. The method according to claim 5, characterized in that, Determining the target region centered on the image center point of the second target mask image based on the first distance parameter and the second distance parameter includes: The length and width of the target region are determined based on twice the first distance parameter and twice the second distance parameter; Using the center point of the second target mask image as the center point, the target region is determined based on the length and width of the target region.

7. The method according to claim 1, characterized in that, After cropping the plurality of first images according to the target region, the method further includes: Image stitching is performed on multiple target images corresponding to the multiple first images to obtain a three-dimensional display animation corresponding to the target object; The target image is the image determined by cropping the first image.

8. An image cropping device, characterized in that, include: The first determining module is used to determine a first target mask image based on the first mask images corresponding to the multiple first images when the target object is photographed in a circular manner and multiple first images after homography transformation are obtained. The first target mask image is determined based on the pixel values ​​corresponding to the pixels of the multiple first mask images. The first target mask image includes the overlapping area corresponding to the multiple first mask images. The first acquisition submodule is used to perform a first-direction flipping process on the first target Mask image to obtain a first intermediate Mask image; The first comparison and determination submodule is used to perform a pixel-by-pixel comparison between the first target mask image and the first intermediate mask image to determine the second intermediate mask image. The second acquisition submodule is used to perform a second-direction flipping process on the second intermediate mask image to acquire a third intermediate mask image; the first direction and the second direction are perpendicular to each other; The second comparison and determination submodule is used to perform a pixel-by-pixel comparison between the second intermediate mask image and the third intermediate mask image to determine the second target mask image. The second determining module is used to determine a target region centered on the center point of the image based on the second target Mask image; The cropping module is used to crop the plurality of first images according to the target region.

9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the image cropping method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the image cropping method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for generating panorama, electronic equipment and storage medium

    CN114066731A

  • Image cutting method and device, terminal and readable storage medium

    CN114549551A