WO2018133227A1 - 颜色填充方法及终端 - Google Patents

颜色填充方法及终端 Download PDF

Info

Publication number
WO2018133227A1
WO2018133227A1 PCT/CN2017/081301 CN2017081301W WO2018133227A1 WO 2018133227 A1 WO2018133227 A1 WO 2018133227A1 CN 2017081301 W CN2017081301 W CN 2017081301W WO 2018133227 A1 WO2018133227 A1 WO 2018133227A1
Authority
WO
WIPO (PCT)
Prior art keywords
area
channel
terminal
point
missing
Prior art date
Application number
PCT/CN2017/081301
Other languages
English (en)
French (fr)
Inventor
陈心
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201780082279.4A priority Critical patent/CN110140149B/zh
Publication of WO2018133227A1 publication Critical patent/WO2018133227A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning

Definitions

  • the present application relates to the field of image processing technologies, and in particular, to a color filling method and a terminal.
  • the missing area of the quadrilateral image is generally corrected by filling the missing area with the color set by the image correction application.
  • the color set by the application is relatively simple, and the color of the adjacent area of the missing area is more diverse, the filling color of the missing area is inconsistent with the color of the corrected image in some scenes, and the user experience is not good.
  • the color of the invitation card image is mainly blue and green, and there is a missing area in the upper left corner of the captured invitation card image; as shown in FIG. 1B, the corrected quadrilateral image is assumed to be applied.
  • the color is white, and the missing area in the upper left corner of the corrected image is filled with white.
  • the fill color of the missing area is sharply contrasted with the corrected image color.
  • Embodiments of the present application provide a color filling method and a terminal such that the fill color of the missing area is not sharply contrasted with the corrected image color.
  • an embodiment of the present application provides a color filling method, the method comprising: determining, by a terminal, a missing area of a quadrilateral image, wherein the quadrilateral image includes the missing area and a first area, wherein the missing area is a captured image of the quadrilateral image An outer area, the first area is an area of the quadrilateral image in the captured image; the terminal determines a second area in the first area adjacent to the missing area; the terminal determines the color according to the color of the second area The target color of the missing area; the terminal fills the missing area according to the target color.
  • the terminal determines a target color of the second region adjacent to the missing region in the first region, and fills the missing region with the target color. Since the second area is the adjacent area of the missing area, filling the missing area according to the target color of the second area can make the filling color of the missing area be close to the color of the corrected image, so that the contrast is not unobtrusive, and the application setting is avoided.
  • the fixed color fills the missing area, resulting in a problem of abrupt contrast between the fill color of the missing area and the corrected image color.
  • the terminal determines the second area in the first area that is adjacent to the missing area, including: the terminal determines the missing area and a common edge of the first area; the terminal determines the first Area At least one point that is not on the common edge; the terminal determines the second area based on the common edge and the at least one point. Based on the scheme, the terminal can determine a second region in the first region that is adjacent to the missing region.
  • the terminal determines the common area of the missing area and the first area
  • the method includes: determining, by the terminal, the common edge according to the first end point of the first side and the second end point of the second side, where The first side and the second side are two sides constituting the first area, and an intersection of the first side and the second side is located outside the first area, and the intersection is the quadrilateral corresponding to the missing area A missing vertex of the image, the first end point being an end point of the first side that is closer to the missing vertex, and the second end point is an end point of the second side that is closer to the missing vertex. Based on the scheme, the terminal can accurately determine the missing area and the common side of the first area.
  • the at least one point includes a first point and a second point; wherein the first point is a distance from the first edge to the first edge is
  • T a point of 1 *
  • T 2 *
  • represents the length of the first side, and L 21 represents the second endpoint and the second point The distance between, 0 ⁇ T 2 ⁇ 1,
  • the terminal can accurately determine the positions of the first point and the second point. Since the first point is a point on the first side and the second point is a point on the second side, the second area determined according to the first point, the second point, and the missing area and the common side of the first area is The complete area closest to the missing area, thus filling the missing area according to the target color of the second area, can make the fill color of the missing area closer to the corrected image color.
  • the terminal determines the target color of the missing area according to the color of the second area, including: the r channel, the g channel, and the b channel of the terminal for the red, green, and blue RGB color spaces of the second area.
  • the terminal determines the gray histogram H r of the r channel of the RGB color space of the second region; the terminal determines the second according to the gray histogram H r of the r channel
  • the gray-scale weighted average V r of the r channel of the region after the terminal is processed for the r channel in the terminal for the r channel, the g channel and the b channel, the terminal is based on the weighted average value of the r channel V r , a weighted average of the gradation g V g of the channel and the channel b V b gradation weighted average, determine the main gradation value (V r, V g, V b) of the deleted region; the terminal
  • the terminal determines, according to the gray histogram H r of the r channel, a gray weighted average value V r of the r channel of the second region, where the terminal acquires the gray histogram H r
  • the terminal determines the gray level G r,max with the highest probability according to the first preset formula
  • the first preset formula includes: X ⁇ [G r,1
  • the terminal can determine the gray-scale weighted average value V r of the r-channel of the second region more accurately according to the gray-scale histogram H r of the r-channel.
  • an embodiment of the present application provides a terminal, where the terminal has a function of implementing terminal behavior in the foregoing method.
  • This function can be implemented in hardware or in hardware by executing the corresponding software.
  • the hardware or software includes one or more modules corresponding to the functions described above.
  • an embodiment of the present application provides a terminal, including: a processor, a memory, and a communication interface; the memory is configured to store a computer execution instruction, and when the terminal is running, the processor executes the computer execution instruction stored in the memory. So that the terminal performs the color filling method described in the above aspects.
  • an embodiment of the present application provides a computer readable storage medium having instructions stored therein that, when run on a computer, cause the computer to perform the color filling method described in the above aspects.
  • an embodiment of the present application provides a computer program product comprising instructions that, when executed on a computer, cause the computer to perform the color filling method described in the above aspects.
  • FIG. 1 is a schematic diagram of an image missing area according to an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a gray histogram provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of hardware of a terminal according to an embodiment of the present disclosure.
  • FIG. 4 is a schematic flow chart of a color filling method according to an embodiment of the present application.
  • FIG. 5 is a schematic diagram of still another image missing area according to an embodiment of the present application.
  • FIG. 6 is a schematic flowchart diagram of still another color filling method according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram of still another image missing area according to an embodiment of the present application.
  • FIG. 8 is a schematic flowchart diagram of still another color filling method according to an embodiment of the present application.
  • FIG. 9 is a schematic flowchart diagram of still another color filling method according to an embodiment of the present application.
  • FIG. 10 is a schematic flowchart diagram of still another color filling method according to an embodiment of the present application.
  • FIG. 11 is a schematic diagram of still another image missing area according to an embodiment of the present application.
  • FIG. 12 is a schematic diagram of still another gray histogram according to an embodiment of the present application.
  • FIG. 13 is a schematic diagram of color filling of an image missing area according to an embodiment of the present application.
  • FIG. 14 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • FIG. 15 is a schematic structural diagram of still another terminal according to an embodiment of the present application.
  • the gray histogram is a function of the gray level distribution and is a statistic of the gray level distribution of the pixel points in the image.
  • a gray histogram is a method of counting the frequency or probability of occurrence of all pixels in a digital image according to the magnitude of the gray value.
  • red green blue (RGB) color mode Second, red green blue (RGB) color mode:
  • RGB color mode is a color standard in the industry, which is obtained by changing the three color channels of red (R), green (G), and blue (B) and superimposing them on each other.
  • RGB is the color of the three channels of red, green and blue. This standard includes almost all the colors that human vision can perceive. It is one of the most widely used color systems.
  • A/B in the embodiment of the present application means or, for example, A/B may represent A or B; “and/or” in the embodiment of the present application is merely an association describing the associated object.
  • the relationship indicates that there may be three kinds of relationships, for example, A and/or B, which may indicate that there are three cases where A exists separately, A and B exist at the same time, and B exists separately.
  • Multiple means two or more than two.
  • FIG. 3 is a schematic structural diagram of a hardware structure of a terminal according to an embodiment of the present application.
  • the terminal 300 includes a processor 301, a camera 302, a display 303, a memory 304, and a bus 305.
  • the processor 301, the camera 302, the display 303, and the memory 304 are connected to one another via a bus 305.
  • the processor 301 is a control center of the terminal 300, connects the various parts of the entire terminal 300 via the bus 305, executes the terminal by running or executing software programs and/or modules stored in the memory 304, and calling data stored in the memory 304.
  • the various functions of 300 and processing data provide overall monitoring of terminal 300.
  • the processor 301 may include one or more processing units; the processor 301 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, etc., and a modulation solution
  • the processor mainly handles wireless communication. It can be understood that the above modem processor may not be integrated into the processor 301.
  • the camera 302 is used to capture an object and obtain image data of the object.
  • the camera 302 may be a depth camera or a dual camera, which is not specifically limited in this embodiment of the present application.
  • the display 303 is for displaying an image obtained by photographing and processing the object.
  • the memory 304 can be used to store software programs and modules, and the processor 301 is stored in the memory by running The software programs and modules in 304 perform various functional applications and data processing of the terminal 300.
  • the memory 304 mainly includes a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function (such as a photographing function, a document correction function), and the like; the storage data area can be stored according to the terminal 300. Use the created data (such as the angle library of the preset rectangular pose) and so on.
  • memory 304 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the bus 305 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 3, but it does not mean that there is only one bus or one type of bus.
  • the terminal 300 may further include a radio frequency (RF) circuit, an audio circuit, a communication interface, and/or a plurality of sensors, etc., which are not specifically limited in this embodiment of the present application.
  • RF radio frequency
  • FIG. 4 is a schematic flowchart of a color filling method provided by the embodiment of the present application, including steps S401-S404:
  • the terminal determines a missing area of the quadrilateral image.
  • the quadrilateral image includes a missing area and a first area
  • the missing area is an area of the quadrilateral image outside the captured image
  • the first area is an area of the quadrilateral image in the captured image.
  • the missing area of the quadrilateral image outside the captured image may be one or more, and each of the missing areas may be color-filled by using the color filling method provided by the embodiment of the present application.
  • the application examples are not specifically limited thereto.
  • the quadrilateral image KFLI of FIG. 5 has two missing regions outside the captured image ABCD, namely a triangular region KEJ and a triangular region GLH, and the quadrilateral image KFLI in the captured image ABCD in the hexagonal region EFGHIJ is a quadrilateral image KFLI in the captured image.
  • the area in the ABCD which is the first area.
  • the terminal determines a second area in the first area that is adjacent to the missing area.
  • the second area determined by the terminal may be the entire area of the first area.
  • the terminal determines a target color of the missing area according to the color of the second area.
  • the terminal fills the missing area according to the target color.
  • the terminal determines a target color of the second region adjacent to the missing region in the first region, and fills the missing region with the target color. Since the second area is the adjacent area of the missing area, filling the missing area according to the target color of the second area can make the filling color of the missing area be close to the color of the corrected image, so that the contrast is not unobtrusive, and the application setting is avoided.
  • the fixed color fills the missing area, resulting in a problem of abrupt contrast between the fill color of the missing area and the corrected image color.
  • step S402 may specifically include steps S402A-S402C:
  • the terminal determines the missing area and the common side of the first area.
  • the terminal determines at least one point in the first area that is not on the public side.
  • At least one point which may be a point, or a plurality of points, is not specifically limited in this embodiment.
  • these points may be points on the side of the first area, and may also be points in the first area, which is not specifically limited in this embodiment of the present application.
  • the terminal determines the second area according to the common edge and the at least one point.
  • the first missing area triangle area KEJ in FIG. 5 it is assumed that at least one point on the common side of the first area EFGHIJ determined by the terminal is point M, as shown in FIG. 7, adjacent to the triangle area KEJ
  • the second area is a triangular area EMJ.
  • the second missing area triangular area GLH in FIG. 5 assuming that at least one point of the first area EFGHIJ that is not on the common side determined by the terminal is point N and point O, as shown in FIG. 7,
  • the second region adjacent to the triangular region GLH is a quadrilateral region NGHO.
  • the terminal can determine a second region in the first region that is adjacent to the missing region.
  • step S402A may specifically include step S402A1:
  • S402A1 The terminal determines a common edge according to the first end point of the first side and the second end point of the second side.
  • the first side and the second side are two sides constituting the first area, and the intersection of the first side and the second side is located outside the first area, and the intersection point is a missing vertex of the quadrilateral image corresponding to the missing area, first The endpoint is the endpoint of the first edge that is closer to the missing vertex, and the second endpoint is the endpoint of the second edge that is closer to the missing vertex.
  • the edge EF and the edge IJ in FIG. 5 are two sides constituting the first region EFGHIJ, the intersection point K of the edge EF and the edge IJ is located outside the first region EFGHIJ, and the intersection point K is a quadrilateral image corresponding to the triangle region KEJ of the missing region.
  • a missing vertex of KFLI the endpoint E is the endpoint near the missing vertex in the edge EF, and the endpoint J is the endpoint near the missing vertex in the edge IJ, so it can be determined that the edge EJ is the missing region triangle region KEJ and the first region EFGHIJ
  • the public side Or, for example, the side FG and the side HI in FIG.
  • the intersection L of the side FG and the side HI is located outside the first area EFGHIJ, and the intersection point L is the missing area triangle area GLH A missing vertex of the quadrilateral image KFLI, the end point G is the end point of the edge FG which is closer to the missing vertex, and the end point H is the end point of the edge HI which is closer to the missing vertex, so it can be determined that the edge GH is the missing area triangle area GLH and the The public side of a region EFGHIJ.
  • the terminal can accurately determine the missing area and the common side of the first area.
  • the at least one point includes a first point and a second point.
  • the first point is a point on the first side that is separated from the first end point by
  • T 1 *
  • the second point is on the second side and the second end point
  • T 2 *
  • L 11 represents the distance between the first end point and the first point, 0 ⁇ T 1 ⁇ 1,
  • L 21 represents the distance between the second end point and the second point, 0 ⁇ T 2 ⁇ 1,
  • represents the length of the second side.
  • T 1 and T 2 may be the same or different, which is not specifically limited in this embodiment of the present application.
  • the terminal can accurately determine the positions of the first point and the second point. Since the first point is a point on the first side and the second point is a point on the second side, the second area determined according to the first point, the second point, and the missing area and the common side of the first area is The complete area closest to the missing area, thus filling the missing area according to the target color of the second area, can make the fill color of the missing area closer to the corrected image color.
  • step S403 may specifically include steps S403A-S403C:
  • S403A The terminal processes the r channel, the g channel, and the b channel of the RGB color space of the second area according to the following operations for the r channel.
  • T1 The terminal determines a gray histogram H r of the r channel of the RGB color space of the second region.
  • T2 The terminal determines the gray-scale weighted average value V r of the r-channel of the second region according to the gray-scale histogram H r of the r-channel.
  • the terminal after the terminal processes the r channel, the g channel, and the b channel according to the above operation for the r channel, the terminal according to the weighted average value of the r channel V r , the gray scale weighted average of the g channel V g and the b channel
  • the weighted average value V b of the gray scale determines the main gray value (V r , V g , V b ) of the missing area.
  • S403C The terminal determines a target color of the missing area according to the primary gray value (V r , V g , V b ).
  • the terminal can determine the target color of the missing area according to the color of the second area.
  • step T2 may specifically include steps T2A-T2D:
  • T2A The terminal acquires the gray level G r,max with the highest probability in the gray histogram H r .
  • T2B The neighboring interval of the gray level G r,max where the terminal determines the maximum probability is [G r,1 , G r,2 ].
  • G r,1 ⁇ [0,255]
  • G r,2 ⁇ [0,255].
  • G r,max -G r,1 G r,2 -G r,max .
  • T2C The terminal determines the probability sum S r of all gray levels in the adjacent interval of the gray level G r,max with the highest probability according to formula (1).
  • T2D S r and the terminal according to the equation (2), to determine a weighted average of the gray channels V r r RGB color space of the second region.
  • H r '(x) H r (x)/S r
  • H r (x) represents the probability value of the gray scale representing the gray level x in the gray histogram of the r channel
  • H' r (x ) indicates normalization to H r (x)
  • indicates summation of all values on the interval.
  • the terminal can determine the gray-scale weighted average value V r of the r-channel of the second region according to the gray-scale histogram H r of the r-channel.
  • the color filling method provided by the embodiment of the present application may be used before the quadrilateral image is corrected to a rectangular image, or may be used before being displayed to the user after the quadrilateral image is corrected into a rectangular image. No specific limitation.
  • the quadrilateral image is ABCD
  • the captured image is IJKL
  • the first region of the quadrilateral image in the captured image is EBCDH
  • the terminal can determine that the missing area of the quadrilateral image is AEH.
  • the terminal determines a second area in the first area adjacent to the missing area.
  • the terminal determines that the common side of the triangular area AEH and the pentagon area EBCDH is EH according to the end point E on the side EB and the end point H on the side DH.
  • the terminal determines at least one point in the first area that is not on the common side.
  • the terminal determines the quadrilateral region EFGH enclosed by the edge EH, the point F, and the point G as the second region.
  • the terminal determines the target color of the missing area according to the color of the second area.
  • the gray scale histogram H r of the r channel of the RGB color space of the quadrilateral region EFGH determined for the terminal is shown in FIG. 12, the gray scale histogram H r of the r channel of the RGB color space of the quadrilateral region EFGH determined for the terminal.
  • the terminal determines the gray-scale weighted average value r r 26.8 ⁇ 27 of the r-channel of the RGB color space of the quadrilateral region EFGH according to S r and the formula (4).
  • the terminal fills the missing area according to the target color.
  • the terminal fills the triangle area AEH according to the dark blue, and the result is as shown in FIG.
  • the color filling method provided by the embodiment of the present application fills the missing area, so that the filling color of the missing area is close to the color of the corrected image, so that the contrast is not obtrusive, and the fixed setting due to the use of the application is avoided.
  • the color fills the missing area, causing a problem in which the fill color of the missing area contrasts with the corrected image color.
  • the terminal includes a hardware structure and/or a software module corresponding to each function.
  • the present application can be implemented in a combination of hardware or hardware and computer software in combination with the elements and algorithm steps of the various examples described in the embodiments disclosed herein. Whether a function is implemented in hardware or computer software to drive hardware depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods to implement the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present application.
  • the embodiment of the present application may divide the function module into the terminal according to the foregoing method example.
  • each function module may be divided according to each function, or two or more functions may be integrated into one processing module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of the module in the embodiment of the present application is schematic, and is only a logical function division, and the actual implementation may have another division manner.
  • FIG. 14 shows a possible structural diagram of the terminal 140 involved in the above embodiment.
  • the terminal 140 includes a determination module 141 and a filler module 142.
  • the determining module 141 is configured to support the terminal 140 to perform step S401, step S402, and step S403 in FIG. 4;
  • the filling module 142 is configured to support the terminal 140 to perform step S404 in FIG.
  • the determining module 141 is configured to support the terminal 140 to perform step S401, step S402A, step S402B, step S402C, and step S403 in FIG. 6;
  • the filling module 142 is configured to support the terminal 140 to perform step S404 in FIG. 6.
  • the determining module 141 is configured to support the terminal 140 to perform step S401, step S402A1, step S402B, step S402C, and step S403 in FIG. 8; the filling module 142 is configured to support the terminal 140 to perform step S404 in FIG.
  • the determining module 141 is configured to support the terminal 140 to perform steps S401, S402, and S403 in FIG. 9 and T1 and T2, step S403B, step S403C, and step S403D.
  • the filling module 142 is configured to support the terminal 140. Step S404 in Fig. 9 is performed.
  • the determining module 141 is configured to support the terminal 140 to perform T1, T2A, T2B, T2C, and T2D, step S403B, step S403C, and step S403D in step S401, step S402, and step S403A in FIG. 10; 142 is used to support the terminal 140 to perform step S404 in FIG.
  • FIG. 15 shows a possible structural diagram of the terminal 150 involved in the above embodiment.
  • the terminal 150 includes a processing module 151.
  • the processing module 151 is configured to support the terminal 150 to perform step S401, step S402, step S403, and step S404 in FIG.
  • the processing module 151 is configured to support the terminal 150 to perform step S401, step S402A, step S402B, step S402C, step S403, and step S404 in FIG. 6.
  • the processing module 151 is configured to support the terminal 150 to perform step S401, step S402A1, step S402B, step S402C, step S403, and step S404 in FIG.
  • the processing module 151 is configured to support the terminal 150 to perform T1 and T2, step S403B, step S403C, step S403D, and step S404 in step S401, step S402, and step S403A in FIG.
  • the processing module 151 is configured to support the terminal 150 to perform T1, T2A, T2B, T2C, and T2D, step S403B, step S403C, step S403D, and step S404 in step S401, step S402, and step S403A in FIG.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • a software program it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device that includes one or more servers, data centers, etc. that can be integrated with the media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)) or the like.
  • a magnetic medium eg, a floppy disk, a hard disk, a magnetic tape
  • an optical medium eg, a DVD
  • a semiconductor medium such as a Solid State Disk (SSD)

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

