Image stitching method, electronic device and storage medium
By analyzing the pixel value distribution of the image, determining the splicing scene and selecting the target pixel point set, the problem of low image splicing accuracy in the existing technology is solved and higher splicing accuracy is achieved.
Patent Information
- Application Number
- CN202410705915.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-03
AI Technical Summary
Existing image stitching technology is affected by factors such as lighting changes, viewing angle differences, motion blur, scale changes, and unclear features, resulting in low stitching accuracy.
By obtaining the pixel value distribution of the image to be spliced, the current splicing scene is determined, and the target pixel point set is selected according to different scenes to perform image matching and splicing to improve the matching accuracy.
It improves the accuracy of image stitching and reduces the impact of lighting changes, viewing angle differences and other factors on the stitching results.
Smart Images

Figure CN118279141B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an image stitching method, an electronic device and a storage medium. Background Art
[0002] Image stitching technology has made great progress in the past few decades, but it still faces challenges. The existing image stitching technology mainly relies on the similarity between the overlapping areas of each image to be stitched to determine the stitching area, and stitches each image to be stitched into a seamless stitched image through the stitching area. However, when stitching the images to be stitched, it is still affected by a variety of influencing factors, resulting in low image stitching accuracy. For example, the influencing factors can be illumination changes, perspective differences, motion blur, scale changes, and the images to be stitched have fewer features or unclear features.
[0003] In view of the existing technical defects, how to provide an effective image stitching solution is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0004] The present application at least provides an image stitching method, an electronic device and a storage medium.
[0005] The present application provides an image stitching method, comprising: acquiring each image to be stitched, each image to be stitched includes a first image and a second image; determining a current stitching scene according to a pixel value distribution of each pixel point in the first image and / or the second image; determining a target pixel point set from the first image and / or the second image according to a pixel point selection method of the current stitching scene, wherein the pixel point selection methods for different stitching scenes are different; stitching the first image and the second image based on a target matching result of the first image and the second image, wherein the target matching result includes a matching result between target pixel point sets of the two images to be stitched or a matching result between a target pixel point set of one of the images to be stitched and each pixel point in the other image to be stitched.
[0006] The present application provides an image stitching device, comprising: an acquisition module, a first determination module, a second determination module and a stitching module; the acquisition module is used to acquire each image to be stitched, each image to be stitched includes a first image and a second image; the first determination module is used to determine a current stitching scene according to a pixel value distribution of each pixel point in the first image and / or the second image; the second determination module is used to determine a target pixel point set from the first image and / or the second image according to a pixel point selection method of the current stitching scene, and the pixel point selection methods of different stitching scenes are different; the stitching module is used to stitch the first image and the second image based on a target matching result of the first image and the second image, the target matching result including a matching result between target pixel point sets of the two images to be stitched or a matching result between a target pixel point set of one of the images to be stitched and each pixel point in the other image to be stitched.
[0007] The present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned image stitching method.
[0008] The present application provides a computer-readable storage medium on which program instructions are stored. When the program instructions are executed by a processor, the above-mentioned image stitching method is implemented.
[0009] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0012] Figure 1 It is a flowchart of an embodiment of the image stitching method of the present application;
[0013] Figure 2This is a schematic diagram of the distribution of pixel values in an image to be filtered in an embodiment of the image stitching method of the present application;
[0014] Figure 3 Schematic diagram of candidate regions in an embodiment of the image stitching method of the present application;
[0015] Figure 4 is another flow chart of an embodiment of the image stitching method of the present application;
[0016] Figure 5 is a schematic diagram of a stitched image according to an embodiment of the image stitching method of the present application;
[0017] Figure 6 It is a structural schematic diagram of an embodiment of the image stitching device of the present application;
[0018] Figure 7 It is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0019] Figure 8 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0020] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0021] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0022] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0023] The present application provides some image stitching methods and image stitching devices. The application scenarios of the image stitching method include but are not limited to the stitching of multiple video images at the same time and panoramic image acquisition. The execution subject of the image stitching method can be any device with an image stitching function, such as a panoramic image acquisition device or an image stitching device. For example, the image stitching device can be set in a terminal device or a server or other processing device, wherein the terminal device can be a device for image stitching, a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, etc. In some possible implementations, the image stitching method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0024] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of the image stitching method of the present application. Specifically, the image stitching method may include the following steps:
[0025] Step S11: Acquire the images to be stitched.
[0026] Each image to be stitched includes a first image and a second image.
[0027] Acquiring each image to be stitched may be acquiring several images to be stitched. Among them, several images to be stitched may be at least two images to be stitched. Specifically, the way to acquire each image to be stitched may be to acquire each image to be stitched through an image acquisition device and to acquire relevant data of each image to be stitched through a network. In some application scenarios, the image acquisition device may be a panoramic shooting device, a video acquisition device, a medical imaging device, a map surveying and mapping device, or a sensor device. Exemplarily, the way to acquire each image to be stitched through a map surveying and mapping device may be to acquire a large range of image data through aerial photography, and use the image data as relevant data of each image to be stitched. Exemplarily, the way to acquire each image to be stitched through a sensor device may be to acquire image data using a sensor device during engineering measurement or environmental monitoring, and use the image data as relevant data of each image to be stitched. In other application scenarios, acquiring relevant data of each image to be stitched through a network may be to acquire images to be processed from an online gallery, a social media platform, or a professional database. The image to be stitched may contain a target object. Among them, the target object contained in the image to be stitched may be any object or scene that needs to be identified, analyzed, or processed. It is understandable that in different application scenarios, the number of images to be stitched obtained is different and the image types of the images to be stitched are different, and the number and image types of the images to be stitched obtained are not limited. The present application takes any two of the images to be stitched obtained as an example, and each image to be stitched includes a first image and a second image.
[0028] Each image to be stitched may be an image with an overlapping area. The overlapping area corresponding to each image to be stitched may include at least part of the image to be stitched. It can be considered that the overlapping area between the first image and the second image may include at least part of the first image and at least part of the second image.
[0029] Step S12: determining a current stitching scene according to the pixel value distribution of each pixel point in the first image and / or the second image.
[0030] The pixel value distribution may refer to the distribution of the values of each pixel point in the image to be spliced in the entire image. Specifically, the pixel value distribution may include the values of each pixel point in the image to be spliced and the number of pixels. Exemplarily, the pixel value distribution may include the pixel values of all pixel positions in the image to be spliced, and the pixel values of each pixel position may be the same or different. Exemplarily, the pixel distribution may be a pixel histogram corresponding to the image to be spliced. The pixel histogram is used to represent the frequency or number of each pixel value in the image to be spliced. In some application scenarios, the first image and / or the second image in the image to be spliced may be a grayscale image, in which case the pixel value distribution may be a pixel histogram between pixel values 0 and 255. In other application scenarios, the first image and / or the second image in the image to be spliced may also be a color image, in which case the pixel value distribution may be the pixel value distribution of different color channels. In some application scenarios, the pixel value distribution may refer to the distribution of the values of each pixel point in the first image in the entire image. In some application scenarios, the pixel value distribution may refer to the distribution of the values of each pixel point in the second image in the entire image. In other application scenarios, the pixel value distribution may refer to the distribution of the values of each pixel point in the first image in the entire image and the distribution of the values of each pixel point in the second image in the entire image.
[0031] The current stitching scene may be the current stitching scene of the image to be stitched. The current stitching scene may refer to the current stitching scene of the first image and / or the current stitching scene of the second image. Specifically, the current stitching scene may include selection conditions for indicating how to select each pixel point in the image to be stitched. In some application scenarios, an association relationship between the selection conditions corresponding to the pixel points and several preset stitching scenes and each pixel value in the pixel value distribution situation may be established in advance. Specifically, the selection conditions corresponding to the pixel points may be to select different pixel points from each pixel value in the pixel value distribution situation based on different preset stitching scenes. Different preset stitching scenes may respectively include different selection conditions for indicating how to select each pixel point in the image to be stitched. Several preset stitching scenes may be one preset stitching scene or multiple preset stitching scenes. Multiple preset stitching scenes may be at least two preset stitching scenes. The selection conditions corresponding to different preset stitching scenes may represent the selection range of the pixel points in the image to be stitched. For example, the image to be stitched may be a grayscale image, the pixel value distribution of the image to be stitched may be each pixel point between pixel values 0 and 255, and the preset stitching scenes of the image to be stitched may be a first-order stitching scene, a second-order stitching scene, and a third-order stitching scene. In some application scenarios, the preset stitching scene with the largest selection range of pixel points may include the selection range of pixel points in at least some preset stitching scenes. The selection condition of the first-order stitching scene may be to select the pixel points in the image to be stitched whose selection range is between pixel values 0 and 150. The selection condition of the second-order stitching scene may be to select the pixel points in the image to be stitched whose selection range is between pixel values 0 and 200. The selection condition of the third-order stitching scene may be to select the pixel points in the image to be stitched whose selection range is between pixel values 0 and 250. In some application scenarios, the selection ranges of pixel points in different preset stitching scenes may have intersections. In other application scenarios, the selection ranges of pixels in different preset stitching scenes may be completely different and the selection ranges of pixels in different preset stitching scenes may be added together to obtain the complete pixel value distribution corresponding to the image to be stitched. For example, the selection conditions of the first-order stitching scene, the second-order stitching scene, and the third-order stitching scene may be to select the selection ranges of pixels in the image to be stitched as pixel values 0 to 150, pixel values 151 to 200, and pixel values 201 to 255, respectively. It is understandable that different preset stitching scenes have different selection ranges of pixels determined based on the pixel value distribution. The current stitching scene may be one of the above-mentioned preset stitching scenes. The current stitching scene corresponding to different images to be stitched is determined based on the pixel value distribution of the image to be stitched. The current stitching scene of the first image and the current stitching scene of the second image may be the same or different.
[0032] In some application scenarios, the pixel value distribution of the images to be stitched may be one or more. The pixel value distribution of the images to be stitched may be the pixel value distribution of each pixel point in the entire image to be stitched. In addition, one of the multiple pixel value distributions may be the pixel value distribution of each pixel point in at least part of the images to be stitched. That is, the images to be stitched are divided into multiple preset candidate areas, and each preset candidate area corresponds to a pixel value distribution.
[0033] Step S13: determining a target pixel point set from the first image and / or the second image according to the pixel point selection method of the current stitching scene.
[0034] The pixel selection methods for different stitching scenes are different.
[0035] The pixel selection method may be a selection condition for each pixel in the above-mentioned image to be stitched. In some application scenarios, the preset stitching scenes may be a first stitching scene and a second stitching scene. The current stitching scene may be one of the first stitching scene and the second stitching scene. The pixel selection method of the current stitching scene may be a selection range of each pixel in the image to be stitched in the case of the first stitching scene. The pixel selection method of the current stitching scene may also be a selection range of each pixel in the image to be stitched in the case of the second stitching scene. Determining the target pixel set from the first image and / or the second image may refer to determining the target pixel set of the first image from the first image and / or determining the target pixel set of the second image from the second image. In some application scenarios, the target pixel set of the first image is determined from the first image according to the pixel selection method of the current stitching scene corresponding to the first image. Among them, the pixel selection method of the current stitching scene corresponding to the first image may be a selection range of each pixel in the first image in the case of the first stitching scene or the second stitching scene. In some application scenarios, the target pixel set of the second image is determined from the second image according to the pixel selection method of the current splicing scene corresponding to the second image. Among them, the pixel selection method of the current splicing scene corresponding to the second image can be the selection range of each pixel in the second image in the case of the second splicing scene or the second splicing scene. In other application scenarios, the target pixel set of the first image is determined from the first image according to the pixel selection method of the current splicing scene corresponding to the first image, and the target pixel set of the second image is determined from the first image according to the pixel selection method of the current splicing scene corresponding to the second image. It can be understood that the process of simultaneously determining the target pixel set of the first image and the target pixel set of the second image can refer to the above content, which will not be repeated here. In addition, the current splicing scene corresponding to the first image and the current splicing scene corresponding to the second image can be the same or different, and the current splicing scene corresponding to different images to be spliced is determined based on the pixel value distribution of the images to be spliced.
[0036] In some application scenarios, the target pixel set may be each pixel determined in the entire image to be stitched based on the pixel selection method of the current stitching scene. In other application scenarios, the target pixel set may be each pixel determined in at least part of the image to be stitched based on the pixel selection method of the current stitching scene. Specifically, the target pixel set may be each pixel determined in at least one of the above-mentioned preset candidate areas in the image to be stitched based on the pixel selection method of the current stitching scene.
[0037] Step S14: based on the target matching result of the first image and the second image, the first image and the second image are spliced.
[0038] The target matching result includes a matching result between target pixel point sets of two images to be stitched or a matching result between a target pixel point set of one image to be stitched and each pixel point in another image to be stitched.
[0039] In some application scenarios, the target pixel set of the first image can be used as the first object to be matched, and the target pixel set of the second image can be used as the second object to be matched. The first object to be matched is matched with the second object to be matched to obtain a matching result, which is used as the target matching result between the first image and the second image. In other application scenarios, the target pixel set of the first image can be used as the first object to be matched, and all the pixels of the second image can be used as the second object to be matched. The first object to be matched is matched with the second object to be matched to obtain a matching result, which is used as the target matching result between the first image and the second image. In other application scenarios, all the pixels of the first image can be used as the first object to be matched, and the target pixel set of the second image can be used as the second object to be matched. The first object to be matched is matched with the second object to be matched to obtain a matching result, which is used as the target matching result between the first image and the second image.
[0040] The target matching result may include a successful match result and a failed match result between the first image and the second image. The target matching method of the first to-be-matched object and the second to-be-matched object may be a target matching method such as precise position matching, histogram matching, and similarity matching. After the target matching results are obtained by different target matching methods, the splicing method of the first image and the second image may be different.
[0041] In some application scenarios, accurate position matching can be that the pixel values corresponding to the same position in the preset direction of at least a partial area of the first object to be matched and at least a partial area of the second object to be matched are the same, and the pixel points at the position are recorded as successfully matched. The preset direction can be a row direction or a column direction. For example, the target column with the most successful pixel matches in the column direction is obtained. The target column is taken as the successful matching result, and the other columns except the target column in the first image and the second image are taken as the failed matching results, and the target column corresponding to the successful matching result and the image area corresponding to the target column are taken as the target matching result. In some application scenarios, histogram matching can be respectively obtaining the first histogram and the second histogram corresponding to the pixel points contained in at least a partial area of the first object to be matched and at least a partial area of the second object to be matched. If the first histogram and the second histogram are similar under predetermined conditions, the similar image area is taken as the successful matching result. For example, the predetermined condition can be that the same pixel value reaches a preset number. In some application scenarios, similarity matching can be a similarity match between at least a partial area in the first object to be matched and at least a partial area in the second object to be matched. If the similarity match reaches a similarity threshold, the image area corresponding to the similarity reaching the similarity threshold is taken as a successful match result.
[0042] In some application scenarios, the first target area corresponding to the successful matching result in the target matching result is determined in the first image, and the second target area corresponding to the successful matching result in the target matching result is determined in the second image, and the first image and the second image are spliced based on the image area. In some application scenarios, the splicing method can be to use the first target area and the second target area as the superposition area, and superimpose the first image and the second image based on the superposition area to obtain the final spliced image. In other application scenarios, the splicing method can also be to remove at least part of the image on one side of the first target area of the first image along the splicing direction, and remove at least part of the image on the opposite side corresponding to the second target area of the second image and one of the above-mentioned sides. And align and splice the removed first image and the removed second image and the first target area or the second target area. Exemplarily, the splicing direction is the vertical column direction, remove the right image of the first target area of the first image, remove the left image of the second target area of the second image, and align and splice the removed first image and the removed second image and the second target area to obtain the spliced image.
[0043] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0044] In some embodiments, the stitching scene includes a first stitching scene and a second stitching scene, and the above step S12 may include the following steps: First, take the first image or the second image as the reference image, and determine the first candidate pixel set for the first stitching scene in the reference image and the second candidate pixel set for the second stitching scene in the reference image according to the pixel value distribution of each pixel in the reference image. Then, calculate the pixel ratio between the number of pixels in the first candidate pixel set and the number of pixels in the second candidate pixel set. Next, based on the relationship between the pixel ratio and the expected proportion of the scene, determine the current stitching scene of the reference image, and the expected proportion of the scene represents the expected ratio between the number of pixels in the reference image with respect to the first stitching scene and the number of pixels in the reference image with respect to the second stitching scene.
[0045] In some application scenarios, if the current stitching scene is determined and the target pixel set is extracted for only one of the images between the first image and the second image, and the current stitching scene of the first image and the target pixel set of the first image or the current stitching scene of the second image and the target pixel set of the second image are obtained, then the reference image can be the first image or the second image. In other application scenarios, the current stitching scene can be determined and the target pixel set can be extracted for both the first image and the second image, and the current stitching scene of the first image and the target pixel set of the first image and the current stitching scene of the second image and the target pixel set of the second image are obtained. This application takes the method of determining the current stitching scene and extracting the target pixel set for only one of the images between the first image and the second image in the first application scenario as an example. The process of determining the current stitching scene and extracting the target pixel set for only one of the images between the first image and the second image in the second application scenario can refer to the content of the first application scenario, and will not be repeated below.
[0046] In some embodiments, the above-mentioned step of determining the first candidate pixel set for the first stitching scene in the reference image and the second candidate pixel set for the second stitching scene in the reference image according to the pixel value distribution of each pixel in the reference image may include the following steps: first, obtaining a first scene threshold corresponding to the first stitching scene and a second scene threshold corresponding to the second stitching scene, wherein the first scene threshold represents the maximum pixel value of the pixel that can be selected in the reference image under the first stitching scene, and the second scene threshold represents the maximum pixel value of the pixel that can be selected in the reference image under the second stitching scene. Subsequently, pixels whose pixel values are lower than the first scene threshold are selected from the reference image to obtain the first candidate pixel set, and pixels whose pixel values are lower than the second scene threshold are selected from the reference image to obtain the second candidate pixel set.
[0047] The stitching scene may be the aforementioned preset stitching scenes. The stitching scene may include a first stitching scene and a second stitching scene. In some application scenarios, the first stitching scene may be a difficult scene, and the second stitching scene may be a regular scene. The selection range of pixels in the first stitching scene may include the selection range of pixels in the second stitching scene. The selection range of pixels in the first stitching scene is larger.
[0048] In some application scenarios, the first image is used as a reference image, and according to the pixel value distribution of each pixel in the first image, a first set of candidate pixels in the first image regarding the first stitching scene and a second set of candidate pixels in the first image regarding the second stitching scene are determined. In other application scenarios, the second image is used as a reference image, and according to the pixel value distribution of each pixel in the second image, a first set of candidate pixels in the second image regarding the first stitching scene and a second set of candidate pixels in the second image regarding the second stitching scene are determined. This application takes the first image as a reference image as an example, and the process of using the second image as a reference image can refer to the process of using the first image as a reference image, which will not be repeated below.
[0049] Acquire several preset scene thresholds. The several preset scene thresholds may include a first scene threshold and a second scene threshold. In some application scenarios, a one-to-one correspondence between several preset scene thresholds and several preset stitching scenes may be pre-established. The preset scene threshold represents the maximum pixel value of a pixel point that can be selected in the reference image under the preset stitching scene. It is understandable that the number of the preset scene thresholds acquired is the same as the number of preset stitching scenes in the reference image.
[0050] The preset scene thresholds corresponding to the preset stitching scenes of different reference images are different. In some application scenarios, the preset scene threshold is determined based on the material of the target object collected by the above-mentioned image acquisition device. The materials of the collected target objects are different, and the preset scene thresholds obtained may be the same or different. For example, the material of the first target object collected by the image acquisition device is the first material, and the reference image collected is the first image of the first target object and the second image of the first target object. Several preset stitching scenes may include the first scene threshold of the first target object. The material of the second target object collected by the image acquisition device is the second material, and the reference image collected is the first image of the second target object and the second image of the second target object. Several preset stitching scenes may include the first stitching scene of the second target object and the second stitching scene of the second target object. Several preset scene thresholds may include the first scene threshold of the second target object. It can be understood that for target objects with different materials, the division of the preset stitching scenes may be at least partially the same, may be completely the same, and are both the first stitching scene and the second stitching scene. For target objects of different materials, the preset scene thresholds corresponding to the same preset stitching scene may be at least partially different, or may be completely different. Specifically, the first scene threshold of the first target object and the first scene threshold of the second target object may be the same or different. The second scene threshold of the first target object and the second scene threshold of the second target object may be the same or different.
[0051] In some application scenarios, a first scene threshold corresponding to a first stitching scene of a first image is obtained. The first scene threshold represents the maximum pixel value of a pixel point that can be selected in a reference image in the first stitching scene. The first scene threshold can be expressed as HARD_T. The first scene threshold can be set to 250. In other application scenarios, a second scene threshold corresponding to a second stitching scene of the first image is obtained. The second scene threshold represents the maximum pixel value of a pixel point that can be selected in a reference image in the second stitching scene. The second scene threshold can be expressed as NORMAL_T. The first scene threshold can be set to 237. Pixel points whose pixel values are lower than the first scene threshold are selected from the first image to obtain a first candidate pixel point set of the first image. Pixel points whose pixel values are lower than the second scene threshold are selected from the first image to obtain a second candidate pixel point set of the first image. It can be understood that the selection range of the first candidate pixel point set can include the selection range of the pixel points in the second candidate pixel point set. The selection range of the pixel points in the first candidate pixel point set is larger.
[0052] In some application scenarios, the method for obtaining the first candidate pixel set and the second candidate pixel set of the reference image can be to traverse all pixels of the reference image. For each pixel, if the pixel is a pixel below the first scene threshold, the pixel is added to the first candidate pixel set, and the first counter corresponding to the first candidate pixel set is incremented by one. For each pixel, if the pixel is a pixel below the second scene threshold, the pixel is added to the second candidate pixel set, and the second counter corresponding to the second candidate pixel set is incremented by one. The first candidate pixel set can be represented as HARD_P. The second candidate pixel set can be represented as NORMAL_P. The final values of the first counter and the second counter are obtained respectively. Among them, the final value of the first counter can be represented as HARD_N. The final value of the second counter can be represented as NORMAL_N.
[0053] Calculate the pixel ratio between the number of pixels in the first candidate pixel set and the number of pixels in the second candidate pixel set. The number of pixels in the first candidate pixel set may be the final value of the first counter. The number of pixels in the second candidate pixel set may be the final value of the second counter. The pixel ratio may characterize the proportion of the number of pixels between different candidate pixel sets. Specifically, the process of calculating the pixel ratio may refer to formula (1):
[0054] Formula (1);
[0055] in, It can represent the pixel ratio. It can represent the number of pixels in the second candidate pixel set. It can represent the number of pixels in the first candidate pixel set.
[0056] Get the expected proportion of the scene. In some application scenarios, an association relationship between several preset splicing scenes and the expected proportion of the scene can be established in advance. There is a corresponding expected proportion of the scene between any two preset splicing scenes. The expected proportion of the scene represents the expected ratio between the number of pixels in the reference image with respect to the first splicing scene and the number of pixels in the reference image with respect to the second splicing scene. The expected proportion of the scene can be preset according to the splicing accuracy requirement. The expected proportion of the scene can be expressed as, for example, SCEEN_R. The expected proportion of the scene can be 0.77. In some application scenarios, a discriminator can be used to output the current splicing scene. The discriminator is used to determine the relationship between the pixel ratio and the expected proportion of the scene. In some application scenarios, if the pixel ratio is greater than the expected proportion of the scene, that is, NH_R is greater than SCEEN_R, the current splicing scene is determined as the second splicing scene. Among them, the pixel ratio greater than the expected proportion of the scene can indicate that the number of pixels in the second candidate pixel set corresponding to the second splicing scene is the majority relative to the expected number. In other application scenarios, if the pixel ratio is less than or equal to the expected proportion of the scene, that is, NH_R is less than or equal to SCEEN_R, the current stitching scene is determined as the first stitching scene. Among them, the pixel ratio is greater than the expected proportion of the scene, which can indicate that the number of pixels in the second candidate pixel set corresponding to the second stitching scene is a minority relative to the expected number or is exactly equal to the expected number.
[0057] It can be considered that the current stitching scene determined by the distribution of pixel values in different reference images and the expected scene proportion has the characteristics of differentiated processing. Specifically, the current stitching scene obtained by comparing the pixel ratio and the expected scene proportion between different preset stitching scenes is a scene that better meets the stitching accuracy requirements. In turn, the target matching result determined based on the current stitching scene is more accurate, thereby improving the accuracy of image stitching.
[0058] In some embodiments, the current stitching scene is determined according to the pixel value distribution of each pixel point in the first image and / or the second image, including: first, graying the first image and the second image respectively to obtain a first grayscale image and a second grayscale image. Then, filtering the first grayscale image based on a pre-set first background threshold to obtain a first candidate image, and obtaining a second candidate image based on a pre-set second background threshold and the second grayscale image. Next, the current stitching scene is determined according to the pixel value distribution of each pixel point in the first candidate image and / or the second candidate image.
[0059] In some application scenarios, if the first image and the second image included in the image to be stitched are color images, the first image and the second image are respectively grayscaled to obtain the first grayscale image and the second grayscale image. In some application scenarios, if the first image and the second image included in the image to be stitched are grayscale images, the first image and the second image can also be grayscaled.
[0060] The first background threshold and the second background threshold are both pre-set pixel background thresholds. The pixel background threshold represents the maximum pixel value of the pixel point that can be retained in the image to be stitched or the minimum pixel value of the pixel point that can be filtered in the image to be stitched. The pixel background thresholds corresponding to different images to be stitched may be different. The first background threshold and the second background threshold correspond to the first image and the second image, respectively. The first background threshold of the first image and the second background threshold of the second image may be the same or different, which is not limited here. In some application scenarios, the first grayscale image is filtered based on the pre-set first background threshold to obtain the first candidate image, and the process of obtaining the second candidate image based on the pre-set second background threshold and the second grayscale image can be based on the same pixel background threshold, and the first grayscale image and the second grayscale image are filtered respectively, wherein the first background threshold is the same as the second background threshold.
[0061] In some embodiments, the above-mentioned step of filtering the first grayscale image based on the preset first background threshold to obtain the first candidate image, and the step of obtaining the second candidate image based on the preset second background threshold and the second grayscale image may include the following steps: first, the first grayscale image is used as the image to be filtered, the first background threshold is used as the filtering judgment threshold, and the first candidate image is used as the target candidate image, or the second grayscale image is used as the image to be filtered, the second background threshold is used as the filtering judgment threshold, and the second candidate image is used as the target candidate image. Subsequently, the pixel points of the image to be filtered whose pixel values are greater than or equal to the filtering judgment threshold are determined as the points to be filtered. Then, in response to the number of pixel points on one side of the point to be filtered in the preset direction in the image to be filtered being greater than or equal to the preset number, the pixel points corresponding to the one side of the point to be filtered are used as the reserved pixel points. Or, in response to the number of pixel points on one side of the point to be filtered in the preset direction in the image to be filtered being less than the preset number, the pixel points corresponding to the one side of the point to be filtered are used as the points to be filtered. Then, the pixel values of each point to be filtered are set to the preset pixel values.
[0062] The filtering judgment threshold is the above-mentioned pixel background threshold. The filtering judgment threshold can be expressed as BK_T. First, the pixel points whose pixel values in the image to be filtered are greater than or equal to the filtering judgment threshold are determined as the points to be filtered. The points to be filtered include initial points to be filtered and target points to be filtered. Specifically, the pixel points whose pixel values in the image to be filtered are greater than or equal to the filtering judgment threshold are determined as the initial points to be filtered. The preset direction can be a single direction or multiple directions. It can be understood that the process of determining the retained pixels each time can be determined successively along a single direction or synchronously along multiple different directions. In some application scenarios, the pixel points corresponding to one side of the point to be filtered can refer to the pixels between two adjacent initial points to be filtered in the preset direction in the image to be filtered. In other application scenarios, the pixel points corresponding to one side of the point to be filtered can refer to the first initial point to be filtered and the last initial point to be filtered in a preset direction, the first initial point to be filtered along one side of the preset direction, and the last initial point to be filtered along one side of the preset direction. The preset number can be pre-set according to the splicing accuracy requirements. Exemplarily, the preset number may be 6. The preset pixel value may represent the expected pixel value of the pixel point in the background area. Exemplarily, the preset pixel value may be that the pixel value of each pixel point in the background area is set to 255. It is understandable that each pixel point in the background area is set to white.
[0063] In some application scenarios, in response to the number of pixels on one side of the initial point to be filtered in the preset direction in the image to be filtered being greater than or equal to the preset number, the pixels corresponding to one side of the initial point to be filtered are used as reserved pixels. Each point to be filtered may be a pixel other than the reserved pixel. The pixel values of each point to be filtered are set to the preset pixel value, and the process of obtaining the target candidate image may be to set all the pixels in the image to be filtered except the reserved pixel to the preset pixel value, and obtain the target candidate image. In other application scenarios, in response to the number of pixels on one side of the point to be filtered in the preset direction in the image to be filtered being less than the preset number, the pixels corresponding to one side of the initial point to be filtered are used as the target point to be filtered. Each point to be filtered may be each initial point to be filtered and each target point to be filtered. The pixel values of each point to be filtered are set to the preset pixel value, and the process of obtaining the target candidate image may be to set all the pixels in the image to be filtered except the initial points to be filtered and each target point to be filtered to the preset pixel value, and obtain the target candidate image.
[0064] In some other application scenarios, the preset direction may include a first direction and a second direction. In response to each pixel point in the image to be filtered being less than a filtering judgment threshold, the pixel point is used as a first candidate pixel point, and the first candidate pixel points that are continuous in the first direction are used as a first candidate pixel string, and / or, the first candidate pixel points that are continuous in the second direction are used as a second candidate pixel string. For each first candidate pixel string, in response to the number of pixels in the first candidate pixel string being greater than or equal to a preset number, the first candidate pixel string is used as a first target pixel string, and / or, for each second candidate pixel string, in response to the number of pixels in the second candidate pixel string being greater than or equal to a preset number, the second candidate pixel string is used as a second target pixel string. Based on each first target pixel string and / or each second target pixel string, a target candidate image is determined.
[0065] Exemplarily, the filtering judgment threshold BK_T of the first grayscale image is first determined. Specifically, the background in the background area of the first grayscale image is pure white, and the filtering judgment threshold BK_T can be set to 255. The preset direction can be the width direction of the first grayscale image, the row-by-row direction. Traverse the first grayscale image row by row, and record the candidate pixel strings whose continuous pixel values are less than the filtering judgment threshold. And record the number of continuous pixel points of each candidate pixel string, and the number of continuous pixel points can be expressed as M1. The preset number can be expressed as M2. M2 can be 6. For each candidate pixel string, in response to M1 being less than M2, the candidate pixel string is determined as the target pixel string. The pixels of each pixel point in the target pixel string are set to the filtering judgment threshold BK_T to obtain a candidate image. In some application scenarios, on the basis of row-by-row traversal, the candidate image after row-by-row traversal processing is subjected to the same column-by-column traversal processing along the height direction of the candidate image to obtain the first candidate image. In other application scenarios, row-by-row traversal processing and column-by-column traversal processing can be synchronized. In some application scenarios, the first grayscale image is the image to be filtered, the first background threshold is the filtering judgment threshold, and the first candidate image is the target candidate image. In other application scenarios, the second grayscale image is the image to be filtered, the second background threshold is the filtering judgment threshold, and the second candidate image is the target candidate image. This application takes the image to be filtered, the filtering judgment threshold, and the target candidate image as an example, where the image to be filtered, the filtering judgment threshold, and the target candidate image are respectively the first grayscale image, the first background threshold, and the first candidate image. The situation where the image to be filtered, the filtering judgment threshold, and the target candidate image are respectively the second grayscale image, the second background threshold, and the second candidate image can refer to the above content, and will not be repeated here.
[0066] See also Figure 2 , Figure 2 This is a schematic diagram of the distribution of pixel values in an image to be filtered in an embodiment of the image stitching method of the present application.
[0067] like Figure 2 As shown, Figure 2 It is the distribution of pixel values of one column of pixels in the image to be filtered. Along the vertical column downward direction, the first pixel is Px1. The last pixel is Px9. Among them, the pixel values of each pixel Px1, Px2, Px3, Px4, Px5, Px6, Px7, Px8, and Px9 can be 240, 245, 233, 245, 255, 240, 245, 233, 245, respectively. It can be understood that the initial point to be filtered Px5. The pixel values of each pixel Px1, Px2, Px3, Px4, Px5, Px6, Px7, Px8, and Px9 are all set to 255. In the first grayscale image, after each column and each row are processed in the same way, the first candidate image is obtained, which can reduce the influence of noise in the background area, thereby improving the accuracy of subsequent similarity calculations and improving the accuracy of image stitching.
[0068] It can be understood that the above process of obtaining the target candidate image can be regarded as performing scattered point filtering on the image to be filtered in multiple preset directions.
[0069] In some application scenarios, the current stitching scene of the first image is determined based on the pixel value distribution of each pixel in the first candidate image. In some application scenarios, the current stitching scene of the second image is determined based on the pixel value distribution of each pixel in the second candidate image. In other application scenarios, the current stitching scene of the first image and the current stitching scene of the second image are determined based on the pixel value distribution of each pixel in the first candidate image and the second candidate image, respectively. It can be understood that the process of determining the current stitching scene of the first image and / or the current stitching scene of the second image based on the pixel value distribution of each pixel in the first candidate image and / or the second candidate image can refer to the above content and will not be repeated here.
[0070] It can be considered that, taking the first image and the first candidate image as examples, there are a large number of scattered noises in the first image that are very close to the background, but it will have an impact on the current stitching scene and the target matching result that cannot be ignored. The first candidate image is an image that removes the interference of corresponding pixels in the background area corresponding to the filtering judgment threshold. According to the distribution of pixel values of each pixel in the first candidate image and / or the second candidate image, it is more accurate to determine the current stitching scene of the first image and / or the current stitching scene of the second image. In addition, in some application scenarios, due to the fluctuation of the hardware performance of the image acquisition device, this noise close to the background is often full of randomness, and the background of the first image and the background of the second image collected at different times may be different. For difficult scenes with small differences from the background and large background interference, it is very important to perform scattered point filtering in multiple preset directions to effectively reduce image noise.
[0071] In some embodiments, determining the current stitching scene according to the pixel value distribution of each pixel point in the first image and / or the second image includes:
[0072] Firstly, the first image or the second image is used as a reference image, and the reference image is divided into regions to obtain a plurality of first candidate regions.
[0073] Next, according to the pixel value distribution of each pixel point in each first candidate area, the current stitching scene of each first candidate area is determined.
[0074] The reference image is divided into regions to obtain a number of first candidate regions.
[0075] In the present application, the first image is used as a reference image, the first candidate regions are the first candidate regions of the first image, and the current stitching scene of each first candidate region is the current stitching scene of the first image. Specifically, the first candidate image of the first image is used as a reference image to obtain the first candidate regions. It can be understood that the region division of the reference image can be the region division of the first image that has not been subjected to noise reduction processing, or the region division of the first candidate image.
[0076] In some application scenarios, the reference image may be divided into regions by sampling the first image row by row or column by column with a sampling frame of a preset size to obtain a plurality of first candidate regions. The number of pixel rows or the number of pixel columns of each sampling frame is L. Exemplarily, in response to the splicing direction being the vertical column direction, the first image is sampled column by column based on the sampling frame. If the value of the number of columns L is 3 and the first image includes 10 columns of pixels. The number of first candidate regions is 10. In other application scenarios, the reference image may be divided into regions by sampling the reference image with a sampling frame of a preset size to obtain a preset number of matching regions. Specifically, by sampling K groups of matching regions in the reference image, the number of pixel rows or the number of pixel columns of each matching region and the sampling frame is L. Each matching region is a region of the same size. Whether the number of rows or the number of columns in each matching region is fixed is determined based on the splicing direction. Exemplarily, if the splicing direction is the vertical column direction, the number of pixel columns in each matching region is fixed to L. Exemplarily, the value of the number of groups K is 3 and the value of the number of columns L is 3. It is understandable that K groups of matching regions may represent K first candidate regions. The number of groups K and the number of rows L or the number of columns L may be dynamically adjusted according to the stitching accuracy requirement.
[0077] For each first candidate region, the current stitching scene of the first candidate region is determined according to the pixel value distribution of each pixel point in the first candidate region. The current stitching scene of the first candidate region is determined according to the first candidate pixel point set corresponding to the first stitching scene in the first candidate region and the second candidate pixel point set corresponding to the second stitching scene. The current stitching scene of the first candidate region is one of the first stitching scene and the second stitching scene.
[0078] It can be understood that the process of determining the current stitching scene of the first candidate area based on the first candidate pixel set corresponding to the first stitching scene in the first candidate area and the second candidate pixel set corresponding to the second stitching scene can refer to the above-mentioned step of calculating the pixel ratio between the number of pixels in the first candidate pixel set and the number of pixels in the second candidate pixel set, as well as the above-mentioned step of determining the current stitching scene of the reference image based on the relationship between the pixel ratio and the expected proportion of the scene, which will not be repeated here.
[0079] In some embodiments, the target pixel set includes a candidate pixel set of each first candidate area, and the target pixel set is determined from the first image and / or the second image according to the pixel selection method of the current stitching scene, including:
[0080] According to the pixel selection method corresponding to the current stitching scene of each first candidate area, a corresponding candidate pixel point set is determined from each first candidate area.
[0081] For each first candidate region, the current stitching scene of the first candidate region may be one of the first stitching scene and the second stitching scene. The candidate pixel set corresponding to the first candidate region may be the first candidate pixel set or the second candidate pixel set. For each first candidate region, if the current stitching scene of the first candidate region is the first stitching scene, the first scene threshold corresponding to the first stitching scene is obtained. Pixels with pixel values lower than the first scene threshold are selected from the reference image to obtain the first candidate pixel set. In some application scenarios, the first candidate pixel set is used as the target pixel set of the first candidate region. For each first candidate region, if the current stitching scene of the first candidate region is the second stitching scene, the second scene threshold corresponding to the second stitching scene is obtained, and pixels with pixel values lower than the second scene threshold are selected from the reference image to obtain the second candidate pixel set. In some application scenarios, the second candidate pixel set is used as the target pixel set of the second candidate region. It can be understood that each first candidate region and the target pixel set of each first candidate region can be obtained. Specifically, K first candidate regions of the first image and the target pixel set of each first candidate region are obtained.
[0082] In some embodiments, the image stitching method may further include the following steps:
[0083] First, the other image of the first image and the second image except the reference image is used as another image.
[0084] Then, other images are divided into regions to obtain several second candidate regions.
[0085] Next, at least part of the first candidate areas are selected from the first candidate areas as the target area, and similarities are calculated between the candidate pixel point sets of the target area and the second candidate areas in other images. The target matching result includes the similarities between the target area and the second candidate areas.
[0086] If the first image is a reference image, the second image is another image. If the second image is a reference image, the first image is another image. This application takes the first image as a reference image and the second image as another image as an example.
[0087] K first candidate regions of the first image and a set of target pixels of each first candidate region are obtained. The second image is divided into regions to obtain several second candidate regions of the second image. Specifically, the second image can be divided into regions by sampling row by row or column by column in the second image with a sampling frame of the preset size. The sampling frame can be the above-mentioned column number fixed to L. Exemplarily, in response to the splicing direction being the vertical column direction, the second image is sampled column by column based on the above-mentioned sampling frame. If the value of the number of columns L is 3 and the second image includes 10 columns of pixels. Then the number of second candidate regions A, A value is 10.
[0088] The candidate pixel set of the target area may be a first candidate pixel set corresponding to the first stitching scene and a second candidate pixel set corresponding to the second stitching scene. The current stitching scene of the target area and the target pixel set corresponding to the current stitching scene are determined. The current stitching scene of the target area is one of the first stitching scene and the second stitching scene. The target pixel set of the target area is one of the first candidate area and the second candidate area. In some application scenarios, selecting at least part of the first candidate areas from each first candidate area as the target area may be selecting K first candidate areas as the target area based on sampling accuracy. And obtain the target pixel set corresponding to the current stitching scene of the target area.
[0089] For a target area, the target pixel set in the candidate pixel set of the target area is similar to each second candidate area in other images. For a target area, the target pixel set in each candidate pixel set of the target area is similar to each second candidate area in other images. The target matching result includes the similarity between each target area and each second candidate area. In some application scenarios, the target matching result includes each candidate similarity between each target area and each second candidate area. In other application scenarios, the target matching result includes the maximum similarity between each target area and each second candidate area. The target area and the second candidate area corresponding to the maximum similarity are used as the successful matching results in the above target matching results.
[0090] In some embodiments, at least part of the first candidate regions are selected from each first candidate region as the target region, and the candidate pixel set of the target region is respectively calculated with each second candidate region in other images for similarity, including: first, the candidate pixel set of the target region is used as the first object to be matched, the second candidate region is used as the second object to be matched, and the similarity between the candidate pixel set of the target region and the second candidate region is used as the candidate similarity; then, the pixel value similarity between the first object to be matched and the second object to be matched is calculated; secondly, the hash similarity between the first object to be matched and the second object to be matched is calculated; then, the first similarity is determined based on the pixel value similarity and the hash similarity and the first weight. Then, the candidate similarity is determined based on the first similarity and the number of pixels in the first object to be matched.
[0091] The candidate pixel set of the target area is taken as the first object to be matched, the second candidate area is taken as the second object to be matched, and the similarity between the candidate pixel set of the target area and the second candidate area is taken as the candidate similarity.
[0092] In some application scenarios, the candidate pixel set of the target area may refer to the target pixel set corresponding to the current splicing scene determined based on the pixel value distribution of each pixel of the first image. In other application scenarios, the candidate pixel set of the target area may also refer to the candidate pixel set determined by the pixel value distribution of each pixel of the first image and the second image. Specifically, after the current splicing scene is determined based on the pixel value distribution of each pixel of the first image, the current splicing scene determined by the first image is updated by further integrating the pixel value distribution of each pixel of the second image to obtain the final current splicing scene. The candidate pixel set of the target area refers to the candidate pixel set corresponding to the final current splicing scene. Taking the second candidate area as the second object to be matched may refer to the pixel set corresponding to each second candidate area. Taking the second candidate area as the second object to be matched may also refer to the target pixel set in each second candidate area. Among them, for a target pixel set in a second candidate area, the process of determining the target pixel set in the first candidate area can be referred to, and it will not be repeated here.
[0093] See also Figure 3 , Figure 3 Schematic diagram of candidate regions in an embodiment of the image stitching method of the present application.
[0094] This application takes the candidate pixel set of the target area as the target pixel set as an example. The number of the first objects to be matched is the same as the number of the above target areas. The second objects to be matched are each second candidate area and the pixel set corresponding to each second candidate area. The number of the second objects to be matched is the same as the number of the above second candidate areas. For example, the first objects to be matched are 3 and the second objects to be matched are 10. Figure 3 The first object to be matched in the first candidate image shown includes three target areas, specifically area a, area b, and area c. Figure 3 The second candidate regions in the second to-be-matched object are shown schematically. Each second candidate region includes region e and region d.
[0095] In some application scenarios, the first object to be matched is used as an index, and each candidate similarity is divided into K groups to obtain K similarity groups. Each similarity group includes A candidate similarities. In other application scenarios, each candidate similarity is directly obtained. The total number of each candidate similarity is represented as B. The total number B can be the product of the first object to be matched and the second object to be matched. The calculation method of each candidate similarity between the first object to be matched and the second object to be matched can refer to the following content: Calculate the pixel value similarity between the first object to be matched and the second object to be matched. And calculate the hash similarity between the first object to be matched and the second object to be matched. Based on the pixel value similarity, the hash similarity and the first weight, determine the first similarity. Determine the candidate similarity based on the first similarity and the number of pixels in the first object to be matched.
[0096] Specifically, the process of calculating the pixel value similarity between the first to-be-matched object and the second to-be-matched object may refer to formula (2):
[0097] Formula (2);
[0098] in, It can represent the similarity of pixel values. It can represent the first object to be matched. It can represent the second object to be matched. The tolerance value can represent the preset expected allowable difference. Can represent absolute values. It can represent the absolute value of the difference between the pixel value of the first object to be matched and the pixel value of the second object to be matched. The pixel value similarity SimPixel can represent the feature point set of the first object to be matched P and the second object to be matched for calculating the similarity. The number of feature points whose absolute value of the difference between the corresponding pixel values of each pixel is less than the tolerance value PIXEL_T.
[0099] Specifically, the process of calculating the pixel value similarity between the first to-be-matched object and the second to-be-matched object may refer to formula (3):
[0100] Formula (3);
[0101] in, Can represent hash similarity. It can represent the first object to be matched. Can represent the second object to be matched. Hash similarity Used to evaluate two feature point sets, the first object to be matched P and the second object to be matched The changing trend of the corresponding pixel value of each pixel point at the same pixel position. First, calculate the mean of the pixel value of each feature point set. as well as Then, for the first object to be matched P, the pixel value of each pixel is compared in turn. With the mean If the value of is greater than the mean, the value of the hash table of that point is set to 1, that is , otherwise Then for the second object to be matched Compare the pixel values of each pixel in turn With the mean If the value of is greater than the mean, the value of the hash table of that point is set to 1, that is , otherwise Finally, compare the number of equal values in the hash tables of the two feature point sets to get the hash similarity .
[0102] Specifically, based on the pixel value similarity, the hash similarity and the first weight, the process of determining the first similarity can refer to formula (4):
[0103] Formula (4);
[0104] in, It can represent the first similarity. The above pixel value similarity can be expressed. The above hash similarity can be expressed. The first weight Q1 may be represented by .Exemplarily, the first weight Q1 may be 0.5.
[0105] In some embodiments, determining the candidate similarity based on the first similarity and the number of pixels in the first object to be matched may include the following steps: first, calculating a target ratio between the first similarity and the number of pixels in the first object to be matched. Then, determining the mean square error between the first object to be matched and the second object to be matched. Subsequently, calculating the product between the mean square error and the second weight. Next, calculating the difference between the target ratio and the product, using the difference as the second similarity, and using the second similarity as the candidate similarity.
[0106] The target ratio may be calculated by dividing the first similarity by the number of pixels in the first object to be matched to obtain a first ratio. In some application scenarios, the first ratio is multiplied by the ratio weight to obtain a ratio product. The ratio product is used as the target ratio. In other application scenarios, the first ratio is directly used as the target ratio. It can be considered that the number of pixels in the first object to be matched is different based on the current splicing scene. The final values of the first counter and the second counter are obtained respectively. Among them, the final value of the first counter can be expressed as HARD_N. The final value of the second counter can be expressed as NORMAL_N. The number of pixels in the first object to be matched can be HARD_N in the above-mentioned first splicing scene corresponding to the target area or NORMAL_N in the above-mentioned second splicing scene.
[0107] Specifically, the process of determining the mean square error between the first to-be-matched object and the second to-be-matched object may refer to formula (5):
[0108] Formula (5);
[0109] in, It can be expressed as mean square error.
[0110] A mean square error between the first to-be-matched object and the second to-be-matched object is determined. It can represent valid pixels in the first object to be matched. Valid pixels can be pixels that meet the preset scene threshold corresponding to the current splicing scene. For each valid pixel, the mean square error is calculated using the pixels in the second object to be matched at the same position corresponding to the valid pixel and the valid pixel, which can increase the fine-grained embodiment of the similarity between the first object to be matched and the second object to be matched.
[0111] In some embodiments, the stitching scene includes a first stitching scene and a second stitching scene, and the stitching difficulty of the first stitching scene is greater than the stitching difficulty of the second stitching scene. The image stitching method may further include the following steps: First, multiply the third weight by the second similarity to obtain a first product. Then, multiply the third weight by the second similarity to obtain a first product. In response to the current stitching scene being the first stitching scene, the first product is used as a candidate similarity. Or, in response to the current stitching scene being the second stitching scene, the first product is multiplied by the pixel ratio to obtain a second product, and the second product is used as a candidate similarity. The pixel ratio represents the ratio between the number of pixels in the first candidate pixel set and the number of pixels in the second candidate pixel set. The first candidate pixel set is a pixel set in the reference image for the first stitching scene, and the second candidate pixel set is a pixel set in the reference image for the second stitching scene.
[0112] The difficulty of stitching the first stitching scene is greater than the difficulty of stitching the second stitching scene. The first stitching scene may be the above-mentioned difficult scene. The second stitching scene may be the above-mentioned conventional scene. The image to be stitched includes a foreground area and a background area. Among them, the foreground area may include pixels with large pixel value differences. The background area may include pixels with small pixel value differences. Specifically, the difficult scene has more pixels with small differences from the background and large background interference. The background in the difficult scene and the conventional scene may refer to the background area, or may refer to the area composed of pixels with a pixel value of 255 in the grayscale image. The conventional scene has more pixels with large differences from the background and small background interference. Therefore, for the image to be stitched, if there are more pixels with small background differences and large background interference in the image, it is impossible to accurately determine the area that the target object in the image to be stitched needs to be stitched. For the image to be stitched, the stitching difficulty of the first stitching scene is greater than the stitching difficulty of the second stitching scene.
[0113] Specifically, the calculation process of candidate similarity can refer to formula (6):
[0114] Formula (6);
[0115] in, It may represent the candidate similarity corresponding to the first product when the current stitching scene of the target area is the first stitching scene, or the candidate similarity corresponding to the second product when the current stitching scene of the target area is the second stitching scene. It can be the mean square error mentioned above. It can be the pixel ratio in the above formula (1) Q2 may be a second weight. The value of the second weight may be 100. Q3 may be a third weight. The value of the third weight may be. Q4 may be the above ratio weight. The value of the ratio weight may be .in addition, The second similarity may be indicated when the current stitching scene of the target area is the second stitching scene. It can represent the second similarity when the current stitching scene of the target area is the first stitching scene. or It can represent the target ratio. It can be considered that when the current splicing scene of the target area is the first splicing scene or the second splicing scene, the calculation method of the candidate similarity is different. Differential processing of similarity calculation of different scenes can be achieved, thereby improving the accuracy of similarity calculation.
[0116] It can be considered that in the process of calculating the candidate similarity, the similarity is calculated based on the combined features obtained by the differential processing in the first to-be-matched object and the second to-be-matched object of the present application, which can improve the accuracy of the calculated similarity, so that the successful matching result in the determined target matching result is more accurate. Therefore, the more accurate the target matching result is, the more accurate the spliced image obtained after splicing.
[0117] In addition, the present application uses the division of the first candidate area and the second candidate area to perform similarity calculation, rather than performing similarity calculation on each pixel in the two images to be stitched one by one. The present application can improve the efficiency of determining the candidate similarity and the maximum similarity in the target matching results.
[0118] In addition, the present application uses scattered point filtering in multiple preset directions to suppress the scattered point noise that is very close to the background in the image to be stitched, which can not only effectively reduce the noise in the image to be stitched, but also retain important structural information and improve the overall stitching accuracy. Among them, the important structural information retained is the above-mentioned retained pixel points.
[0119] It is understandable that the present application can achieve flexible application and high efficiency in different preset stitching scenarios. By performing differentiated processing on the candidate pixel point sets of different preset stitching scenes, not only the stitching effect can be improved, but also the versatility and adaptability of the image stitching method of the present application are ensured. At the same time, at least part of the first candidate areas are selected as the target area from each first candidate area, and the target area is used to calculate the similarity with each second candidate area of low complexity to ensure the rapidity and high precision of the method, providing a practical and efficient solution for image stitching technology.
[0120] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0121] See also Figure 4 , Figure 4 FIG. 2 is another flow chart of an embodiment of the image stitching method of the present application. Figure 4 As shown, the process of the image stitching method may include the following steps:
[0122] The image stitching method sequentially performs step S401, step S402, step S403 and step S404. Step S401: Acquire each image to be stitched. Wherein, each image to be stitched includes a first image and a second image. Step S402: Perform grayscale processing on the first image and the second image respectively to obtain a first grayscale image and a second grayscale image. Step S403: Perform filtering processing on the first grayscale image based on a preset first background threshold to obtain a first candidate image, and obtain a second candidate image based on a preset second background threshold and the second grayscale image. Step S404: Determine the current stitching scene according to the pixel value distribution of each pixel in the first candidate image and / or the second candidate image. Specifically, determine the current stitching scene of each first candidate area in the first image according to the pixel value distribution of each pixel in the first candidate image. If the first candidate areas are different, the current stitching scene of the first candidate areas may be different. After step S404, perform steps S405, step S405 and step S407. Step S405: Determine the corresponding candidate pixel set from each first candidate area according to the pixel selection method corresponding to the current stitching scene of each first candidate area. Step S406: Select at least part of the first candidate area from each first candidate area as the target area, and calculate the similarity between the candidate pixel set of the target area and each second candidate area in other images. Step S407: Use the target area and the second candidate area corresponding to the highest similarity as the successfully matched area. In some application scenarios, selecting at least part of the first candidate area from each first candidate area as the target area can be performed serially. After determining the first target area and all candidate similarities corresponding to the target area, the highest similarity corresponding to the first target area is retained, and the second target area is selected. Repeat the determination of all candidate similarity calculations corresponding to the second target area and the retention of the highest similarity corresponding to the second target area until the steps of determining all candidate similarity calculations corresponding to the last target area and retaining the highest similarity corresponding to the last target area are completed, and step S407 is executed. Figure 3 As shown, the first target area can be area a, and the similarity calculated according to the above formula (4) is The highest similarity corresponding to the first target region may correspond to region e in the second candidate region. The last target region may be region b. The similarity calculated according to the above formula (4) is The highest similarity corresponding to the last target region can correspond to region d in the second candidate region. Region c of the target region is traversed to calculate the similarities between each candidate region c and each second candidate region. The highest similarity is . In some other application scenarios, selecting at least part of the first candidate areas as the target areas from the first candidate areas can be performed in parallel, and all the target areas are selected at one time, and after the candidate similarities between all the target areas and the second candidate areas are synchronously calculated, step S407 is executed. After executing step S407, step S408 is executed. Step S408: splicing the first image and the second image based on the successfully matched area. It can be understood that the execution process of steps S401 to S408 can refer to the above content and will not be repeated here.
[0123] See also Figure 5 , Figure 5 It is a schematic diagram of a stitched image according to an embodiment of the image stitching method of the present application.
[0124] like Figure 5 As shown, after executing step S407, the highest similarity is determined to be . And determine that the target matching result includes a successfully matched area. The successfully matched area includes area b and area d. Area b and / or area d are used as the splicing object in the target matching result. The process of executing step S408 can refer to the above content, and the spliced image can be obtained as follows Figure 5 The dotted line frame in the overlapping area is at least part of the above-mentioned splicing object, and the dotted line frame may be area b or area d. The dotted line frame may also be at least part of area b and at least part of area d.
[0125] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0126] See also Figure 6 , Figure 6It is a structural schematic diagram of an embodiment of the image stitching device of the present application. The image stitching device 60 includes an acquisition module 61, a first determination module 62, a second determination module 63 and a stitching module 64; the acquisition module 61 is used to acquire each image to be stitched, and each image to be stitched includes a first image and a second image; the first determination module 62 is used to determine the current stitching scene according to the pixel value distribution of each pixel point in the first image and / or the second image; the second determination module 63 is used to determine the target pixel point set from the first image and / or the second image according to the pixel point selection method of the current stitching scene, and the pixel point selection method of different stitching scenes is different; the stitching module 64 is used to stitch the first image and the second image based on the target matching result of the first image and the second image, and the target matching result includes the matching result between the target pixel point set of the two images to be stitched or the matching result between the target pixel point set of one of the images to be stitched and each pixel point in the other image to be stitched.
[0127] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0128] Please refer to the image stitching method for the functions performed by each module, which will not be repeated here.
[0129] See also Figure 7 , Figure 7 : is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 70 includes a memory 71 and a processor 72, and the processor 72 is used to execute program instructions stored in the memory 71 to implement the steps in the above-mentioned image stitching method embodiment. In a specific implementation scenario, the electronic device 70 may include but is not limited to: a multi-camera device, a microcomputer, and a server. In addition, the electronic device 70 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0130] Specifically, the processor 72 is used to control itself and the memory 71 to implement the steps in the above-mentioned image stitching method embodiment. The processor 72 can also be called a CPU (Central Processing Unit). The processor 72 may be an integrated circuit chip with signal processing capabilities. The processor 72 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 72 can be implemented by an integrated circuit chip.
[0131] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0132] See also Figure 8 , Figure 8 The computer-readable storage medium 80 stores program instructions 801 thereon, and when the program instructions 801 are executed by a processor, the steps in any of the above-mentioned image stitching method embodiments are implemented.
[0133] The above scheme obtains the images to be stitched, determines different current stitching scenes according to the different pixel value distributions of each pixel in the first image and / or the second image, determines the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene, and the pixel selection methods of different stitching scenes are different. Based on the different current stitching scenes, a more accurate target matching result is determined, and the first image and the second image are stitched based on the target matching result of the first image and the second image. Compared with the prior art in which image stitching is directly based on the similarity between the overlapping areas in the images to be stitched, which is greatly interfered by multiple influencing factors, the present application can improve the accuracy of image stitching.
[0134] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0135] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0136] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0137] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0138] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. An image stitching method, characterized in that: include: Acquire each image to be stitched, each of the images to be stitched includes a first image and a second image; Determining a current stitching scene according to a distribution of pixel values of each pixel in the first image and / or the second image; Determine a target pixel point set from the first image and / or the second image according to a pixel point selection method of the current stitching scene, wherein different pixel point selection methods are different for different stitching scenes, and the pixel point selection method is used to indicate a selection condition for each pixel point in the image to be stitched, and the current stitching scene is one of several preset stitching scenes, and the selection condition corresponding to the preset stitching scene is used to indicate a selection range of pixels in the image to be stitched, and the selection range of pixels is a preset range of pixel values; splicing the first image and the second image based on target matching results of the first image and the second image, wherein the target matching results include matching results between target pixel point sets of the two images to be spliced or matching results between the target pixel point set of one of the images to be spliced and each pixel point in the other image to be spliced; The plurality of preset stitching scenes include a first stitching scene and a second stitching scene, the selection range of pixels in the first stitching scene includes the selection range of pixels in the second stitching scene, and the determining the current stitching scene according to the distribution of pixel values of each pixel in the first image and / or the second image includes: Taking the first image or the second image as a reference image, determining a first set of candidate pixels for a first stitching scene in the reference image and a second set of candidate pixels for a second stitching scene in the reference image according to pixel value distribution of each pixel in the reference image, wherein a current stitching scene of the reference image is one of the first stitching scene and the second stitching scene; Calculating a pixel ratio between the number of pixels in the first candidate pixel set and the number of pixels in the second candidate pixel set, the pixel ratio being used to indicate a proportion of the number of pixels between the first candidate pixel set and the second candidate pixel set; Based on the relationship between the pixel ratio and the expected scene ratio, the current stitching scene of the reference image is determined, and the expected scene ratio represents the expected ratio between the number of pixels in the reference image with respect to the first stitching scene and the number of pixels in the reference image with respect to the second stitching scene.
2. The method according to claim 1, characterized in that The determining, according to the pixel value distribution of each pixel in the reference image, a first set of candidate pixels for the first stitching scene in the reference image and a second set of candidate pixels for the second stitching scene in the reference image comprises: Obtaining a first scene threshold corresponding to the first stitching scene and a second scene threshold corresponding to the second stitching scene, wherein the first scene threshold represents a maximum pixel value of pixels that can be selected in the reference image under the first stitching scene, and the second scene threshold represents a maximum pixel value of pixels that can be selected in the reference image under the second stitching scene; Pixels whose pixel values are lower than the first scene threshold are selected from the reference image to obtain the first candidate pixel set, and pixels whose pixel values are lower than the second scene threshold are selected from the reference image to obtain the second candidate pixel set.
3. The method according to claim 1, characterized in that The determining the current stitching scene according to the pixel value distribution of each pixel point in the first image and / or the second image includes: Performing grayscale processing on the first image and the second image respectively to obtain a first grayscale image and a second grayscale image; filtering the first grayscale image based on a preset first background threshold to obtain a first candidate image, and obtaining a second candidate image based on a preset second background threshold and the second grayscale image; A current stitching scene is determined according to a distribution of pixel values of each pixel in the first candidate image and / or the second candidate image.
4. The method according to claim 3, characterized in that The filtering process of the first grayscale image based on a preset first background threshold to obtain a first candidate image, and the filtering process of the first grayscale image based on a preset second background threshold and the second grayscale image to obtain a second candidate image include: The first grayscale image is used as the image to be filtered, the first background threshold is used as the filtering judgment threshold, and the first candidate image is used as the target candidate image; or the second grayscale image is used as the image to be filtered, the second background threshold is used as the filtering judgment threshold, and the second candidate image is used as the target candidate image; Determine the pixel points of the to-be-filtered image whose pixel values are greater than or equal to the filtering judgment threshold as the to-be-filtered points; In response to the number of pixel points on one side of the to-be-filtered point in the preset direction in the to-be-filtered image being greater than or equal to a preset number, taking the pixel points corresponding to one side of the to-be-filtered point as reserved pixel points; Or, in response to the number of pixel points on one side of the to-be-filtered point in a preset direction in the to-be-filtered image being less than a preset number, taking the pixel points corresponding to one side of the to-be-filtered point as the to-be-filtered point; The pixel value of each of the points to be filtered is set to a preset pixel value to obtain the target candidate image.
5. The method according to claim 1, characterized in that The determining the current stitching scene according to the pixel value distribution of each pixel point in the first image and / or the second image includes: Taking the first image or the second image as a reference image, dividing the reference image into regions to obtain a plurality of first candidate regions; Determine the current stitching scene of each of the first candidate areas according to the pixel value distribution of each pixel point in each of the first candidate areas; The target pixel set includes candidate pixel sets of each of the first candidate areas, and determining the target pixel set from the first image and / or the second image according to the pixel selection method of the current stitching scene includes: A corresponding candidate pixel set is determined from each of the first candidate regions according to a pixel selection method corresponding to the current stitching scene of each of the first candidate regions.
6. The method according to claim 5, characterized in that The method further comprises: using another image of the first image and the second image other than the reference image as another image; Performing region division on the other image to obtain a plurality of second candidate regions; At least part of the first candidate areas are selected from each of the first candidate areas as the target area, and similarities are calculated for the candidate pixel point sets of the target area and each of the second candidate areas in the other images, and the target matching result includes the similarities between each target area and each second candidate area.
7. The method according to claim 6, characterized in that The selecting at least part of the first candidate regions from the first candidate regions as the target region, and respectively calculating similarities between the candidate pixel point sets of the target region and the second candidate regions in the other images, comprises: The candidate pixel set of the target area is used as the first object to be matched, the second candidate area is used as the second object to be matched, and the similarity between the candidate pixel set of the target area and the second candidate area is used as the candidate similarity; Calculating the pixel value similarity between the first to-be-matched object and the second to-be-matched object; Calculating the hash similarity between the first to-be-matched object and the second to-be-matched object; Determine a first similarity based on the pixel value similarity, the hash similarity and a first weight; The candidate similarity is determined according to the first similarity and the number of pixels in the first object to be matched.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: include: A program file is stored, and when the program file is executed by a processor, it is used to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image acquisition method and device, equipment and storage medium
CN117611483A
