CN114022390B - Star burst adding method, star burst adding device, computer equipment and readable storage medium - Google Patents
Star burst adding method, star burst adding device, computer equipment and readable storage medium Download PDFInfo
- Publication number
- CN114022390B CN114022390B CN202111371093.5A CN202111371093A CN114022390B CN 114022390 B CN114022390 B CN 114022390B CN 202111371093 A CN202111371093 A CN 202111371093A CN 114022390 B CN114022390 B CN 114022390B
- Authority
- CN
- China
- Prior art keywords
- starburst
- highlight
- gray
- size
- image
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/90—Dynamic range modification of images or parts thereof
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/20—Image enhancement or restoration using local operators
- G06T5/30—Erosion or dilatation, e.g. thinning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/40—Image enhancement or restoration using histogram techniques
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20024—Filtering details
- G06T2207/20032—Median filtering
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
The embodiment of the invention discloses a starburst adding method, a starburst adding device, computer equipment and a readable storage medium. The method comprises the following steps: preprocessing the processed picture to obtain the distribution of all gray values in the gray image corresponding to the processed picture; determining the number of highlight points according to a preset proportion threshold value and the size of a gray level image, and calculating a segmentation threshold value to obtain a segmentation threshold value of a highlight region; performing binarization processing on the gray level image according to the segmentation threshold value, and performing expansion processing on the binarization result to obtain a highlight region and a highlight point; carrying out normalization processing on the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor; and determining the size of the starburst material according to the intensity change factor, and adding the corresponding size of the starburst material to a highlight point corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect picture. The method optimizes the display of the starburst effect and improves the user experience.
Description
Technical Field
The embodiment of the invention relates to the field of image processing, in particular to a starburst adding method, a starburst adding device, computer equipment and a readable storage medium.
Background
The starburst effect is that a starburst lens is added in front of a camera lens to enable a shot photo to generate a starburst effect, different types of longitudinal and transverse linear stripes are carved on glass of the starburst lens through an etching method, and bright points in a shot scene can be diffracted under the action of a point light source, so that each light source point on the shot photo emits the light burst of a specific wire harness.
With the development of the era, the mode of obtaining the beautifying effect through a filter lens is gradually replaced by a mode of a beauty drawing software, the starburst can bring dream and romantic effects to the whole picture, the scene use rate in night scene shooting and the like is very high, in order to meet the requirements in the aspect, a starburst filter algorithm appears, and the glauber-light four-shot effect generated by the starburst is simulated through the realization of the algorithm. At present, the common starburst filter effect on the market is low in overall brightness of a video or an image, and the starburst effect cannot be seen or added in a highlight area scene where the whole picture is not particularly highlighted, so that the use experience of a user is poor.
Disclosure of Invention
The embodiment of the invention provides a starburst adding method, a starburst adding device, computer equipment and a readable storage medium, which aim to solve the problem of poor starburst effect in the prior art.
In a first aspect, an embodiment of the present invention provides a method for adding starburst, including:
carrying out gray processing on the processed picture to obtain a gray image of the processed picture, and carrying out histogram statistics on the gray image to obtain the distribution of all gray values in the gray image;
determining the number of highlight points according to a preset proportion threshold value and the size of the gray level image, and calculating a segmentation threshold value according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region;
performing binarization processing on the gray level image according to the segmentation threshold value, and performing expansion processing on a binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region;
Screening a target light area from the highlight area according to a preset area threshold;
Normalizing the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor;
And determining the size of the starburst material according to the intensity change factor, and adding the starburst material with the corresponding size to the highlight point corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect picture.
In a second aspect, an embodiment of the present invention provides a starburst adding device, including:
The statistics module is used for carrying out gray processing on the processed picture to obtain a gray image of the processed picture, and carrying out histogram statistics on the gray image to obtain the distribution of all gray values in the gray image;
The calculation module is used for determining the number of highlight points according to a preset proportion threshold value and the size of the gray level image, and carrying out segmentation threshold value calculation according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region;
the binarization module is used for carrying out binarization processing on the gray level image according to the segmentation threshold value and carrying out expansion processing on a binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region;
The screening module is used for screening the target light area from the highlight area according to a preset area threshold value;
the normalization module is used for carrying out normalization processing on the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor;
And the starburst adding module is used for determining the size of the starburst material according to the intensity change factor, and adding the corresponding size of the starburst material to the highlight points corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect diagram.
In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the starburst adding method described in the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program when executed by a processor causes the processor to perform the starburst adding method described in the first aspect above.
The embodiment of the invention provides a starburst adding method, a starburst adding device, computer equipment and a storage medium. Gray processing is carried out on a processed picture to obtain a gray image of the processed picture, histogram statistics is carried out on the gray image to obtain distribution of all gray values in the gray image; determining the number of highlight points according to a preset proportion threshold value and the size of a gray level image, and calculating a segmentation threshold value according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region; performing binarization processing on the gray level image according to the segmentation threshold value, and performing expansion processing on the binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region; screening a target light region from the highlight region according to a preset area threshold value; carrying out normalization processing on the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor; and determining the size of the starburst material according to the intensity change factor, and adding the corresponding size of the starburst material to a highlight point corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect picture. According to the method, gray level processing and histogram statistics are carried out on the processed picture, then segmentation threshold calculation is carried out, a highlight region and highlight points in the processed picture are determined, the size of the added starburst is adjusted according to the intensity change factor of the highlight points, the adjustment of the starburst size according to the brightness difference of the highlight points is achieved, the display of the starburst effect is optimized, and user experience is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a starburst adding method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of step 130 in FIG. 1;
FIG. 3 is a schematic view of a sub-flow of an embodiment of a method for adding starburst according to an embodiment of the present invention;
fig. 4 is a schematic block diagram of a starburst adding device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
In the prior art, a target object in a video is tracked by using a target tracking frame with a fixed size, and the size of the target tracking frame should be the best size closest to the target object. In general, the size of the target object in the target tracking frame of each frame of image generally changes with time, for example: the zoom-in or zoom-out of the lens changes the display size of the target object in the target tracking frame. If the target object is selected only by the target tracking frame with a fixed size, when the size of the selected target object is larger or smaller than that of the target tracking frame, the feature value extracted from the target object by the target tracking frame in other subsequent applications will deviate, so that the subsequent calculation result is wrong.
Therefore, a variable target tracking frame has been proposed and applied to a variable target object. The target tracking frame with corresponding size is adjusted according to the size of the target object in each frame of image, so that the target tracking frame is easy to change drastically. Therefore, adjusting the change range of the target tracking frame is a technical problem to be solved.
According to the method provided by the embodiment of the invention, the attribute of the target tracking frame is subjected to filtering processing by sequentially using median filtering processing and mean filtering processing, so that the position of the target tracking frame is smoothly moved, and the size of the target tracking frame is smooth when the size of the target tracking frame is changed according to the size of the tracked target.
Referring to fig. 1, a flow chart of a starburst adding method according to an embodiment of the invention includes steps S110 to S160.
Step S110, carrying out gray processing on a processed picture to obtain a gray image of the processed picture, and carrying out histogram statistics on the gray image to obtain the distribution of all gray values in the gray image;
In this embodiment, the processed picture is subjected to graying processing, i.e., the processed picture is converted into a gray image. In the gray image, the pixel with larger gray value is brighter, and the pixel with smaller gray value is darker. Since the sensitivity of the human eye to green is highest and the sensitivity to blue is lowest, different weights are required to be respectively adopted for the three RGB color channels to carry out weighted average so as to obtain a reasonable gray image. The adopted graying calculation formula is as follows:
Gray = 0.299 * R + 0.578 * G + 0.114 * B
In the formula, gray represents the Gray value of the pixel after calculation, R represents the red channel pixel value of the pixel of the processed picture, G represents the green channel pixel value, B represents the blue channel pixel value, and the value ranges of Gray, R, G, B are all 0-255.
And then carrying out histogram statistics on the gray level image, and carrying out statistics on the distribution of all gray level values in the gray level image, wherein the number of pixel points, the maximum gray level value and the minimum gray level value corresponding to each gray level value in the whole image can be known from the statistical result. For convenience of storage, for an image with a gray value range of 0-255, a one-dimensional unsigned integer array with an array length of 256 may be used to store the number of pixels corresponding to each gray value, i.e. the subscript of the array represents the gray value, and the array represents the number of pixels of the gray value. For example, the gray value range of the 8bit image is 0 to 255.
Step S120, determining the number of highlight points according to a preset proportion threshold value and the size of the gray level image, and calculating a segmentation threshold value according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region;
In this embodiment, a proportion threshold is set, the number of highlight points is determined according to the set proportion threshold and the size of the gray scale image, and the segmentation threshold calculation is performed according to the number of highlight points and the distribution of all gray scale values in the gray scale image, so as to obtain the segmentation threshold of the highlight region. For example, if the obtained division threshold is 0.05%, the pixel of the brightest first 0.05% in the gray-scale image is determined to be a highlight point.
Further, calculating the segmentation threshold specifically includes: the method comprises the steps of marking a processed picture, obtaining the size of the processed picture, and then calculating the number of high-light spots according to the following formula based on the size of the processed picture and a preset proportion threshold value:
highlightAmount = srcWidth * srcHeight * threshold;
Wherein highlightAmount denotes the number of highlight points, srcWidth denotes the width of the processed picture, SRCHEIGHT denotes the height of the processed picture, and threshold denotes a proportional threshold;
And after the number of the high-light spots is obtained, accumulating the number of the corresponding pixel points in the gray level image from large to small, and stopping accumulating when the accumulated value is larger than or equal to the number of the high-light spots, wherein the gray level value corresponding to the pixel points at the stopping time is used as a segmentation threshold value. The set proportion threshold value can be customized by a user, the smaller the proportion threshold value is, the smaller the proportion occupied by the highlight points is, the larger the calculated segmentation threshold value is, the more the highlight points in the gray level image are, and the quantity of starburst materials is controlled in the subsequent addition of the starburst materials by using the segmentation threshold value.
Step S130, carrying out binarization processing on the gray level image according to the segmentation threshold value, and carrying out expansion processing on a binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region;
In this embodiment, after obtaining the segmentation threshold based on the above steps, binarizing the gray image according to the segmentation threshold to obtain a binarized image; and then expanding the binarized image to obtain a highlight region and a highlight point. The central point of the highlight region is the highlight point.
As shown in fig. 2, in an embodiment, step S130 includes:
Step S210, carrying out binarization processing on the gray level image based on the segmentation threshold value to obtain a binarized image, wherein all pixel points larger than or equal to the segmentation threshold value are assigned 255, and all other pixel points are assigned 0;
step S220, performing expansion processing on the binarized image, and performing contour edge searching on the expanded binarized image to obtain the outermost contour point of each white area on the binarized image;
And step S230, fitting a minimum outer-wrapping rectangle of the corresponding white area according to the outermost contour point of each white area, and taking the minimum outer-wrapping rectangle as the highlight area and the central point of the minimum outer-wrapping rectangle as the highlight point.
In this embodiment, the specific process of acquiring the highlight region and the highlight point is as follows: and carrying out binarization processing on the gray level image based on the segmentation threshold value to obtain a binarized image with only black and white colors. Wherein all pixel points larger than or equal to the segmentation threshold value are assigned 255 and represented by white; the remaining pixels are all assigned 0's, represented in black. Then expanding the binarized image, and searching the contour edge of the expanded binarized image to obtain the outermost contour point of each white area on the binarized image; and fitting a minimum outer-wrapping rectangle of the corresponding white region according to the outermost contour point of each white region, and taking the minimum outer-wrapping rectangle as a highlight region and the central point of the minimum outer-wrapping rectangle as a highlight point. The expansion treatment is to connect adjacent highlight areas in an image, the size of a convolution kernel of the expansion treatment is recommended to be 5-11, the convolution kernel is preferably 9, the adjacent highlight areas can not be connected if the convolution kernel is too small, and the adjacent highlight areas can be easily connected into a large piece if the convolution kernel is too large.
Step S140, screening out a target light area from the highlight area according to a preset area threshold;
in this embodiment, the highlight region is screened according to the preset area threshold, and the highlight region with the area larger than the preset area threshold is screened, that is, the highlight region with the area smaller than the preset area threshold is used as the target highlight region. For example, the processed picture includes a white wall, but the brightness value of the white wall is relatively high, the processed picture may be judged as a highlight region, but the user does not want to add the starburst effect to the white wall, and at this time, the area of the highlight region can be screened, and the white wall region can be filtered, so that the target light region can be obtained.
Step S150, carrying out normalization processing on the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor;
In this embodiment, in order to make the starburst in the whole picture have different sizes, and combine with the normal visual effect, the brighter the place, the stronger the emitted light burst, the size of the starburst material is set, and the size of the starburst material is adjusted accordingly according to the brightness of the highlight point. The intensity of the highlight is expressed by an intensity variation factor, and the brighter the highlight is, the larger the corresponding intensity variation factor is. It should be noted that the intensity change factor is obtained by normalizing the intensity value of the highlight point and the maximum intensity value in the gray-scale image.
The specific process of calculating the intensity change factor is as follows: determining a position of a highlight corresponding to the target light area from the gray scale image, and determining a target gray scale value grayValue of the highlight based on the position of the highlight; then searching a maximum gray value maxGrayValue in the gray image; carrying out normalization processing on the gray value of the high light spot according to a formula to obtain an intensity change factor:
factor=(grayValue-hightlightThreshold)/(maxGrayVlalue-hightlightThreshold),
wherein highlightThreshold is the segmentation threshold.
And step 160, determining the size of the starburst material according to the intensity change factor, and adding the starburst material with the corresponding size to the highlight points corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect diagram.
In this embodiment, in order to make the starburst effect more attractive, the size of the starburst material is calculated based on the intensity variation factor of the highlight points, and the starburst material with a corresponding size is added to the highlight points corresponding to the processed picture according to the calculated starburst size, so as to obtain a starburst effect diagram.
As shown in fig. 3, in an embodiment, after step S150, before step S160, the method includes:
Step S310, calculating Euclidean distance between any two high light spots, and judging whether the Euclidean distance is smaller than a preset distance threshold value;
Step S321, if yes, discarding one of the high-light spots;
In step S322, if not, two highlight points are reserved.
In this embodiment, in order to control the density of starburst materials, a distance threshold is preset to prevent the starburst materials from being too dense, the euclidean distance between any two high light points of all high light points is calculated, whether the euclidean distance between any two high light points is smaller than the preset distance threshold is judged, and if the euclidean distance between any two high light points is smaller than the preset distance threshold, one high light point is discarded to prevent the high light points within a certain range from being too dense; if the Euclidean distance between any two high light spots is larger than the preset distance threshold, the distance between the two high light spots in a certain range is large enough, and the condition of dense is not caused, so that the two high light spots are reserved.
Further, star burst material is obtained, wherein the star burst material can be a four-burst star, a six-burst star or an eight-burst star, and the like, and the star burst material is a four-channel 32bit picture containing an alpha channel, and the size of the star burst material can be 200 x 200 or 100 x 100. Setting a mixing area mixWidth x mixHeight for adding starburst materials to a processed picture, wherein the mixing area is adaptively adjusted according to the size of the processed picture, the larger the processed picture is, the larger the mixing area is, the more harmonious the starburst effect is presented, and the phenomenon that the original picture is large and the starburst effect is small, so that the starburst effect is not obvious is avoided. Then, based on the intensity change factor of the highlight point, calculating the star burst material size of the current highlight point according to the following formula:
dstWidth = mixWidth * (1.0 + size + factor)
dstHeight = mixHeight * (1.0 + size + factor);
Wherein mixWidth x mixHeight is a preset mixing region size, dstWidth x DSTHEIGHT is a starburst material size, size is a control parameter, and factor is an intensity variation factor; the size is used for controlling the size of the starburst material, and the factor ranges from 0.0 to 1.0.
Then, the size of the starburst material is adjusted to the size of the starburst material corresponding to the current highlight point, the starburst material is rotated according to the rotation angle parameter, and then the following mixing formula is adopted to mix the starburst material with the processed picture in an RGB channel:
addColor = min(srcColor + textureColor, 255)
Wherein, the min function is used for preventing the mixed color value from crossing the boundary, when the min function is larger than 255, the mixed color value is equal to 255, the mixed pixel value addColor is 0-255, the srccolor is the pixel value of the processed picture, and textureColor is the pixel value of the used starburst material;
Finally, alpha mixing is carried out by utilizing an alpha channel of the starburst material according to the following formula, and the starburst adding treatment of the current highlight point is completed:
dstColor = addColor * alpha + srcColor * (1.0 - alpha)
Wherein: dstColor denotes a final output pixel value, addColor denotes a pixel value obtained by mixing a processed picture and a starburst material in an RGB channel, alpha is a normalized value of an alpha channel of the starburst material, and the range of alpha is 0.0-1.0.
Further, taking the picture output after the current highlight point starburst adding process as the input of the next highlight point starburst adding process, and continuing the next highlight point starburst adding process until all the highlight points finish the starburst adding process, so as to obtain a starburst effect picture. N center points are needed to be added for N times, N starburst can be displayed in the processed picture, the size of each starburst is related to the intensity change factor of the high-light point, the effect of different sizes of the starburst is displayed, and the starburst effect is attractive.
According to the method, gray level processing and histogram statistics are carried out on the processed picture, then segmentation threshold calculation is carried out, a highlight region and highlight points in the processed picture are determined, the size of the added starburst is adjusted according to the intensity change factor of the highlight points, the adjustment of the starburst size according to the brightness difference of the highlight points is achieved, the display of the starburst effect is optimized, and user experience is improved.
The embodiment of the invention also provides a starburst adding device which is used for executing any embodiment of the starburst adding method. Specifically, referring to fig. 4, fig. 4 is a schematic block diagram of a star burst adding device according to an embodiment of the present invention. The star burst adding device 100 may be configured in a server.
As shown in fig. 4, the starburst adding device 100 includes a statistics module 110, a calculation module 120, a binarization module 130, a screening module 140, a normalization module 150, and a starburst adding module 160.
The statistics module 110 is configured to perform gray level processing on a processed picture to obtain a gray level image of the processed picture, and perform histogram statistics on the gray level image to obtain distribution of all gray level values in the gray level image;
the calculation module 120 is configured to determine the number of highlight points according to a preset proportion threshold and the size of the gray scale image, and calculate a segmentation threshold according to the number of highlight points and the distribution of all gray scale values in the gray scale image, so as to obtain a segmentation threshold of a highlight region;
The binarization module 130 is configured to perform binarization processing on the gray level image according to the segmentation threshold, and perform expansion processing on the binarization result to obtain at least one highlight region and a highlight point corresponding to each highlight region;
The screening module 140 is configured to screen a target light area from the highlight areas according to a preset area threshold;
The normalization module 150 is configured to normalize the gray value of the highlight point according to a relationship between the gray value of the highlight point and a maximum gray value in the gray image, so as to obtain an intensity variation factor;
and the starburst adding module 160 is configured to determine a starburst material size according to the intensity variation factor, and add the starburst material with a corresponding size to the highlight point corresponding to the processed picture according to the starburst material size, so as to obtain a starburst effect diagram.
In one embodiment, the computing module 120 includes:
The first calculating unit is used for obtaining the size of the processed picture, and calculating the quantity of the high light spots according to the following formula:
highlightAmount = srcWidth * srcHeight * threshold;
wherein highlightAmount denotes the number of highlight points, srcWidth denotes the width of the processed picture, SRCHEIGHT denotes the height of the processed picture, and threshold denotes a scale threshold.
And the second calculation unit is used for carrying out traversal accumulation on the number of the pixel points in the direction from large to small of all gray values in the gray image, stopping accumulation when the accumulated value is greater than or equal to the number of the high light points, and taking the gray value corresponding to the pixel points at the stopping time as the segmentation threshold value.
In one embodiment, the binarization module 130 includes:
the binarization unit is used for carrying out binarization processing on the gray level image based on the segmentation threshold value to obtain a binarized image, wherein all pixel points larger than or equal to the segmentation threshold value are assigned 255, and all other pixel points are assigned 0;
performing expansion processing on the binarized image, and performing contour edge searching on the expanded binarized image to obtain the outermost contour point of each white area on the binarized image;
And fitting a minimum outer-wrapping rectangle of the corresponding white area according to the outermost contour point of each white area, and taking the minimum outer-wrapping rectangle as the highlight area and the central point of the minimum outer-wrapping rectangle as the highlight point.
In one embodiment, normalization module 150 includes:
a searching unit, configured to determine a target gray value grayValue of the target highlight point corresponding to the target highlight region based on the gray image, and search a maximum gray value maxGrayValue in the gray image;
The third calculation unit is configured to normalize the gray value of the highlight point according to the following formula, to obtain an intensity variation factor:
factor=(grayValue-hightlightThreshold)/(maxGrayVlalue-hightlightThreshold),
wherein highlightThreshold is the segmentation threshold.
In one embodiment, the starburst adding device 100 further comprises:
The judging module is used for calculating the Euclidean distance between any two high light spots and judging whether the Euclidean distance is smaller than a preset distance threshold value or not;
The discarding module is used for discarding one of the high-light points if the Euclidean distance is less than the preset distance threshold value;
And the reservation module is used for reserving the two high light spots if the Euclidean distance is larger than the preset distance threshold value.
In one embodiment, starburst adding module 160 includes:
a fourth calculation unit, configured to calculate the size of the starburst material of the current highlight dot according to the following formula:
dstWidth = mixWidth * (1.0 + size + factor)
dstHeight = mixHeight * (1.0 + size + factor);
Wherein mixWidth x mixHeight is a preset mixing region size, dstWidth x DSTHEIGHT is a starburst material size, size is a control parameter, and factor is an intensity variation factor;
And the channel mixing unit is used for adjusting the size of the starburst material corresponding to the current highlight point according to the size of the starburst material, rotating the starburst material according to the rotation angle parameter, mixing the starburst material with the RGB channel of the processed picture, and performing alpha mixing by utilizing the alpha channel of the starburst material to finish the starburst adding process of the current highlight point.
The embodiment of the invention also provides computer equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the starburst adding method when executing the computer program.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a non-volatile computer readable storage medium. The computer readable storage medium stores a computer program which, when executed by a processor, causes the processor to perform the starburst adding method as described above.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein. Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units is merely a logical function division, there may be another division manner in actual implementation, or units having the same function may be integrated into one unit, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units may be stored in a storage medium if implemented in the form of software functional units and sold or used as stand-alone products. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.
Claims (10)
1. A method of adding starburst, comprising:
carrying out gray processing on the processed picture to obtain a gray image of the processed picture, and carrying out histogram statistics on the gray image to obtain the distribution of all gray values in the gray image;
determining the number of highlight points according to a preset proportion threshold value and the size of the gray level image, and calculating a segmentation threshold value according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region;
performing binarization processing on the gray level image according to the segmentation threshold value, and performing expansion processing on a binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region;
Screening a target light area from the highlight area according to a preset area threshold;
Normalizing the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor;
And determining the size of the starburst material according to the intensity change factor, and adding the starburst material with the corresponding size to the highlight point corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect picture.
2. The method for adding starburst according to claim 1, wherein the determining the number of highlight points according to a preset ratio threshold and the size of the gray scale image, and calculating a segmentation threshold according to the number of highlight points and the distribution of all gray scale values in the gray scale image, to obtain a segmentation threshold of a highlight region, comprises:
The size of the processed picture is obtained, and the number of high-light spots is calculated according to the following formula:
highlightAmount = srcWidth * srcHeight * threshold;
Wherein highlightAmount denotes the number of highlight points, srcWidth denotes the width of the processed picture, SRCHEIGHT denotes the height of the processed picture, and threshold denotes a proportional threshold;
and carrying out traversal accumulation on the number of pixel points in the direction from large to small of all gray values in the gray image, stopping accumulation when the accumulated value is greater than or equal to the number of highlight points, and taking the gray value corresponding to the pixel point at the stopping time as the segmentation threshold.
3. The method of adding starburst according to claim 1, wherein the binarizing the gray-scale image according to the segmentation threshold and expanding the binarized result to obtain at least one highlight region and highlight points corresponding to each highlight region comprises:
Performing binarization processing on the gray level image based on the segmentation threshold value to obtain a binarized image, wherein all pixels larger than or equal to the segmentation threshold value are assigned 255, and all other pixels are assigned 0;
performing expansion processing on the binarized image, and performing contour edge searching on the expanded binarized image to obtain the outermost contour point of each white area on the binarized image;
And fitting a minimum outer-wrapping rectangle of the corresponding white area according to the outermost contour point of each white area, and taking the minimum outer-wrapping rectangle as the highlight area and the central point of the minimum outer-wrapping rectangle as the highlight point.
4. The method for adding starburst according to claim 1, wherein the normalizing the gray value of the highlight point according to the relationship between the gray value of the highlight point and the maximum gray value in the gray image to obtain the intensity variation factor comprises:
Determining a target gray value grayValue of a highlight point corresponding to the target highlight region based on the gray image, and searching a maximum gray value maxGrayValue in the gray image;
and carrying out normalization processing on the gray value of the high light spot according to the following formula to obtain an intensity change factor:
factor=(grayValue-hightlightThreshold)/(maxGrayVlalue-hightlightThreshold),
wherein highlightThreshold is the segmentation threshold.
5. The method for adding starburst according to claim 1, wherein the normalizing the gray level of the highlight point according to the relationship between the gray level of the highlight point and the maximum gray level in the gray level image, after obtaining an intensity variation factor, determining a starburst material size according to the intensity variation factor, and adding the starburst material with a corresponding size to the highlight point corresponding to the processed picture according to the starburst material size, before obtaining a starburst effect diagram, comprises:
calculating Euclidean distance between any two high light spots, and judging whether the Euclidean distance is smaller than a preset distance threshold value;
If yes, discarding one of the high-light spots;
if not, two highlight points are reserved.
6. The method for adding starburst according to claim 1, wherein determining the size of starburst material according to the intensity variation factor, and adding the corresponding size of starburst material to the highlight point corresponding to the processed picture according to the size of starburst material, to obtain a starburst effect figure, comprises:
the starburst material size of the current highlight point is calculated according to the following formula:
dstWidth = mixWidth * (1.0 + size + factor)
dstHeight = mixHeight * (1.0 + size + factor);
Wherein mixWidth x mixHeight is a preset mixing region size, dstWidth x DSTHEIGHT is a starburst material size, size is a control parameter, and factor is an intensity variation factor;
And adjusting the size of the starburst material corresponding to the current highlight point according to the size of the starburst material, rotating the starburst material according to the rotation angle parameter, mixing the starburst material with the processed picture in an RGB channel, and carrying out alpha mixing by utilizing an alpha channel of the starburst material to finish the starburst adding process of the current highlight point.
7. The method for adding starburst according to claim 1, wherein the determining the size of starburst material according to the intensity variation factor, and adding the corresponding size of starburst material to the highlight point corresponding to the processed picture according to the size of starburst material, to obtain a starburst effect figure, further comprises:
And taking the output result after the current highlight point starburst adding process as the input of the next highlight point starburst adding process, and continuing the next highlight point starburst adding process until all the highlight points finish the starburst adding process, thereby obtaining the starburst effect graph.
8. A starburst adding device, comprising:
The statistics module is used for carrying out gray processing on the processed picture to obtain a gray image of the processed picture, and carrying out histogram statistics on the gray image to obtain the distribution of all gray values in the gray image;
The calculation module is used for determining the number of highlight points according to a preset proportion threshold value and the size of the gray level image, and carrying out segmentation threshold value calculation according to the number of highlight points and the distribution of all gray level values in the gray level image to obtain a segmentation threshold value of a highlight region;
the binarization module is used for carrying out binarization processing on the gray level image according to the segmentation threshold value and carrying out expansion processing on a binarization result to obtain at least one highlight region and highlight points corresponding to each highlight region;
The screening module is used for screening the target light area from the highlight area according to a preset area threshold value;
the normalization module is used for carrying out normalization processing on the gray value of the highlight point according to the relation between the gray value of the highlight point and the maximum gray value in the gray image to obtain an intensity change factor;
And the starburst adding module is used for determining the size of the starburst material according to the intensity change factor, and adding the corresponding size of the starburst material to the highlight points corresponding to the processed picture according to the size of the starburst material to obtain a starburst effect diagram.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the starburst addition method of any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, causes the processor to perform the starburst addition method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111371093.5A CN114022390B (en) | 2021-11-18 | 2021-11-18 | Star burst adding method, star burst adding device, computer equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111371093.5A CN114022390B (en) | 2021-11-18 | 2021-11-18 | Star burst adding method, star burst adding device, computer equipment and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114022390A CN114022390A (en) | 2022-02-08 |
CN114022390B true CN114022390B (en) | 2024-07-26 |
Family
ID=80065176
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111371093.5A Active CN114022390B (en) | 2021-11-18 | 2021-11-18 | Star burst adding method, star burst adding device, computer equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114022390B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117726669B (en) * | 2023-03-30 | 2025-02-25 | 书行科技(北京)有限公司 | Image processing method and device, electronic device and computer readable storage medium |
CN116630478B (en) * | 2023-05-31 | 2024-09-03 | 深圳市闪剪智能科技有限公司 | Method, system and related equipment for adding special effect of light to illuminant in image |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104700109A (en) * | 2015-03-24 | 2015-06-10 | 清华大学 | Method and device for decomposing hyper-spectral intrinsic images |
CN105608664A (en) * | 2014-11-19 | 2016-05-25 | 深圳市腾讯计算机系统有限公司 | Photo processing method and terminal |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI764898B (en) * | 2016-08-03 | 2022-05-21 | 日商新力股份有限公司 | Information processing device, information processing method and program |
WO2020140198A1 (en) * | 2019-01-02 | 2020-07-09 | 深圳市邻友通科技发展有限公司 | Fingernail image segmentation method, apparatus and device, and storage medium |
CN110930329B (en) * | 2019-11-20 | 2023-04-21 | 维沃移动通信有限公司 | Starry sky image processing method and device |
-
2021
- 2021-11-18 CN CN202111371093.5A patent/CN114022390B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105608664A (en) * | 2014-11-19 | 2016-05-25 | 深圳市腾讯计算机系统有限公司 | Photo processing method and terminal |
CN104700109A (en) * | 2015-03-24 | 2015-06-10 | 清华大学 | Method and device for decomposing hyper-spectral intrinsic images |
Also Published As
Publication number | Publication date |
---|---|
CN114022390A (en) | 2022-02-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3862140B2 (en) | Method and apparatus for segmenting a pixelated image, recording medium, program, and image capture device | |
Rivera et al. | Content-aware dark image enhancement through channel division | |
US20030053692A1 (en) | Method of and apparatus for segmenting a pixellated image | |
US8923612B2 (en) | Image processing apparatus and method, and program | |
US8644638B2 (en) | Automatic localized adjustment of image shadows and highlights | |
US7916963B2 (en) | Method and apparatus for an intuitive digital image processing system that enhances digital images | |
US10672112B2 (en) | Method and system for real-time noise removal and image enhancement of high-dynamic range images | |
US6832000B2 (en) | Automatic segmentation-based grass detection for real-time video | |
EP1667066A1 (en) | Visual processing device, visual processing method, visual processing program, integrated circuit, display device, imaging device, and mobile information terminal | |
US8902328B2 (en) | Method of selecting a subset from an image set for generating high dynamic range image | |
EP1318475A1 (en) | A method and system for selectively applying enhancement to an image | |
CN114022390B (en) | Star burst adding method, star burst adding device, computer equipment and readable storage medium | |
US20140079319A1 (en) | Methods for enhancing images and apparatuses using the same | |
KR20150019985A (en) | Method and apparatus for dynamic range enhancement of an image | |
Lee et al. | Image contrast enhancement using classified virtual exposure image fusion | |
JP2010503056A (en) | Image enhancement method and apparatus | |
WO2009030596A1 (en) | Method for non-photorealistic rendering | |
WO2008102296A2 (en) | Method for enhancing the depth sensation of an image | |
KR100694153B1 (en) | Method and Apparatus for Image Processing based on a Mapping Function | |
US20100061656A1 (en) | Noise reduction of an image signal | |
KR100765760B1 (en) | Method and Apparatus for Darker Region Details using Image Global Information | |
Stange | Gradient Based Histogram Equalization of Thermal Infrared Images | |
CN117689593A (en) | Image processing method and device and electronic equipment | |
WO2023063938A1 (en) | Adjustment of pixels | |
Jeon et al. | Adaptive color balance algorithm for users' conveniences |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |