Image processing method and device, electronic device and readable storage medium
Through image processing methods, including preprocessing, filling, expansion and color space transformation, the saturation of the purple edge area is dynamically adjusted to solve the purple edge problem caused by camera lens error, improve user experience and removal efficiency, and avoid high-cost solution.
Patent Information
- Application Number
- CN202210311321.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-28
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-03-28
AI Technical Summary
There are common errors in camera lenses and sensors, which lead to the phenomenon of 'purple fringing' appearing on the edges of objects in photos of high-contrast, large-backlit objects, which affects the user's online home viewing experience. Existing technology removal methods are costly or inefficient.
Through image processing methods, including image acquisition, image preprocessing, obtaining highlight areas, filling and expansion processing, obtaining purple edge areas, color space transformation and adjusting the saturation of target pixels, dynamically adjust the saturation of the purple edge area to remove purple edges, retaining the original color.
It achieves automatic removal of purple fringe areas, improves user viewing experience, reduces costs, avoids changes to the original color, and improves the accuracy and efficiency of purple fringe removal.
Smart Images

Figure CN114782261B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and specifically relates to an image processing method and device, an electronic device, and a readable storage medium. Background Art
[0002] In related technologies, errors are common in camera lenses and sensors, resulting in more or less "purple fringing" at the edges of objects in photos of high-contrast, backlit objects. In the real estate sector, most image acquisition is done during times when natural lighting conditions are good, making the appearance of "purple fringing" more likely, affecting users' online house-viewing experience.
[0003] In the related art, there are generally two ways to remove purple fringing. The first way is to manually adjust the image on professional drawing software in the later stage. In the real estate field, due to the huge demand for online house viewing, if manual post-production photo editing is used, the labor cost will increase. The second way is to use a lens with a BR lens added, where a BR lens refers to a composite lens that uses a BR optical element (blue spectrum refractive optical element). However, BR lenses are very expensive. In the real estate field, large-scale configuration of shooting equipment is required. If BR lenses are used, a lot of costs will be added. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an image processing method and device, an electronic device and a readable storage medium, which can solve the problem that common errors in camera lenses and sensors result in the appearance of "purple fringing" at the edges of objects in photos of high-contrast and large backlit objects, thereby affecting the user's online house viewing experience.
[0005] In a first aspect, an embodiment of the present application provides an image processing method, including: acquiring a first image; performing image preprocessing on the first image to obtain a binary image; acquiring a highlight area of the binary image; filling and dilating the highlight area to obtain a second image; acquiring a purple-fringe appearance area based on the first image and the second image; processing the first image based on the purple-fringe appearance area to obtain a third image; performing color space transformation on the third image to obtain a fourth image; acquiring a purple-fringe area based on the fourth image and a purple hue threshold; acquiring a first saturation of a target pixel in the purple-fringe area, and setting the saturation of the target pixel to a second saturation based on the first saturation to obtain a fifth image.
[0006] In the second aspect, an embodiment of the present application provides an image processing device, including a first acquisition module, a first processing module, a second acquisition module, a second processing module, a third acquisition module, a third processing module, a transformation module, a fourth acquisition module and a fifth acquisition module; the first acquisition module is used to acquire a first image; the first processing module is used to perform image preprocessing on the first image to obtain a binary image; the second acquisition module is used to acquire a highlight area of the binary image; the second processing module is used to fill and dilate the highlight area to obtain a second image; the third acquisition module is used to acquire a purple-edge appearing area based on the first image and the second image; the third processing module processes the first image based on the purple-edge appearing area to obtain a third image; the transformation module is used to perform color space transformation on the third image to obtain a fourth image; the fourth acquisition module is used to acquire a purple-edge area based on the fourth image and a purple hue threshold; the fifth acquisition module is used to acquire a first saturation of a target pixel in the purple-edge area, and based on the first saturation, sets the saturation of the target pixel to a second saturation to obtain a fifth image.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the image processing method of the first aspect are implemented.
[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the image processing method of the first aspect are implemented.
[0009] The present application can remove the purple-edge area appearing in the first image by processing the first image, and retain the original color of the purple object without introducing other colors, thereby improving the user viewing experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 One of the flowcharts of the image processing method provided in the embodiment of the present application is shown;
[0011] Figure 2 The second flowchart of the image processing method provided in the embodiment of the present application is shown;
[0012] Figure 3 The third flowchart of the image processing method provided in the embodiment of the present application is shown;
[0013] Figure 4 A fourth flowchart of the image processing method provided in an embodiment of the present application is shown;
[0014] Figure 5FIG5 shows a fifth flow chart of the image processing method provided in an embodiment of the present application;
[0015] Figure 6 A structural block diagram of an image processing device provided in an embodiment of the present application is shown;
[0016] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present application is shown;
[0017] Figure 8 A schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application is shown.
[0018] In the figure, Figures 6 to 8 The corresponding relationship between the reference numerals and the component names is as follows:
[0019] 100: image processing device; 110: first acquisition module; 120: first processing module; 130: second acquisition module; 140: second processing module; 150: third acquisition module; 160: third processing module; 170: transformation module; 180: fourth acquisition module; 190: fifth acquisition module; 1000: electronic device; 1002: processor; 1004: memory; 1100: electronic device; 1101: radio frequency unit; 1102: network module; 1103: audio output unit; 1104: input unit; 11041: graphics processor; 11042: microphone; 1105: sensor; 1106: display unit; 11061: display panel; 1107: user input unit; 11071: touch panel; 11072: other input devices; 1108: interface unit; 1109: memory; 1110: processor. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0021] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0022] The following is combined with Figures 1 to 7 , the image processing method and device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0023] An image processing method is provided in an embodiment of the present application. Figure 1 FIG. 1 shows one of the flow charts of the image processing method provided in the embodiment of the present application, such as Figure 1 As shown, the image processing method includes:
[0024] Step 102: Acquire a first image.
[0025] Step 104: perform image preprocessing on the first image to obtain a binary image.
[0026] Step 106, obtaining the highlight area of the binary image.
[0027] Step 108, filling and dilating the highlight area to obtain a second image.
[0028] Step 110: Acquire a purple fringing appearance area based on the first image and the second image.
[0029] Step 112: Process the first image based on the purple fringing area to obtain a third image.
[0030] Step 114, performing color space transformation on the third image to obtain a fourth image.
[0031] Step 116: Obtain a purple-fringe area based on the fourth image and the purple hue threshold.
[0032] Step 118, obtaining a first saturation of the target pixel in the purple-fringe area, and setting the saturation of the target pixel to a second saturation based on the first saturation, to obtain a fifth image.
[0033] It is understandable that the first image may be an image that needs to be processed. Optionally, the first image may be a real-scene captured image of a house in the real estate field.
[0034] It is understandable that in the VR house viewing scenario in the real estate field, most of the images captured by the camera are taken when the sunlight conditions are good, and most of the pictures taken will have purple fringing. In addition, the furniture and decoration inside the house often involve purple. While maintaining the original purple objects in the image, removing the purple fringes becomes a technical problem that must be solved.
[0035] The algorithms for automatic purple fringing removal in related technologies have the following problems: First, most of them directly correct the raw (unprocessed image) data at the ISP layer (Image Signal Processing). In the real estate field, the input is generally jpg (Joint Photographic Experts Group, JPEG format) or yuv (color encoding method) after the camera ISP has processed it. The input loses a lot of pixel information, making it difficult to automatically remove purple fringing and the effect is poor. Second, by introducing other color information or black, white and gray to replace the purple fringing area, it will cause the original color of the purple object to be changed in some scenes, affecting the perception.
[0036] It is understandable that in actual applications, a large number of real estate-related pictures can be taken by cameras and other equipment, and a large number of real estate-related pictures can be tested to obtain a purple hue threshold with better effect. By setting the above purple hue threshold, a more accurate purple-edge area can be obtained.
[0037] In this embodiment, the purple hue threshold can be obtained by comparing a large number of existing tests on removing purple fringing from images.
[0038] The image processing method of this embodiment can be deployed on the server side. The real-life image of the house captured by the staff through the camera can be regarded as the first image. The first image is transmitted to the server side. The image processing method set on the server side processes the first image to obtain a fifth image. The fifth image is the image with the purple-edge area removed. The fifth image can be used to generate a panoramic view of the house and other operations.
[0039] In this embodiment, the first saturation of the target pixel in the purple-fringe area is calculated, the second saturation is calculated according to the first saturation, and then the saturation of the target pixel in the purple-fringe area is set to the second saturation. In this embodiment, the saturation of the purple-fringe area is dynamically adjusted so that the color transition between the purple-fringe area and the surrounding area appears smoother, thereby improving the accuracy of removing purple fringing.
[0040] In this embodiment, by processing the first image, the purple edge area in the first image can be removed, and the purple edge effect of the panoramic image can be automatically removed. In addition, no other colors are introduced, and the original color of the purple object is retained, thereby improving the user viewing experience.
[0041] In some embodiments of the present application, Figure 2 FIG. 2 shows a second flow chart of the image processing method provided in an embodiment of the present application. Figure 2 As shown, the first image is subjected to image preprocessing to obtain a binary image, which specifically includes:
[0042] Step 202: convert the first image into a grayscale image.
[0043] Step 204, segmenting the grayscale image into binary images.
[0044] It can be understood that the first image captured by the camera is a color image, and the color image can be an HSV color space image. The first image is converted into a grayscale image, and then the grayscale image is segmented to obtain a binary image.
[0045] In this embodiment, a binarized image is obtained by processing the first image, and then a purple-edge region can be obtained through the binarized image. Finally, the purple-edge region is removed to improve the user viewing experience.
[0046] In some embodiments of the present application, segmenting the grayscale image into a binary image specifically includes:
[0047] The grayscale image is segmented into a binary image using the first threshold.
[0048] It is understandable that VR house viewing in the real estate field will take a large number of pictures through cameras and other equipment. By testing a large number of pictures, the first threshold is obtained, so that the purple edge obtained through the binarized image is more accurate.
[0049] In this embodiment, the first threshold value can be obtained by comparing a large number of existing tests on image purple fringing removal.
[0050] In this embodiment, a first threshold is obtained through testing, and then the grayscale image is segmented using the first threshold to obtain a binary image. The binary image is subsequently processed to obtain the purple-fringed edge, so that the range of the purple-fringed edge can be made more accurate.
[0051] In some embodiments of the present application, Figure 3 The third flow chart of the image processing method provided in the embodiment of the present application is shown as follows: Figure 3 As shown, the highlighted area is filled and expanded to obtain a second image, which specifically includes:
[0052] Step 302: Obtain discrete highlight areas in the binary image, and fill the discrete highlight areas to obtain a fifth image.
[0053] Step 304: Acquire the concentrated highlight area in the fifth image, and expand the concentrated highlight area to obtain a sixth image.
[0054] Step 306: merge the fifth image and the sixth image to obtain a second image.
[0055] In this embodiment, the discrete highlight areas in the binary image are filled, so that the purple fringing area can be extracted with higher accuracy. In addition, the purple fringing is removed only at the obvious bright and dark boundaries, which will not affect the original color of the purple object and improve the user viewing experience.
[0056] In this embodiment, discrete highlight areas will be ignored to avoid the appearance of abrupt pixel blocks similar to mosaics in the image, and the original purple objects will also retain their original colors to improve the user viewing experience.
[0057] In this embodiment, the saturation of the purple-fringe area is dynamically adjusted, and the color transition with the surrounding area is smoother, and the viewing experience is better.
[0058] In some embodiments of the present application, obtaining the purple fringing occurrence area based on the first image and the second image specifically includes:
[0059] The first image is combined with the second image to obtain the area where the purple edge appears.
[0060] In this embodiment, the purple-fringe region may be obtained by merging the first image and the second image. This approach can reduce the difficulty of ultimately obtaining the purple-fringe region and improve accuracy.
[0061] In some embodiments of the present application, based on the purple fringing area, the first image is processed to obtain the third image, specifically including:
[0062] The purple-fringe region is merged with the first image to obtain a third image.
[0063] In this embodiment, the third image is obtained by merging the purple fringing area and the first image, that is, the original input image. The third image is then further processed to remove the purple fringing and improve the user viewing experience.
[0064] In some embodiments of the present application, performing color space transformation on the third image to obtain the fourth image specifically includes:
[0065] The third image is converted into the HSV color space to obtain a fourth image.
[0066] In this embodiment, the third image is converted into the HSV color space to obtain a fourth image, which is an image without purple fringing. When a user views a property (for example, when viewing a property in VR or browsing property pictures), an image without purple fringing is presented, which can improve the user's viewing experience.
[0067] In some embodiments of the present application, Figure 4 FIG. 4 shows a flow chart of the image processing method provided in an embodiment of the present application. Figure 4 As shown, obtaining a first saturation of a target pixel in a purple-fringe area, and setting the saturation of the target pixel to a second saturation based on the first saturation, to obtain a fifth image, specifically includes:
[0068] Step 402, obtaining a first saturation of a target pixel;
[0069] Step 404, obtaining a second saturation based on the proportion of the first saturation;
[0070] Step 406, setting the saturation of the target pixel to a second saturation.
[0071] In this embodiment, the first saturation of the target pixel is first obtained, then the proportion of the first saturation is obtained, and then the second saturation is obtained, and the saturation of the target pixel is adjusted to the second saturation. In this embodiment, the saturation is appropriately reduced according to the proportion of the first saturation. In this embodiment, the saturation of the target pixel is dynamically adjusted, and the saturation of the high saturation is reduced more, and the saturation of the low saturation is reduced less, so that the color transition between the purple edge area and the surrounding area is smoother.
[0072] In this embodiment, the proportion of the first saturation may refer to the ratio of the first saturation to 255.0, and the calculation formula of the second saturation may be:
[0073] new_saturation=old_saturation×(1-old_saturation / 255.0)
[0074] Among them, new_saturation represents the second saturation of the target pixel, old_saturation represents the first saturation of the target pixel, first obtain the ratio of the first saturation to 255.0, then obtain the difference between 1 and the ratio, and finally obtain the product of the first saturation and the difference, and the above product is the second saturation.
[0075] In this embodiment, in view of the fact that there are differences in the purple-fringed areas of each image, the first saturation of the target pixel in the purple-fringed area is calculated, and then dynamic adjustment is performed based on the obtained first saturation, and the saturation of the purple-fringed area is set to the second saturation. At this time, the saturation of the high saturation is reduced more, and the saturation of the low saturation is reduced less, thereby improving the accuracy of removing purple fringing.
[0076] In some embodiments of the present application, Figure 5 FIG. 5 shows a flow chart of an image processing method provided in an embodiment of the present application. Figure 5 As shown, the image processing method comprises:
[0077] Step 502, input image;
[0078] Wherein, the image may be a panoramic image;
[0079] Step 504, converting the image into a grayscale image;
[0080] Step 506, setting a fixed threshold, and segmenting the grayscale image into a binary image using the fixed threshold.
[0081] The fixed threshold is obtained through comparison of a large number of existing case tests.
[0082] Step 508, filling the fragmented white holes (ie, discrete highlight areas) in the binary image to obtain image img1.
[0083] Step 510: Expand the concentrated highlight area in the image img1 with the holes filled outward by one circle to obtain the image img2.
[0084] Step 512, merging the image img1 and the image img2 to obtain the area where the purple edge appears;
[0085] Step 514: merge the above region and the original input image, and convert them into HSV color space.
[0086] Step 516, determine the threshold of the purple hue, find the purple area in the image, and appropriately reduce the saturation according to the proportion of its saturation.
[0087] The threshold of the purple hue is obtained by comparing and testing a large number of existing cases.
[0088] Finally the purple fringing effect is weakened and removed.
[0089] In this embodiment, the image is binarized and discrete highlight holes are filled by using a threshold value obtained through a large number of tests, so that the accuracy of extracting the purple fringing area is higher.
[0090] In this embodiment, no other color is used to replace the purple fringing. Instead, the saturation of the purple-fringed area is dynamically adjusted by calculating the proportion of the target pixel saturation. The higher the saturation, the more it is reduced, and the lower the saturation, the less it is reduced. The color transition with the surrounding area will appear smoother, thereby improving the accuracy of removing the purple fringing and providing a better image viewing experience.
[0091] In this embodiment, discrete highlight areas are ignored to avoid mosaic-like abrupt pixel blocks in the image, and the original purple objects are also retained in their original colors. In addition, the purple edges are only removed at the obvious bright and dark boundaries, which will not affect the original color of the purple objects.
[0092] The image processing method provided in the embodiment of the present application can be executed by an image processing device. In the embodiment of the present application, an image processing device executing the image processing method is taken as an example to illustrate the image processing device provided in the embodiment of the present application.
[0093] In some embodiments of the present application, an image processing device is provided. Figure 6 The structure block diagram of the image processing device provided by the embodiment of the present application is shown as follows: Figure 6 As shown, the image processing device 100 includes a first acquisition module 110, a first processing module 120, a second acquisition module 130, a second processing module 140, a third acquisition module 150, a third processing module 160, a transformation module 170, a fourth acquisition module 180 and a fifth acquisition module 190. The first acquisition module 110 is used to acquire a first image. The first processing module 120 is used to perform image preprocessing on the first image to obtain a binary image. The second acquisition module 130 is used to acquire a highlight area of the binary image. The second processing module 140 is used to fill and dilate the highlight area to obtain a second image. The third acquisition module 150 is used to acquire a purple edge appearance area based on the first image and the second image. The third processing module 160 is used to process the first image based on the purple edge appearance area to obtain a third image. The transformation module 170 is used to perform color space transformation on the third image to obtain a fourth image. The fourth acquisition module 180 is used to acquire a purple edge area based on the fourth image and a purple hue threshold. The fifth acquisition module 190 is used to acquire a first saturation of a target pixel in the purple-fringe area, and based on the first saturation, set the saturation of the target pixel to a second saturation to obtain a fifth image.
[0094] In this embodiment, by processing the first image, the purple edge area in the first image can be removed, and the purple edge effect of the panoramic image can be automatically removed. In addition, no other colors are introduced, and the original color of the purple object is retained, thereby improving the user viewing experience.
[0095] In some embodiments of the present application, the first processing module 120 specifically includes a grayscale image conversion module and a binary image conversion module. The grayscale image conversion module is used to convert the first image into a grayscale image. The binary image conversion module is used to segment the grayscale image into a binary image.
[0096] In this embodiment, a binarized image is obtained by processing the first image, and then a purple-edge region can be obtained through the binarized image. Finally, the purple-edge region is removed to improve the user viewing experience.
[0097] In some embodiments of the present application, the binary image conversion module includes a segmentation module, and the segmentation module is used to segment the grayscale image into a binary image through a first threshold.
[0098] In this embodiment, a first threshold is obtained through testing, and then the grayscale image is segmented using the first threshold to obtain a binary image. The binary image is subsequently processed to obtain the purple-fringed edge, so that the range of the purple-fringed edge can be made more accurate.
[0099] In some embodiments of the present application, the second processing module 140 includes a filling module, an expansion module and a first merging module. The filling module is used to obtain discrete highlight areas in the binary image and fill the discrete highlight areas to obtain a fifth image. The expansion module is used to obtain concentrated highlight areas in the fifth image and expand the concentrated highlight areas to obtain a sixth image. The first merging module is used to merge the fifth image and the sixth image to obtain a second image.
[0100] In this embodiment, the discrete highlight areas in the binary image are filled, so that the purple fringing area can be extracted with higher accuracy. In addition, the purple fringing is removed only at the obvious bright and dark boundaries, which will not affect the original color of the purple object and improve the user viewing experience.
[0101] In some embodiments of the present application, the third acquisition module 150 includes a second merging module. The second merging module is used to merge the first image and the second image to obtain the purple fringing appearance area.
[0102] In this embodiment, the purple-fringe region may be obtained by merging the first image and the second image. This method can improve the accuracy of obtaining the purple-fringe region.
[0103] In some embodiments of the present application, the third processing module 160 includes a third merging module. The third merging module is used to merge the purple-fringe region with the first image to obtain a third image.
[0104] In this embodiment, the third image is obtained by merging the purple fringing area and the first image, that is, the original input image. The third image is then further processed to remove the purple fringing and improve the user viewing experience.
[0105] In some embodiments of the present application, the transformation module 170 includes a conversion module. The conversion module is used to convert the third image into the HSV color space to obtain the fourth image.
[0106] In this embodiment, the third image is converted into the HSV color space to obtain a fourth image, which is an image without purple fringing. When a user views a property (for example, when viewing a property in VR or browsing property pictures), an image without purple fringing is presented, which can improve the user's viewing experience.
[0107] In some embodiments of the present application, the fifth acquisition module includes a first saturation acquisition module, a second saturation acquisition module and a setting module. The first saturation acquisition module is used to acquire a first saturation of the target pixel. The second saturation acquisition module is used to acquire a second saturation based on a proportion of the first saturation. The setting module is used to set the saturation of the target pixel to the second saturation.
[0108] In this embodiment, in view of the fact that there are differences in the purple-fringed areas of each image, the first saturation of the target pixel in the purple-fringed area is calculated, and then dynamic adjustment is performed based on the obtained first saturation, and the saturation of the purple-fringed area is set to the second saturation. At this time, the saturation of the high saturation is reduced more, and the saturation of the low saturation is reduced less, thereby improving the accuracy of removing purple fringing.
[0109] The image processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0110] The image processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0111] The image processing device provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.
[0112] Alternatively, if Figure 7 As shown, an embodiment of the present application further provides an electronic device 1000, which includes a processor 1002 and a memory 1004. The memory 1004 stores programs or instructions that can be executed on the processor 1002. When the program or instructions are executed by the processor 1002, the various steps of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0113] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0114] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0115] The electronic device 1100 includes but is not limited to: a radio frequency unit 1101, a network module 1102, an audio output unit 1103, an input unit 1104, a sensor 1105, a display unit 1106, a user input unit 1107, an interface unit 1108, a memory 1109, and a processor 1110 and other components.
[0116] Those skilled in the art will appreciate that the electronic device 1100 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0117] The processor 1110 is used to acquire a first image.
[0118] The processor 1110 is used to perform image preprocessing on the first image to obtain a binary image.
[0119] The processor 1110 is used to obtain a highlight area of the binary image.
[0120] The processor 1110 is used to fill and expand the highlight area to obtain a second image.
[0121] The processor 1110 is configured to obtain a purple fringing occurrence area based on the first image and the second image.
[0122] The processor 1110 is configured to process the first image based on the purple fringing appearance area to obtain a third image.
[0123] The processor 1110 is configured to perform color space transformation on the third image to obtain a fourth image.
[0124] The processor 1110 is configured to obtain a purple-fringe area based on the fourth image and a purple hue threshold.
[0125] Processor 1110 is used to obtain a first saturation of a target pixel in the purple-fringe area, and based on the first saturation, set the saturation of the target pixel to a second saturation to obtain a fifth image.
[0126] In this embodiment, by processing the first image, the purple edge area in the first image can be removed, and the purple edge effect of the panoramic image can be automatically removed. In addition, no other colors are introduced, and the original color of the purple object is retained, thereby improving the user viewing experience.
[0127] Further, the processor 1110 is used to perform image preprocessing on the first image to obtain a binary image, specifically including:
[0128] The processor 1110 is configured to convert the first image into a grayscale image.
[0129] The processor 1110 is used to segment the grayscale image into a binary image.
[0130] In this embodiment, a binarized image is obtained by processing the first image, and then a purple-edge region can be obtained through the binarized image. Finally, the purple-edge region is removed to improve the user viewing experience.
[0131] Further, the processor 1110 is used to segment the grayscale image into a binary image, specifically including:
[0132] The processor 1110 is configured to segment the grayscale image into a binary image using a first threshold.
[0133] In this embodiment, a first threshold is obtained through testing, and then the grayscale image is segmented using the first threshold to obtain a binary image. The binary image is subsequently processed to obtain the purple-fringed edge, so that the range of the purple-fringed edge can be made more accurate.
[0134] Further, the processor 1110 is used to fill and dilate the highlight area to obtain a second image, specifically including:
[0135] The processor 1110 is configured to obtain discrete highlight regions in the binary image and fill the discrete highlight regions to obtain a fifth image.
[0136] The processor 1110 is configured to obtain a concentrated highlight area in the fifth image, and expand the concentrated highlight area to obtain a sixth image.
[0137] The processor 1110 is configured to combine the fifth image and the sixth image to obtain a second image.
[0138] In this embodiment, the discrete highlight areas in the binary image are filled, so that the purple fringing area can be extracted with higher accuracy. In addition, the purple fringing is removed only at the obvious bright and dark boundaries, which will not affect the original color of the purple object and improve the user viewing experience.
[0139] Further, the processor 1110 is configured to obtain a purple fringing occurrence area based on the first image and the second image, specifically including:
[0140] The processor 1110 is configured to merge the first image and the second image to obtain a purple-fringe appearing area.
[0141] In this embodiment, the purple-fringe region may be obtained by merging the first image and the second image. This method can improve the accuracy of obtaining the purple-fringe region.
[0142] Further, the processor 1110 is used to process the first image based on the purple fringing appearance area to obtain the third image, specifically including:
[0143] The processor 1110 is configured to merge the purple-fringe region with the first image to obtain a third image.
[0144] In this embodiment, the third image is obtained by merging the purple fringing area and the first image, that is, the original input image. The third image is then further processed to remove the purple fringing and improve the user viewing experience.
[0145] Further, the processor 1110 is configured to perform color space transformation on the third image to obtain a fourth image, specifically including:
[0146] The processor 1110 is configured to convert the third image into an HSV color space to obtain a fourth image.
[0147] In this embodiment, the third image is converted into the HSV color space to obtain a fourth image, which is an image with purple fringing removed. When a user views a property, an image with purple fringing removed is presented, which can improve the user's viewing experience.
[0148] In some embodiments of the present application, the processor 1110 is configured to obtain a first saturation of a target pixel in a purple-fringe region, and based on the first saturation, set the saturation of the target pixel to a second saturation to obtain a fifth image, specifically including:
[0149] Processor 1110, used for a first saturation acquisition module to acquire a first saturation of a target pixel.
[0150] Processor 1110 is used to obtain a second saturation based on a proportion of the first saturation.
[0151] Processor 1110 is used to set the saturation of the target pixel to a second saturation.
[0152] In this embodiment, in view of the fact that there are differences in the purple-fringed areas of each image, the first saturation of the target pixel in the purple-fringed area is calculated, and then dynamic adjustment is performed based on the obtained first saturation, and the saturation of the purple-fringed area is set to the second saturation. At this time, the saturation of the high saturation is reduced more, and the saturation of the low saturation is reduced less, thereby improving the accuracy of removing purple fringing.
[0153] It should be understood that in the embodiment of the present application, the input unit 1104 may include a graphics processor (Graphics Processing Unit, GPU) 11041 and a microphone 11042, and the graphics processor 11041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1106 may include a display panel 11061, and the display panel 11061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1107 includes a touch panel 11071 and at least one of other input devices 11072. The touch panel 11071 is also called a touch screen. The touch panel 11071 may include two parts: a touch detection device and a touch controller. Other input devices 11072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0154] The memory 1109 can be used to store software programs and various data. The memory 1109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1109 may include a volatile memory or a non-volatile memory, or the memory 1109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0155] The processor 1110 may include one or more processing units; optionally, the processor 1110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1110.
[0156] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned image processing method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0157] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0158] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0159] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0160] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0161] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0163] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image processing method, characterized in that: include: acquiring a first image; Performing image preprocessing on the first image to obtain a binary image; Obtaining a highlight area of the binary image; Filling and dilating the highlight area to obtain a second image specifically includes: obtaining discrete highlight areas in the binary image and filling the discrete highlight areas to obtain a fifth image; obtaining concentrated highlight areas in the fifth image and dilating the concentrated highlight areas to obtain a sixth image; merging the fifth image and the sixth image to obtain the second image; Based on the first image and the second image, obtaining a purple fringing occurrence area; Based on the purple fringing area, the first image is processed to obtain a third image; Performing color space transformation on the third image to obtain a fourth image; Based on the fourth image and the purple hue threshold, obtaining a purple-edge region; Acquiring a first saturation of a target pixel in the purple-fringe area, and setting the saturation of the target pixel to a second saturation based on the first saturation to obtain the fifth image, specifically comprising: acquiring the first saturation of the target pixel; acquiring the second saturation based on the proportion of the first saturation; setting the saturation of the target pixel to the second saturation to reduce the saturation and transition the color of the purple-fringe area and the surrounding area; The proportion of the first saturation is a ratio of the first saturation to 255.
0.
2. The image processing method according to claim 1, characterized in that: The performing image preprocessing on the first image to obtain a binary image specifically includes: Converting the first image into a grayscale image; The grayscale image is segmented into a binary image.
3. The image processing method according to claim 2, characterized in that: The step of segmenting the grayscale image into a binary image specifically includes: The grayscale image is segmented into the binary image using a first threshold.
4. The image processing method according to claim 1, characterized in that: The acquiring, based on the first image and the second image, a purple fringing occurrence area specifically includes: The first image and the second image are combined to obtain the purple-fringe appearing area.
5. The image processing method according to claim 1, characterized in that: The processing of the first image based on the purple fringing area to obtain the third image specifically includes: The purple-fringe region is combined with the first image to obtain a third image.
6. The image processing method according to claim 1, characterized in that: Performing color space transformation on the third image to obtain a fourth image specifically includes: The third image is converted into the HSV color space to obtain the fourth image.
7. An image processing device, characterized in that: include: A first acquisition module, used for acquiring a first image; A first processing module, used for performing image preprocessing on the first image to obtain a binary image; A second acquisition module is used to acquire a highlight area of the binary image; A second processing module, used for filling and dilating the highlight area to obtain a second image; A third acquisition module, used for acquiring a purple fringing appearance area based on the first image and the second image; A third processing module, configured to process the first image based on the purple fringing area to obtain a third image; A transformation module, used for performing color space transformation on the third image to obtain a fourth image; A fourth acquisition module, configured to acquire a purple-fringe area based on the fourth image and a purple hue threshold; A fifth acquisition module, configured to acquire a first saturation of a target pixel in the purple-fringe area, and set the saturation of the target pixel to a second saturation based on the first saturation, so as to obtain a fifth image; The second processing module specifically includes: a filling module, used to obtain discrete highlight areas in the binary image, and fill the discrete highlight areas to obtain a fifth image; an expansion module, used to obtain concentrated highlight areas in the fifth image, and expand the concentrated highlight areas to obtain a sixth image; a first merging module, used to merge the fifth image and the sixth image to obtain the second image; The fifth acquisition module includes: a first saturation acquisition module, used to acquire the first saturation of the target pixel; a second saturation acquisition module, used to acquire the second saturation based on the proportion of the first saturation; a setting module, used to set the saturation of the target pixel to the second saturation to reduce the saturation and make the color of the purple-edge area and the surrounding area transition; The proportion of the first saturation is a ratio of the first saturation to 255.
0.
8. The image processing device according to claim 7, characterized in that: The first processing module specifically includes: A grayscale image conversion module, used for converting the first image into a grayscale image; The binary image conversion module is used to segment the grayscale image into a binary image.
9. The image processing device according to claim 8, characterized in that: The binary image conversion module comprises: The segmentation module is used to segment the grayscale image into the binary image through a first threshold.
10. An electronic device, characterized in that: include: A memory on which programs or instructions are stored; A processor, configured to implement the steps of the image processing method according to any one of claims 1 to 6 when executing the program or instruction.
11. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the image processing method according to any one of claims 1 to 6 are implemented.