一种颜色填充方法及终端,适用于图像处理技术领域。该方法包括:终端确定四边形图像的缺失区域(S401),其中,所述四边形图像包括所述缺失区域和第一区域,所述缺失区域为所述四边形图像在拍摄图像外的区域,所述第一区域为所述四边形图像在所述拍摄图像中的区域;所述终端确定所述第一区域中与所述缺失区域相邻的第二区域(S402);所述终端根据所述第二区域的颜色确定所述缺失区域的目标颜色(S403);所述终端根据所述目标颜色填充所述缺失区域(S404)。

Description

颜色填充方法及终端
本申请要求于2017年1月18日提交中国专利局、申请号为201710036812.5、发明名称为“一种矩形框缺失部分的颜色填充方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及图像处理技术领域,尤其涉及颜色填充方法及终端。
背景技术
随着科技的不断发展,越来越多带有摄像头的终端设备被应用到日常生活中。
通常,在用摄像头拍摄四边形图像时,由于拍摄位置不理想、拍摄的四边形图像过大或可供拍摄的时间有限等,可能导致最终呈现出来的四边形图像存在缺失区域。
目前,一般通过使用图像校正应用设定的颜色对缺失区域进行填充的方式对四边形图像的缺失区域进行校正。但是,由于应用设定的颜色较为单一,而缺失区域的相邻区域的颜色较为多样化,从而导致某些场景下,缺失区域的填充颜色与校正后的图像颜色对比突兀,用户体验不佳。比如,如图1A所示,邀请卡图像的颜色主要为蓝色和绿色,拍摄得到的邀请卡图像左上角存在一个缺失区域;如图1B所示,为校正后的四边形图像,假设应用设定的颜色为白色,校正后图像中的左上角的缺失区域填充为白色,显然,缺失区域的填充颜色与校正后的图像颜色对比突兀。
因此,如何对四边形图像的缺失区域进行校正,使得缺失区域的填充颜色与校正后的图像颜色对比不突兀,是目前亟待解决的问题。
发明内容
本申请的实施例提供颜色填充方法及终端,使得缺失区域的填充颜色与校正后的图像颜色不对比突兀。
为达到上述目的,本申请的实施例采用如下技术方案:
一方面,本申请实施例提供一种颜色填充方法,该方法包括:终端确定四边形图像的缺失区域,其中,该四边形图像包括该缺失区域和第一区域,该缺失区域为该四边形图像在拍摄图像外的区域,该第一区域为该四边形图像在该拍摄图像中的区域;该终端确定该第一区域中与该缺失区域相邻的第二区域;该终端根据该第二区域的颜色确定该缺失区域的目标颜色;该终端根据该目标颜色填充该缺失区域。本申请实施例提供的颜色填充方法,终端确定第一区域中与缺失区域相邻的第二区域的目标颜色,并使用该目标颜色填充该缺失区域。由于第二区域为缺失区域的相邻区域,因此根据第二区域的目标颜色填充缺失区域可以使得缺失区域的填充颜色与校正后的图像颜色接近,从而对比不突兀,避免了由于使用应用设定的固定颜色对缺失区域进行填充,导致缺失区域的填充颜色与校正后的图像颜色对比突兀的问题。
一种可能的实现方式中,该终端确定该第一区域中与该缺失区域相邻的第二区域,包括:该终端确定该缺失区域与该第一区域的公共边;该终端确定该第一区域 中不在该公共边上的至少一个点;该终端根据该公共边和该至少一个点确定该第二区域。基于该方案,终端可以确定出第一区域中与缺失区域相邻的第二区域。
一种可能的实现方式中,该终端确定该缺失区域与该第一区域的公共边,包括:该终端根据第一边的第一端点和第二边的第二端点确定该公共边,其中,该第一边和该第二边为构成该第一区域的其中两条边,该第一边和该第二边的交点位于该第一区域外,该交点为该缺失区域对应的该四边形图像的缺失顶点,该第一端点为该第一边中距离该缺失顶点较近的端点,该第二端点为该第二边中距离该缺失顶点较近的端点。基于该方案,终端可以准确地确定出缺失区域和第一区域的公共边。
一种可能的实现方式中,该至少一个点包括第一点和第二点;其中,该第一点为该第一边上与该第一端点的距离为||L11||=T1*||L1||的点,该第二点为该第二边上与该第二端点的距离为||L21||=T2*||L2||的点,L11表示该第一端点和该第一点之间的距离,0<T1<1,||L1||表示该第一边的长度,L21表示该第二端点和该第二点之间的距离,0<T2<1,||L2||表示该第二边的长度。基于该方案,终端可以准确的确定第一点和第二点的位置。由于第一点为第一边上的点,第二点为第二边上的点,因此根据第一点、第二点和缺失区域与第一区域的公共边确定出的第二区域才是与缺失区域最接近的完整区域,因此根据该第二区域的目标颜色填充缺失区域可以使得缺失区域的填充颜色与校正后的图像颜色更接近。
一种可能的实现方式中,该终端根据该第二区域的颜色确定该缺失区域的目标颜色,包括:该终端对于该第二区域的红绿蓝RGB色彩空间的r通道、g通道和b通道,均按照下面针对r通道的操作处理:该终端确定该第二区域的RGB色彩空间的r通道的灰度直方图Hr;该终端根据该r通道的灰度直方图Hr确定该第二区域的r通道的灰度加权平均值Vr;在该终端对于r通道、g通道和b通道,均按照上面针对r通道的操作进行处理后,该终端根据该r通道的加权平均值Vr、该g通道的灰度加权平均值Vg和该b通道灰度的加权平均值Vb,确定该缺失区域的主灰度值(Vr,Vg,Vb);该终端根据该主灰度值(Vr,Vg,Vb)确定该缺失区域的目标颜色。基于该方案,终端可以根据第二区域的颜色确定出缺失区域的目标颜色。
一种可能的实现方式中,该终端根据该r通道的灰度直方图Hr确定该第二区域的r通道的灰度加权平均值Vr,包括:该终端获取该灰度直方图Hr中概率最大的灰度级Gr,max;该终端确定该概率最大的灰度级Gr,max的临近区间为[Gr,1,Gr,2],其中,Gr,max∈[Gr,1,Gr,2],Gr,1∈[0,255],Gr,2∈[0,255];该终端根据第一预设公式,确定该概率最大的灰度级Gr,max的临近区间内所有灰度级的概率总和Sr;该终端根据该Sr以及第二预设公式,确定该第二区域的RGB色彩空间的r通道的灰度加权平均值Vr;其中,该第一预设公式包括:
Figure PCTCN2017081301-appb-000001
x∈[Gr,1,Gr,2];该第二预设公式包 括:
Figure PCTCN2017081301-appb-000002
x∈[Gr,1,Gr,2];其中,Hr'(x)=Hr(x)/Sr,Hr(x)表示表示r通道的灰度直方图中灰度级为x的灰度的概率值,H'r(x)表示对Hr(x)归一化,∑表示对区间上的所有值求和。基于该方案,终端可以根据r通道的灰度直方图Hr确定出第二区域的r通道的灰度加权平均值Vr
一种可能的实现方式中,Gr,max-Gr,1=Gr,2-Gr,max。基于该方案,终端可以更准确地根据r通道的灰度直方图Hr确定出第二区域的r通道的灰度加权平均值Vr
又一方面,本申请实施例提供一种终端,该终端具有实现上述方法中终端行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的模块。
又一方面,本申请实施例提供一种终端,包括:处理器、存储器和通信接口;该存储器用于存储计算机执行指令,当该终端运行时,该处理器执行该存储器存储的该计算机执行指令,以使该终端执行上述各方面所述的颜色填充方法。
又一方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面所述的颜色填充方法。
又一方面,本申请实施例提供了一种包含指令的计算机程序产品,当其在计算机上执行时,使得计算机执行上述各方面所述的颜色填充方法。
另外,上述终端实施例中任一种设计方式所带来的技术效果可参见上述颜色填充方法实施例中不同设计方式所带来的技术效果,此处不再赘述。
本申请的这些方面或其他方面在以下实施例的描述中会更加简明易懂。
附图说明
图1为本申请实施例提供的一种图像缺失区域的示意图;
图2为本申请实施例提供的灰度直方图的示意图;
图3为本申请实施例提供的一种终端的硬件结构示意图;
图4为本申请实施例提供的一种颜色填充方法的流程示意图;
图5为本申请实施例提供的又一种图像缺失区域的示意图;
图6为本申请实施例提供的又一种颜色填充方法的流程示意图;
图7为本申请实施例提供的又一种图像缺失区域的示意图;
图8为本申请实施例提供的又一种颜色填充方法的流程示意图;
图9为本申请实施例提供的又一种颜色填充方法的流程示意图;
图10为本申请实施例提供的又一种颜色填充方法的流程示意图;
图11为本申请实施例提供的又一种图像缺失区域的示意图;
图12为本申请实施例提供的又一种灰度直方图的示意图;
图13为本申请实施例提供的一种图像缺失区域颜色填充的示意图;
图14为本申请实施例提供的一种终端的结构示意图;
图15为本申请实施例提供的又一种终端的结构示意图。
具体实施方式
为了下述各实施例的描述清楚简洁,首先给出相关概念或技术的简要介绍:
一、灰度直方图:
如图2所示,灰度直方图是关于灰度级分布的函数,是对图像中的象素点的灰度级分布的统计。灰度直方图是将数字图像中的所有象素,按照灰度值的大小,统计其出现的频率或概率。
二、红绿蓝(red green blue,RGB)色彩模式:
RGB色彩模式是工业界的一种颜色标准,是通过对红(R)、绿(G)、蓝(B)三个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色,RGB即是代表红、绿、蓝三个通道的颜色,这个标准几乎包括了人类视力所能感知的所有颜色,是目前运用最广的颜色***之一。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。
需要说明的是,本申请实施例中的“/”表示或的意思,例如,A/B可以表示A或B;本申请实施例中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。“多个”是指两个或多于两个。
需要说明的是,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。
需要说明的是,本申请实施例中,“的(of)”,“相应的(corresponding,relevant)”和“对应的(corresponding)”有时可以混用,应当指出的是,在不强调其区别时,其所要表达的含义是一致的。
如图3所示,为本申请实施例提供的一种终端的硬件结构示意图。该终端300包括处理器301、摄像头302、显示器303、存储器304和总线305。其中,处理器301、摄像头302、显示器303和存储器304通过总线305相互连接。
处理器301是终端300的控制中心,通过总线305连接整个终端300的各个部分,通过运行或执行存储在存储器304内的软件程序和/或模块,以及调用存储在存储器304内的数据,执行终端300的各种功能和处理数据,从而对终端300进行整体监控。可选的,处理器301可包括一个或多个处理单元;处理器301可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作***、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器301中。
摄像头302用于对目标物进行拍摄,获得目标物的图像数据。其中,该摄像头302可以是深度摄像头或双摄像头,本申请实施例对此不作具体限定。
显示器303用于显示对目标物进行拍摄并且处理后的图像。
存储器304可用于存储软件程序以及模块,处理器301通过运行存储在存储器 304中的软件程序以及模块,从而执行终端300的各种功能应用以及数据处理。存储器304主要包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需的应用程序(比如拍照功能,文档校正功能)等;存储数据区可存储根据终端300的使用所创建的数据(比如预置的矩形姿态的角度库)等。此外,存储器304可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
总线305可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
尽管未示出,终端300还可能包括射频(radio frequency,RF)电路、音频电路、通信接口和/或多种传感器等,本申请实施例对此不作具体限定。
下面,结合图4对本申请实施例提供的颜色填充方法进行描述,如图4所示,为本申请实施例提供的一种颜色填充方法的流程示意图,包括步骤S401-S404:
S401、终端确定四边形图像的缺失区域。
其中,四边形图像包括缺失区域和第一区域,缺失区域为四边形图像在拍摄图像外的区域,第一区域为四边形图像在拍摄图像中的区域。
需要说明的是,本申请实施例中,四边形图像在拍摄图像外的缺失区域可以为一个也可以为多个,每一个缺失区域都可以采用本申请实施例提供的颜色填充方法进行颜色填充,本申请实施例对此不作具体限定。
比如,图5的四边形图像KFLI在拍摄图像ABCD外存在两个缺失区域,分别为三角形区域KEJ和三角形区域GLH,四边形图像KFLI在拍摄图像ABCD中的六边形区域EFGHIJ为四边形图像KFLI在拍摄图像ABCD中的区域,也即第一区域。
S402、终端确定第一区域中与缺失区域相邻的第二区域。
可选的,本申请实施例中,终端确定的第二区域可以为第一区域的全部区域。
S403、终端根据第二区域的颜色确定缺失区域的目标颜色。
S404、终端根据目标颜色填充缺失区域。
本申请实施例提供的颜色填充方法,终端确定第一区域中与缺失区域相邻的第二区域的目标颜色,并使用该目标颜色填充该缺失区域。由于第二区域为缺失区域的相邻区域,因此根据第二区域的目标颜色填充缺失区域可以使得缺失区域的填充颜色与校正后的图像颜色接近,从而对比不突兀,避免了由于使用应用设定的固定颜色对缺失区域进行填充,导致缺失区域的填充颜色与校正后的图像颜色对比突兀的问题。
可选的,如图6所示,步骤S402具体可以包括步骤S402A-S402C:
S402A、终端确定缺失区域与第一区域的公共边。
S402B、终端确定第一区域中不在公共边上的至少一个点。
其中,至少一个点,具体可以是一个点,也可以是多个点,本申请实施例对此不作具体限定。另外,这些点可以为第一区域边上的点,也可以为第一区域内的点,本申请实施例对此不作具体限定。
S402C、终端根据公共边和该至少一个点确定第二区域。
比如,对于图5中第一个缺失区域三角形区域KEJ,假设终端确定的第一区域EFGHIJ中不在公共边上的至少一个点为点M,则如图7所示,与三角形区域KEJ相邻的第二区域为三角形区域EMJ。或者,比如,对于图5中的第二个缺失区域三角形区域GLH,假设终端确定的第一区域EFGHIJ中不在公共边上的至少一个点为点N和点O,则如图7所示,与三角形区域GLH相邻的第二区域为四边形区域NGHO。
基于该方案,终端可以确定出第一区域中与缺失区域相邻的第二区域。
可选的,如图8所示,步骤S402A具体可以包括步骤S402A1:
S402A1、终端根据第一边的第一端点和第二边的第二端点确定公共边。
其中,第一边和第二边为构成第一区域的其中两条边,第一边和第二边的交点位于第一区域外,该交点为缺失区域对应的四边形图像的缺失顶点,第一端点为第一边中距离缺失顶点较近的端点,第二端点为第二边中距离缺失顶点较近的端点。
比如,图5中的边EF和边IJ为构成第一区域EFGHIJ的其中两条边,边EF和边IJ的交点K位于第一区域EFGHIJ外,交点K为缺失区域三角形区域KEJ对应的四边形图像KFLI的一个缺失顶点,端点E为边EF中距离缺失顶点较近的端点,端点J为边IJ中距离缺失顶点较近的端点,因此可以确定边EJ为缺失区域三角形区域KEJ和第一区域EFGHIJ的公共边。或者,比如,图5中的边FG和边HI为构成第一区域EFGHIJ的其中两条边,边FG和边HI的交点L位于第一区域EFGHIJ外,该交点L为缺失区域三角形区域GLH对应的四边形图像KFLI的一个缺失顶点,端点G为边FG中距离缺失顶点较近的端点,端点H为边HI中距离缺失顶点较近的端点,因此可以确定边GH为缺失区域三角形区域GLH和第一区域EFGHIJ的公共边。
基于该方案,终端可以准确地确定出缺失区域和第一区域的公共边。
一种可能的实现方式中,该至少一个点包括第一点和第二点。其中,第一点为第一边上与第一端点的距离为||L11||=T1*||L1||的点,第二点为第二边上与第二端点的距离为||L21||=T2*||L2||的点,L11表示第一端点和第一点之间的距离,0<T1<1,||L1||表示第一边的长度,L21表示第二端点和第二点之间的距离,0<T2<1,||L2||表示第二边的长度。
可选的,T1和T2的取值可以相同,也可以不同,本申请实施例对此不作具体限定。
基于该方案,终端可以准确的确定第一点和第二点的位置。由于第一点为第一边上的点,第二点为第二边上的点,因此根据第一点、第二点和缺失区域与第一区域的公共边确定出的第二区域才是与缺失区域最接近的完整区域,因此根据该第二区域的目标颜色填充缺失区域可以使得缺失区域的填充颜色与校正后的图像颜色更接近。
具体的,如图9所示,步骤S403具体可以包括步骤S403A-S403C:
S403A:终端对于第二区域的RGB色彩空间的r通道、g通道和b通道,均按照下面针对r通道的操作处理。
T1:终端确定第二区域的RGB色彩空间的r通道的灰度直方图Hr
T2:终端根据r通道的灰度直方图Hr确定第二区域的r通道的灰度加权平均值Vr
S403B、在终端对于r通道、g通道和b通道,均按照上面针对r通道的操作进行处理后,终端根据r通道的加权平均值Vr、g通道的灰度加权平均值Vg和b通道灰度的加权平均值Vb,确定缺失区域的主灰度值(Vr,Vg,Vb)。
S403C、终端根据主灰度值(Vr,Vg,Vb)确定缺失区域的目标颜色。
基于该方案,终端可以根据第二区域的颜色确定出缺失区域的目标颜色。
具体的,如图10所示,步骤T2具体可以包括步骤T2A-T2D:
T2A:终端获取灰度直方图Hr中概率最大的灰度级Gr,max
T2B:终端确定概率最大的灰度级Gr,max的临近区间为[Gr,1,Gr,2]。
其中,Gr,max∈[Gr,1,Gr,2]。
可选的,一种可能的实现方式中,Gr,1∈[0,255],Gr,2∈[0,255]。
可选的,另一种可能的实现方式中,Gr,max-Gr,1=Gr,2-Gr,max
T2C:终端根据公式(1),确定概率最大的灰度级Gr,max的临近区间内所有灰度级的概率总和Sr
Figure PCTCN2017081301-appb-000003
T2D:终端根据Sr以及公式(2),确定第二区域的RGB色彩空间的r通道的灰度加权平均值Vr
Figure PCTCN2017081301-appb-000004
其中,Hr'(x)=Hr(x)/Sr,Hr(x)表示表示r通道的灰度直方图中灰度级为x的灰度的概率值,H'r(x)表示对Hr(x)归一化,∑表示对区间上的所有值求和。
基于该方案,终端可以根据r通道的灰度直方图Hr确定出第二区域的r通道的灰度加权平均值Vr
需要说明的是,本申请实施例提供的颜色填充方法既可以在将四边形图像校正为矩形图像前使用,也可以在将四边形图像校正为矩形图像后显示给用户前使用,本申请实施例对此不作具体限定。
下面将给出结合上述实施例提供的颜色填充方法对缺失区域进行颜色填充的具体示例。
示例性的,如图11所示,假设四边形图像为ABCD,拍摄到的图像为IJKL,四边形图像在拍摄图像中的第一区域为EBCDH,则:
第一步、终端可以确定四边形图像的缺失区域为AEH。
第二步、终端确定第一区域中与缺失区域相邻的第二区域。
首先,终端根据边EB上的端点E和边DH上的端点H确定三角形区域AEH和五边形区域EBCDH的公共边为EH。
其次,终端确定第一区域中不在公共边上的至少一个点。
比如,当T1=0.1,T2=0.1时,不在公共边上的至少一个点可以包括:边EB上与端点E距离为0.1EB的点F,边DH上与端点H距离为0.1DH的点G,即,EF=0.1EB,GH=0.1DH。
最后,终端将边EH、点F、点G连接围成的四边形区域EFGH确定为第二区域。
第三步、终端根据第二区域的颜色确定缺失区域的目标颜色。
首先,如图12所示,为终端确定的四边形区域EFGH的RGB色彩空间的r通道的灰度直方图Hr
其次,终端获取灰度直方图Hr中概率最大的灰度级Gr,max=27。
再次,终端确定概率最大的灰度级Gr,max=27的临近区间为Gr,max∈[17,37]。
再次,终端根据公式(1),确定概率最大的灰度级Gr,max=27的临近区间内所有灰度级的概率总和Sr=0.8822。
终端根据Sr以及公式(4),确定四边形区域EFGH的RGB色彩空间的r通道的灰度加权平均值Vr=26.8≈27。
同样的,根据上述确定四边形区域EFGH的RGB色彩空间的r通道的灰度加权平均值过程确定四边形区域EFGH的RGB色彩空间的g通道的灰度加权平均值Vg=30,以及RGB色彩空间的b通道的灰度加权平均值Vb=39。
其次,终端将四边形区域EFGH灰度加权平均值确定为三角形区域AEH主灰度值=(27,30,39)。
最后,终端根据三角形区域AEH的主灰度值=(27,30,39)确定三角形区域AEH的目标颜色为深蓝色。
第四步、终端根据目标颜色填充缺失区域。
终端根据深蓝色填充三角形区域AEH,结果如图13所示。
由上述示例可以看出,基于本申请实施例提供的颜色填充方法填充缺失区域,可以使得缺失区域的填充颜色与校正后的图像颜色接近,从而对比不突兀,避免了由于使用应用设定的固定颜色对缺失区域进行填充,导致缺失区域的填充颜色与校正后的图像颜色对比突兀的问题。
上述主要从终端的角度对本申请提供的方案进行介绍,可以理解的是,上述终端为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对终端进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
比如,在采用对应各个功能划分各个功能模块的情况下,图14示出了上述实施例中所涉及的终端140的一种可能的结构示意图。如图14所示,终端140包括确定模块141和填充模块142。确定模块141用于支持终端140执行图4中的步骤S401、步骤S402以及步骤S403;填充模块142用于支持终端140执行图4中的步骤S404。 或者,可选的,确定模块141用于支持终端140执行图6中的步骤S401、步骤S402A、步骤S402B、步骤S402C以及步骤S403;填充模块142用于支持终端140执行图6中的步骤S404。或者,可选的,确定模块141用于支持终端140执行图8中的步骤S401、步骤S402A1、步骤S402B、步骤S402C以及步骤S403;填充模块142用于支持终端140执行图8中的步骤S404。或者,可选的,确定模块141用于支持终端140执行图9中的步骤S401、步骤S402、步骤S403A中的T1和T2、步骤S403B、步骤S403C以及步骤S403D;填充模块142用于支持终端140执行图9中的步骤S404。或者,可选的,确定模块141用于支持终端140执行图10中的步骤S401、步骤S402、步骤S403A中的T1、T2A、T2B、T2C和T2D、步骤S403B、步骤S403C以及步骤S403D;填充模块142用于支持终端140执行图10中的步骤S404。
其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
以采用集成的方式划分各个功能模块的情况下,图15示出了上述实施例中所涉及的终端150的一种可能的结构示意图。如图15所示,终端150包括处理模块151。处理模块151用于支持终端150执行图4中的步骤S401、步骤S402、步骤S403以及步骤S404。可选的,处理模块151用于支持终端150执行图6中的步骤S401、步骤S402A、步骤S402B、步骤S402C、步骤S403以及步骤S404。可选的,处理模块151用于支持终端150执行图8中的步骤S401、步骤S402A1、步骤S402B、步骤S402C、步骤S403以及步骤S404。可选的,处理模块151用于支持终端150执行图9中的步骤S401、步骤S402、步骤S403A中的T1和T2、步骤S403B、步骤S403C、步骤S403D以及步骤S404。可选的,处理模块151用于支持终端150执行图10中的步骤S401、步骤S402、步骤S403A中的T1、T2A、T2B、T2C和T2D、步骤S403B、步骤S403C、步骤S403D以及步骤S404。
其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件程序实现时,可以全部或部分地以计算机程序产品的形式来实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或者数据中心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可以用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带),光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。
尽管在此结合各实施例对本申请进行了描述,然而,在实施所要求保护的本申 请过程中,本领域技术人员通过查看所述附图、公开内容、以及所附权利要求书,可理解并实现所述公开实施例的其他变化。在权利要求中,“包括”(comprising)一词不排除其他组成部分或步骤,“一”或“一个”不排除多个的情况。单个处理器或其他单元可以实现权利要求中列举的若干项功能。相互不同的从属权利要求中记载了某些措施,但这并不表示这些措施不能组合起来产生良好的效果。
尽管结合具体特征及其实施例对本申请进行了描述,显而易见的,在不脱离本申请的精神和范围的情况下,可对其进行各种修改和组合。相应地,本说明书和附图仅仅是所附权利要求所界定的本申请的示例性说明,且视为已覆盖本申请范围内的任意和所有修改、变化、组合或等同物。显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (17)

  1. 一种颜色填充方法,其特征在于,所述方法包括:
    终端确定四边形图像的缺失区域,其中,所述四边形图像包括所述缺失区域和第一区域,所述缺失区域为所述四边形图像在拍摄图像外的区域,所述第一区域为所述四边形图像在所述拍摄图像中的区域;
    所述终端确定所述第一区域中与所述缺失区域相邻的第二区域;
    所述终端根据所述第二区域的颜色确定所述缺失区域的目标颜色;
    所述终端根据所述目标颜色填充所述缺失区域。
  2. 根据权利要求1所述的方法,其特征在于,所述终端确定所述第一区域中与所述缺失区域相邻的第二区域,包括:
    所述终端确定所述缺失区域与所述第一区域的公共边;
    所述终端确定所述第一区域中不在所述公共边上的至少一个点;
    所述终端根据所述公共边和所述至少一个点确定所述第二区域。
  3. 根据权利要求2所述的方法,其特征在于,所述终端确定所述缺失区域与所述第一区域的公共边,包括:
    所述终端根据第一边的第一端点和第二边的第二端点确定所述公共边,其中,所述第一边和所述第二边为构成所述第一区域的其中两条边,所述第一边和所述第二边的交点位于所述第一区域外,所述交点为所述缺失区域对应的所述四边形图像的缺失顶点,所述第一端点为所述第一边中距离所述缺失顶点较近的端点,所述第二端点为所述第二边中距离所述缺失顶点较近的端点。
  4. 根据权利要求3所述的方法,其特征在于,所述至少一个点包括第一点和第二点;其中,所述第一点为所述第一边上与所述第一端点的距离为||L11||=T1*||L1||的点,所述第二点为所述第二边上与所述第二端点的距离为||L21||=T2*||L2||的点,L11表示所述第一端点和所述第一点之间的距离,0<T1<1,||L1||表示所述第一边的长度,L21表示所述第二端点和所述第二点之间的距离,0<T2<1,||L2||表示所述第二边的长度。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述终端根据所述第二区域的颜色确定所述缺失区域的目标颜色,包括:
    所述终端对于所述第二区域的红绿蓝RGB色彩空间的r通道、g通道和b通道,均按照下面针对r通道的操作处理:
    所述终端确定所述第二区域的RGB色彩空间的r通道的灰度直方图Hr
    所述终端根据所述r通道的灰度直方图Hr确定所述第二区域的r通道的灰度加权平均值Vr
    在所述终端对于r通道、g通道和b通道,均按照上面针对r通道的操作进行处理后,所述终端根据所述r通道的加权平均值Vr、所述g通道的灰度加权平均值Vg和所述b通道灰度的加权平均值Vb,确定所述缺失区域的主灰度值(Vr,Vg,Vb);
    所述终端根据所述主灰度值(Vr,Vg,Vb)确定所述缺失区域的目标颜色。
  6. 根据权利要求5所述的方法,其特征在于,所述终端根据所述r通道的灰度直方图Hr确定所述第二区域的r通道的灰度加权平均值Vr,包括:
    所述终端获取所述灰度直方图Hr中概率最大的灰度级Gr,max
    所述终端确定所述概率最大的灰度级Gr,max的临近区间为[Gr,1,Gr,2],其中,Gr,max∈[Gr,1,Gr,2],Gr,1∈[0,255],Gr,2∈[0,255];
    所述终端根据第一预设公式,确定所述概率最大的灰度级Gr,max的临近区间内所有灰度级的概率总和Sr
    所述终端根据所述Sr以及第二预设公式,确定所述第二区域的RGB色彩空间的r通道的灰度加权平均值Vr
    其中,所述第一预设公式包括:
    Figure PCTCN2017081301-appb-100001
    x∈[Gr,1,Gr,2];
    所述第二预设公式包括:
    Figure PCTCN2017081301-appb-100002
    x∈[Gr,1,Gr,2];
    其中,Hr'(x)=Hr(x)/Sr,Hr(x)表示表示r通道的灰度直方图中灰度级为x的灰度的概率值,H'r(x)表示对Hr(x)归一化,∑表示对区间上的所有值求和。
  7. 根据权利要求6所述的方法,其特征在于,Gr,max-Gr,1=Gr,2-Gr,max
  8. 一种终端,其特征在于,所述终端包括:确定模块和填充模块;
    所述确定模块用于:
    确定四边形图像的缺失区域,其中,所述四边形图像包括所述缺失区域和第一区域,所述缺失区域为所述四边形图像在拍摄图像外的区域,所述第一区域为所述四边形图像在所述拍摄图像中的区域;
    确定所述第一区域中与所述缺失区域相邻的第二区域;
    根据所述第二区域的颜色确定所述缺失区域的目标颜色;
    所述填充模块用于:
    根据所述目标颜色填充所述缺失区域。
  9. 根据权利要求8所述的终端,其特征在于,所述确定模块具体用于:
    确定所述缺失区域与所述第一区域的公共边;
    确定所述第一区域中不在所述公共边上的至少一个点;
    根据所述公共边和所述至少一个点确定所述第二区域。
  10. 根据权利要求9所述的终端,其特征在于,所述确定模块具体用于:
    根据第一边的第一端点和第二边的第二端点确定所述公共边,其中,所述第一边和所述第二边为构成所述第一区域的其中两条边,所述第一边和所述第二边的交点位于所述第一区域外,所述交点为所述缺失区域对应的所述四边形图像的缺失顶点,所述第一端点为所述第一边中距离所述缺失顶点较近的端点,所述第二端点为所述第二边中距离所述缺失顶点较近的端点。
  11. 根据权利要求10所述的终端,其特征在于,所述至少一个点包括第一点和第二点;其中,所述第一点为所述第一边上与所述第一端点的距离为||L11||=T1*||L1||的点,所述第二点为所述第二边上与所述第二端点的距离为||L21||=T2*||L2||的点,L11表示所述第一端点和所述第一点之间的距离,0<T1<1,||L1||表示所述第一边的长度,L21表示所述第二端点和所述第二点之间的距离,0<T2<1,||L2||表示所述第二边的长度。
  12. 根据权利要求8-11任一项所述的终端,其特征在于,所述确定模块具体用于:
    对于所述第二区域的RGB色彩空间的r通道、g通道和b通道,均按照下面针对r通道的操作处理:
    确定所述第二区域的RGB色彩空间的r通道的灰度直方图Hr
    根据所述r通道的灰度直方图Hr确定所述第二区域的r通道的灰度加权平均值Vr
    在对于r通道、g通道和b通道,均按照上面针对r通道的操作进行处理后,根据所述r通道的加权平均值Vr、所述g通道的灰度加权平均值Vg和所述b通道灰度的加权平均值Vb,确定所述缺失区域的主灰度值(Vr,Vg,Vb);
    根据所述主灰度值(Vr,Vg,Vb)确定所述缺失区域的目标颜色。
  13. 根据权利要求12所述的终端,其特征在于,所述确定模块具体用于:
    获取所述灰度直方图Hr中概率最大的灰度级Gr,max
    确定所述概率最大的灰度级Gr,max的临近区间为[Gr,1,Gr,2],其中,Gr,max∈[Gr,1,Gr,2],Gr,1∈[0,255],Gr,2∈[0,255];
    根据第一预设公式,确定所述概率最大的灰度级Gr,max的临近区间内所有灰度级的概率总和Sr
    根据所述Sr以及第二预设公式,确定所述第二区域的RGB色彩空间的r通道的灰度加权平均值Vr
    其中,所述第一预设公式包括:
    Figure PCTCN2017081301-appb-100003
    x∈[Gr,1,Gr,2];
    所述第二预设公式包括:
    Figure PCTCN2017081301-appb-100004
    x∈[Gr,1,Gr,2];
    其中,Hr'(x)=Hr(x)/Sr,Hr(x)表示表示r通道的灰度直方图中灰度级为x的灰度的概率值,H'r(x)表示对Hr(x)归一化,∑表示对区间上的所有值求和。
  14. 根据权利要求13所述的终端,其特征在于,Gr,max-Gr,1=Gr,2-Gr,max
  15. 一种终端,其特征在于,包括:处理器、存储器和通信接口;
    所述存储器用于存储计算机执行指令,当所述终端运行时,所述处理器执行所述存储器存储的所述计算机执行指令,以使所述终端执行如权利要求1-7中任意一项所述的颜色填充方法。
  16. 一种计算机可读存储介质,其特征在于,包括计算机指令,当其在计算机上运行时,使得计算机执行如权利要求1-7任意一项所述的颜色填充方法。
  17. 一种包含指令的计算机程序产品,其特征在于,当其在计算机上运行时,使得计算机执行如权利要求1-7中任意一项所述的颜色填充方法。
PCT/CN2017/081301 2017-01-18 2017-04-20 颜色填充方法及终端 WO2018133227A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201780082279.4A CN110140149B (zh) 2017-01-18 2017-04-20 颜色填充方法及终端

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710036812 2017-01-18
CN201710036812.5 2017-01-18

Publications (1)

Publication Number Publication Date
WO2018133227A1 true WO2018133227A1 (zh) 2018-07-26

Family

ID=62907662

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/081301 WO2018133227A1 (zh) 2017-01-18 2017-04-20 颜色填充方法及终端

Country Status (2)

Country Link
CN (1) CN110140149B (zh)
WO (1) WO2018133227A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102572205A (zh) * 2011-12-27 2012-07-11 方正国际软件有限公司 一种图像处理方法、装置及***
CN104461439A (zh) * 2014-12-29 2015-03-25 联想(北京)有限公司 一种信息处理方法及电子设备
US20160217557A1 (en) * 2015-01-26 2016-07-28 Sony Corporation Structure analysis method for recovering missing structures in an image after object removal
CN105989582A (zh) * 2015-03-19 2016-10-05 索尼公司 将频率分解用于合成区域中的更好颜色一致性

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521869B (zh) * 2011-09-30 2013-12-25 北京航空航天大学 一种几何特征引导的三维模型表面纹理空洞填补方法
CN102438108B (zh) * 2011-10-13 2014-08-20 江苏尚阳数字科技有限公司 一种影片处理方法
CN102497489B (zh) * 2011-12-05 2015-11-18 优视科技有限公司 图像压缩方法、图像压缩装置和移动终端
CN102938057B (zh) * 2012-10-19 2015-09-23 株洲南车时代电气股份有限公司 一种车辆阴影消除方法及装置
JP6230268B2 (ja) * 2013-05-23 2017-11-15 キヤノン株式会社 画像処理装置、画像処理方法およびプログラム
CN104951195B (zh) * 2014-03-24 2017-12-01 珠海金山办公软件有限公司 一种电子文档阅读区域的变换方法及装置
CN104636726B (zh) * 2015-02-05 2019-05-21 努比亚技术有限公司 一种图像色彩识别方法、装置及终端
CN105704557B (zh) * 2016-01-26 2018-06-19 天脉聚源(北京)科技有限公司 一种识别节目中图标的方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102572205A (zh) * 2011-12-27 2012-07-11 方正国际软件有限公司 一种图像处理方法、装置及***
CN104461439A (zh) * 2014-12-29 2015-03-25 联想(北京)有限公司 一种信息处理方法及电子设备
US20160217557A1 (en) * 2015-01-26 2016-07-28 Sony Corporation Structure analysis method for recovering missing structures in an image after object removal
CN105989582A (zh) * 2015-03-19 2016-10-05 索尼公司 将频率分解用于合成区域中的更好颜色一致性

Also Published As

Publication number Publication date
CN110140149B (zh) 2022-04-05
CN110140149A (zh) 2019-08-16

Similar Documents

Publication Publication Date Title
US11373275B2 (en) Method for generating high-resolution picture, computer device, and storage medium
US9451173B2 (en) Electronic device and control method of the same
US7574069B2 (en) Retargeting images for small displays
US9105122B2 (en) Image processing apparatus and image processing method
US7652717B2 (en) White balance correction in digital camera images
JP7175197B2 (ja) 画像処理方法および装置、記憶媒体、コンピュータ装置
WO2021083059A1 (zh) 一种图像超分重建方法、图像超分重建装置及电子设备
US8284271B2 (en) Chroma noise reduction for cameras
WO2021115136A1 (zh) 视频图像的防抖方法、装置、电子设备和存储介质
WO2020135234A1 (zh) 一种图像处理方法及装置
WO2017084255A1 (zh) 实时视频增强方法、终端和非易失性计算机可读存储介质
WO2021135683A1 (zh) 一种显示终端调整方法及显示终端
CN112218065B (zh) 图像白平衡方法、***、终端设备及存储介质
CN111598777A (zh) 天空云图的处理方法、计算机设备和可读存储介质
WO2018058476A1 (zh) 一种图像校正方法及装置
US20200167933A1 (en) Image processing apparatus, image processing method, and a non-transitory computer readable storage medium
JP2004362443A (ja) パラメータ決定方式
US20170310872A1 (en) Image dynamic range adjustment method, terminal, and storage medium
WO2018133227A1 (zh) 颜色填充方法及终端
JPWO2019041842A5 (zh)
WO2020259444A1 (zh) 一种图像处理方法及相关设备
CN114792283A (zh) 一种图像处理方法、装置、设备及计算机可读存储介质
CN115334245A (zh) 一种图像矫正方法、装置、电子设备及存储介质
WO2022089211A1 (zh) 一种画质调整方法及装置
WO2020035723A1 (zh) 一种识别逆光区域方法、装置和设备/终端/服务器

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17893249

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17893249

Country of ref document: EP

Kind code of ref document: A1