Image processing method and device and storage medium
By generating target masks and target area images and determining rounded corner images based on these images, the problems of low efficiency and poor effect of image rounded corner processing in the prior art are solved, and more efficient rounded corner image processing and better smoothness and anti-aliasing effects are achieved.
Patent Information
- Application Number
- CN202311396761.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-25
- Publication Date
- 2025-04-29
AI Technical Summary
When performing rounded corner processing on images, the processing time is long, the efficiency is low, and the rounded corner smoothness and anti-aliasing effect are poor.
By determining the target rounded corner information of the images to be processed, a target mask and a target area image are generated, and the rounded corner image is determined based on these images. This method uses pixel change information to improve the smoothness and anti-aliasing of rounded images.
Improves the rounded corner smoothness and anti-aliasing of rounded corner images, reducing image processing time, and thus improving processing efficiency.
Smart Images

Figure CN119904506A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of graphics processing technology, and in particular to an image processing method, device and storage medium. Background Art
[0002] In the related art, a method of tangent between a circle and a right angle or a Bezier curve method is used to round the corners of an image to be processed, thereby obtaining a rounded corner image of the image to be processed. However, when this method is used to round the corners of an image to be processed, the processing time may be long, the efficiency may be low, and the rounded corner smoothness and anti-aliasing effect of the rounded corner image obtained by processing may be poor. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides an image processing method, an apparatus and a storage medium to solve the problems existing in the related art.
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, the method comprising:
[0005] Determine target fillet information of the fillet to be drawn of the image to be processed;
[0006] According to the target rounded corner information, determine a target mask image and a target area image in the image to be processed, wherein the target mask image includes pixel change information of the rounded corner to be drawn, and the target area image is an area image in the image to be processed that needs to be rounded;
[0007] A rounded corner image of the image to be processed is determined according to the target area image and the target mask image.
[0008] Optionally, determining a target mask image according to the target fillet information includes:
[0009] The target mask image is determined according to the target fillet information and a preset relationship, wherein the preset relationship is used to characterize a preset corresponding relationship between the fillet information and the mask image.
[0010] Optionally, the preset relationship includes a preset level of fillet information and a corresponding mask map, and determining the target mask map according to the target fillet information and the preset relationship includes:
[0011] When the target rounded corner information belongs to the rounded corner information of the preset level, determining the target mask map according to the target rounded corner information and the rounded corner information of the preset level;
[0012] When the target rounded corner information does not belong to the rounded corner information of the preset level, two rounded corner information of the preset levels adjacent to the target rounded corner information are determined, and the target mask map is determined according to the two rounded corner information of the preset levels.
[0013] Optionally, the method further comprises:
[0014] Determine a curve that forms a closed area with a first side and a second side, wherein the first side and the second side are perpendicular to each other;
[0015] Performing segmentation processing on the curve to obtain a segmented curve;
[0016] Performing rasterization processing on the line segment curve to obtain a pixel change curve;
[0017] According to the pixel change curve, the mask image corresponding to the curve is determined.
[0018] Optionally, determining the mask image according to the pixel change curve includes:
[0019] The pixel values in the closed area enclosed by the pixel change curve, the first side and the second side are set to 1.
[0020] Optionally, determining the rounded corner image of the image to be processed according to the target area image and the target mask image includes:
[0021] For each first pixel position in the target area image, a second pixel position matching the first pixel position is determined in the target mask image, and the pixel value of the second pixel position is fused with the pixel value of the first pixel position to obtain a rounded image of the image to be processed.
[0022] Optionally, determining the target area image in the image to be processed according to the target rounded corner information includes:
[0023] Determining the vertices of the image to be processed;
[0024] According to the target rounded corner information, the image to be processed is divided into nine-square grid images by a nine-square grid method;
[0025] The target area image is determined according to the vertices and the nine-square grid image.
[0026] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing device, the device comprising a first determining module, a second determining module and a third determining module;
[0027] The first determination module is configured to determine target rounded corner information of a to-be-drawn rounded corner of the to-be-processed image;
[0028] The second determination module is configured to determine a target mask image and a target area image in the image to be processed according to the target rounded corner information, wherein the target mask image includes pixel change information of the rounded corner to be drawn, and the target area image is an area image in the image to be processed that needs to be rounded;
[0029] The third determination module is configured to determine the rounded corner image of the image to be processed according to the target area image and the target mask image.
[0030] Optionally, the second determining module is configured to:
[0031] The target mask image is determined according to the target fillet information and a preset relationship, wherein the preset relationship is used to characterize a preset corresponding relationship between the fillet information and the mask image.
[0032] Optionally, the preset relationship includes a preset level of rounded corner information and a corresponding mask map, and the second determining module is further configured to:
[0033] When the target rounded corner information belongs to the rounded corner information of the preset level, determining the target mask map according to the target rounded corner information and the rounded corner information of the preset level;
[0034] When the target rounded corner information does not belong to the rounded corner information of the preset level, two rounded corner information of the preset levels adjacent to the target rounded corner information are determined, and the target mask map is determined according to the two rounded corner information of the preset levels.
[0035] Optionally, the image processing device further includes:
[0036] A fourth determining module is configured to determine a curve that forms a closed area with the first side and the second side, wherein the first side and the second side are perpendicular to each other;
[0037] A first processing module is configured to perform segmentation processing on the curve to obtain a segmented curve;
[0038] A second processing module is configured to perform rasterization processing on the line segment curve to obtain a pixel change curve;
[0039] The fifth determination module is configured to determine the mask image corresponding to the curve according to the pixel change curve.
[0040] Optionally, the fifth determining module is further configured to:
[0041] The pixel values in the closed area enclosed by the pixel change curve, the first side and the second side are set to 1.
[0042] Optionally, the third determining module is configured to:
[0043] For each first pixel position in the target area image, a second pixel position matching the first pixel position is determined in the target mask image, and the pixel value of the second pixel position is fused with the pixel value of the first pixel position to obtain a rounded image of the image to be processed.
[0044] Optionally, the second determining module includes:
[0045] A first determination submodule is configured to determine the vertices of the image to be processed;
[0046] A region division module is configured to divide the image to be processed into nine-square grid images by a nine-square grid method according to the target rounded corner information;
[0047] The second determination submodule is configured to determine the target area image according to the vertices and the nine-square grid image.
[0048] According to a third aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:
[0049] processor;
[0050] a memory for storing processor-executable instructions;
[0051] Wherein, the processor is configured to: perform the steps of the image processing method provided in the first aspect of the present disclosure.
[0052] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the image processing method provided in the first aspect of the present disclosure are implemented.
[0053] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: a new image processing method is provided, which determines the target area image of the image to be processed and the target mask map with pixel change information of the rounded corners to be drawn according to the target rounded corner information of the image to be processed, and determines the rounded corner image of the image to be processed according to the target mask map and the target area image. In this way, by using the target mask map with pixel change information of the rounded corners to be drawn to determine the rounded corner image, the rounded corner smoothness and anti-aliasing of the rounded corner image can be improved, and the time for processing the image to be processed can be reduced, thereby improving the efficiency of processing the image to be processed.
[0054] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0056] Figure 1 It is a schematic diagram of calculating the coordinates of point E in the second related technology.
[0057] Figure 2 The figure is a flowchart of an image processing method according to an exemplary embodiment.
[0058] Figure 3 is a schematic diagram showing a preset relationship according to an exemplary embodiment.
[0059] Figure 4 is a schematic diagram of a mask image according to an exemplary embodiment.
[0060] Figure 5 It is a schematic diagram of enlarging pixel values of pixel points on a curve region image in a mask image according to an exemplary embodiment.
[0061] Figure 6 is a schematic diagram showing calculation of a target area image according to an exemplary embodiment.
[0062] Figure 7 is a schematic diagram showing calculation of a target area image according to an exemplary embodiment.
[0063] Figure 8 is a schematic diagram showing calculation of a target area image according to an exemplary embodiment.
[0064] Fig. 9 The figure is a schematic diagram showing how to divide an image to be processed into a nine-square grid according to an exemplary embodiment.
[0065] Fig.10 It is a schematic diagram of a terminal interface according to an exemplary embodiment.
[0066] Fig.11 The figure is a block diagram of an image processing device according to an exemplary embodiment.
[0067] Fig.12 The invention is a block diagram of a device for image processing according to an exemplary embodiment. DETAILED DESCRIPTION
[0068] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0069] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0070] Rounded rectangle mainly refers to an image whose four corners are replaced by arcs and connected to the edges of the rectangle. It can be widely used in various graphic interface display scenarios, such as graphic design scenarios, web design scenarios, user interface design scenarios, etc.
[0071] In the first related technology, when rounding the corners of a rectangular image, four circles with the same radius are usually used, and the four circles are tangent to the four right angles of the rectangle respectively, and then the tangent segments connecting the circles at each right angle are removed, so that a rounded image of the rectangular image can be obtained.
[0072] In the second related art, a rectangular image is usually rounded by fitting a third-order Bezier curve. Figure 1 As shown, when it is necessary to draw an arc curve from A to D, it is necessary to determine any coordinate point on the arc curve according to the AB line segment, the BC line segment and the CD line segment. The specific processing process includes: assuming that point E is any point on the arc curve from point A to point D, when the coordinate point E needs to be drawn, first determine point F on the AB line segment, point G on the BC line segment and point H on the CD line segment, connect point F and point G to form the FG line segment, and connect point G and point H to form the GH line segment. Then determine point I on the FG line segment and point J on the GH line segment, and connect point I and point J to form the IJ line segment. Finally, determine point E according to the IJ line segment.
[0073] The inventors found that in the first related technology, among the four rounded corners of the rounded image, although the tangent points of the curve and the straight line are continuously differentiable, the curvature of the curve at the tangent point is different from the curvature of the straight line at the tangent point, which leads to poor smoothness and anti-aliasing effect at the connection between the curve and the straight line, thereby reducing the user experience.
[0074] In the second related technology, each coordinate point on the arc curve needs to be calculated through three cycles, and these points are calculated when drawing, which increases the time for drawing the rounded corner curve and reduces processing efficiency.
[0075] Therefore, in order to solve the above problems, the present disclosure provides an image processing method, device and storage medium, which determine the rounded corner image based on the target mask image with pixel change information of the rounded corner to be drawn and the first target image area, thereby increasing the smoothness and anti-aliasing of the connection between the curves and straight lines in the rounded corner image, and reducing the time for drawing the rounded corner image, thereby improving the efficiency of rounding the image to be processed.
[0076] Figure 2 is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 As shown, the image processing method is applied in a terminal, comprising the following steps:
[0077] S201: Determine target fillet information of a fillet to be drawn in an image to be processed;
[0078] S202: determining a target mask image and a target region image in the image to be processed according to the target rounded corner information, wherein the target mask image includes pixel change information of the rounded corner to be drawn, and the target region image is a region image in the image to be processed that needs to be rounded;
[0079] S203: Determine a rounded corner image of the image to be processed according to the target area image and the target mask image.
[0080] For example, the image to be processed may be a rectangular image, which may be a square image or a rectangular image. The fillet to be drawn may be an arc segment of a circle or an arc segment of an ellipse, and the embodiments of the present disclosure do not specifically limit this. The target fillet information may be used to characterize the size of the target texture mapping. When the fillet to be drawn is an arc segment of a circle, the target fillet information is used to characterize the size of the circular radius of the target texture mapping, and when the fillet to be drawn is an arc segment of an ellipse, the target fillet information may be used to characterize the size of the major axis and the minor axis of the target texture mapping.
[0081] When it is necessary to perform rounded corner processing on an image to be processed, one image to be processed may correspond to one rounded corner to be drawn, or may correspond to multiple rounded corners to be drawn. When one image to be processed corresponds to one rounded corner to be drawn, the rounded corner to be drawn may correspond to a target rounded corner information. When one image to be processed corresponds to multiple rounded corners to be drawn, one rounded corner to be drawn may correspond to one target rounded corner information, and multiple rounded corners to be drawn may correspond to multiple target rounded corner information, and the multiple target rounded corner information may be the same or different.
[0082] Then, the target mask image and the target area image can be determined according to the target rounded corner information. Then, the rounded corner image of the image to be processed can be determined according to the target mask image and the target area image. The target mask image can include pixel change information of the rounded corners to be drawn, and the target area image can be the area image that needs to be rounded in the image to be processed.
[0083] The pixel change information may be the specific pixel value corresponding to each pixel point of the fillet to be drawn in the target mask image. In the target mask image, each pixel point corresponds to a specific pixel value, and the pixel values corresponding to different pixels may be partially the same or may be different.
[0084] The target area image may be an area image in the image to be processed where the corners of the image need to be processed into rounded corners. For example, when the image to be processed is a rectangular image, the area image where the corners of the image to be processed are rounded may be an area image where the four right angles of the rectangular image are located.
[0085] By determining the rounded corner image in the image to be processed based on the target mask image with pixel change information and the target area image, the smoothness and anti-aliasing property of the connection between the curve and the straight line in the image to be processed can be improved, and the time for rounding the corners of the image to be processed can be reduced, thereby improving the efficiency of rounding the corners of the image to be processed and improving the user experience at the same time. In addition, the application scenarios for rounding the corners of the image to be processed are increased, such as user interface design scenarios, web page design scenarios, graphic design scenarios, and other application scenarios.
[0086] In the above image processing method, according to the target rounded corner information of the rounded corners to be drawn of the image to be processed, the target area image of the image to be processed and the target mask map with the pixel change information of the rounded corners to be drawn are determined, and the rounded corner image of the image to be processed is determined according to the target mask map and the target area image. In this way, by determining the rounded corner image using the target mask map with the pixel change information of the rounded corners to be drawn, the rounded corner smoothness and anti-aliasing property of the rounded corner image can be improved, and the time for processing the image to be processed can be reduced, thereby improving the efficiency of processing the image to be processed.
[0087] In possible ways, the target mask map is determined according to the target fillet information, including:
[0088] The target mask image is determined according to the target fillet information and the preset relationship, and the preset relationship is used to characterize the preset corresponding relationship between the fillet information and the mask image.
[0089] It should be understood that the fillet information can be used to characterize the size of the texture mapping. For example, when the fillet is a circular curve, the fillet information can be used to characterize the size of the circular radius of the texture mapping, and when the fillet is an elliptical curve, the fillet information can be used to characterize the size of the major axis and the minor axis of the texture mapping. The mask image can be an image with a pixel value at each pixel point.
[0090] In the preset relationship, it can be a mask map under the same type of curve, and different fillet information corresponds to different mask maps. One fillet information can correspond to one mask map, and multiple fillet information can correspond to multiple mask maps.
[0091] In the embodiment of the present disclosure, a mask map corresponding to the target rounded corner information can be matched according to the target rounded corner information and a preset relationship, and the mask map can be used as the target mask map.
[0092] By matching the mask image corresponding to the target rounded corner information in a preset relationship and using the mask image as the target mask image, the smoothness and anti-aliasing effect of the rounded corner image obtained after fusion with the target area image can be improved, and the time for rounding the corners of the image to be processed can be reduced, thereby improving the efficiency of rounding the corners of the image to be processed.
[0093] In a possible manner, the preset relationship includes preset level of fillet information and its corresponding mask map, and determining the target mask map according to the target fillet information and the preset relationship includes:
[0094] When the target rounded corner information belongs to the rounded corner information of the preset level, determining the target mask map according to the target rounded corner information and the rounded corner information of the preset level;
[0095] When the target rounded corner information does not belong to the rounded corner information of a preset level, two rounded corner information of preset levels adjacent to the target rounded corner information are determined, and a target mask map is determined according to the two rounded corner information of preset levels.
[0096] It should be understood that, in a preset relationship, under the same type of curve, the mask images corresponding to different rounded corner information are different. When the rounded corner information is used to characterize the radius size of the texture mapping, the corresponding mask image can be a square mask image, and when the radius size is different, the corresponding mask image is also different. When the rounded corner information is used to characterize the major axis size and minor axis size of the texture mapping, the corresponding mask image can be a rectangular mask image, and when the major axis size and minor axis size are different, the corresponding mask image is also different. Under the same type of curve, different rounded corner information can match the corresponding mask image, which can increase the smoothness of the rounded corners and the anti-aliasing effect in the rounded corner image, thereby improving the aesthetics of the rounded corner image, making the viewing angle effect not stiff, and at the same time improving the user experience effect.
[0097] Among them, the preset level of fillet information in the preset relationship and its corresponding mask map can be obtained by a multi-level asymptotic texture method. When obtained by the multi-level asymptotic texture method, under the same type of curve, the preset level of fillet information has a total of ten preset levels, and each preset level of fillet information corresponds to a mask map. And the pixel change information in the mask map corresponding to the fillet information of different preset levels can be different, and can cover all sizes of fillets to be drawn under the type of curve. In this way, the smoothness of the curve and the straight line in the fillet image can be improved, and the anti-aliasing property of the curve can be improved.
[0098] When matching the target mask map according to the target rounded corner information and the preset relationship, the target rounded corner information may belong to the rounded corner information of the preset level, or the target rounded corner information may not belong to the rounded corner information of the preset level. When the target rounded corner information belongs to any one of the preset levels of rounded corner information, the corresponding preset level of rounded corner information can be queried according to the target rounded corner information, and the mask map corresponding thereto can be matched according to the rounded corner information of the preset level, and the mask map can be used as the target mask map. When the target rounded corner information does not belong to any one of the preset levels of rounded corner information of the preset level, the rounded corner information of two preset levels adjacent to the target rounded corner information can be queried, and then the target mask map can be determined according to the rounded corner information of the two preset levels. Among them, when determining the target mask map according to the two preset levels of rounded corner information, the two preset levels of rounded corner information and the corresponding mask map can be processed by a linear interpolation method to obtain the target mask map.
[0099] For example, Figure 3As shown, when the target rounded corner information is the size of the circular radius of the target texture mapping, in the preset levels of rounded corner information, it can be assumed that the rounded corner information of the zeroth preset level can be 64*64, the rounded corner information of the first preset level can be 32*32, the rounded corner information of the second preset level can be 16*16, and so on, until the rounded corner information of the sixth preset level can be 1*1.
[0100] When the target rounded corner information is 64, the target rounded corner information belongs to the rounded corner information of the zeroth preset level in the preset level rounded corner information, and the mask map corresponding to the target rounded corner information and the rounded corner information of the zeroth preset level can be used as the target mask map. When the target rounded corner information is 50, the target rounded corner information does not belong to any preset level of rounded corner information in the preset level rounded corner information, and the rounded corner information of the zeroth preset level and the rounded corner information of the first preset level can be determined as two preset level rounded corner information adjacent to the target rounded corner information, and the target mask map can be determined according to the mask maps corresponding to the two preset levels of rounded corner information by a linear interpolation method.
[0101] By determining the target mask map based on the relationship between the target rounded corner information and the preset level of rounded corner information, the smoothness of the curves and straight lines of the final rounded corner image can be improved, and the anti-aliasing property of the curve can be improved, thereby improving the aesthetics.
[0102] In a possible embodiment, the method further comprises:
[0103] Determine a curve that encloses a closed region with the first side and the second side, the first side and the second side being perpendicular to each other;
[0104] Perform segmentation processing on the curve to obtain a segmented curve;
[0105] By rasterizing the line segment curve, a pixel change curve is obtained;
[0106] According to the pixel change curve, a mask image corresponding to the curve is determined.
[0107] It should be understood that the curve may be determined by a parametric equation, and the parametric equation may be one or more, one parametric equation may generate one type of mask image, and multiple parametric equations may generate multiple types of mask images.
[0108] In the embodiment of the present disclosure, the determined curve may be a curve of a closed area enclosed by the first side and the second side, and the first side and the second side may be in a perpendicular relationship. The first side and the second side may be the horizontal axis and the vertical axis of the coordinate axis, which is not specifically limited in the embodiment of the present disclosure.
[0109] When processing the curve into segments, a threshold length can be set, and the curve can be divided into multiple different segments according to the threshold length. On each segment, it can be represented by a coordinate point P. Then the coordinates of the coordinate point P on each segment can be calculated according to the expression of the curve. For example, the threshold length can be set to a small value e, and the curve can be divided into several segments of length e according to the value e. In each segment of length e, it can be expressed by the coordinate point P. Then the coordinates of each coordinate point P can be calculated by the parametric equation of the curve to obtain a segmented curve.
[0110] Then, the segmented curve is rasterized. The rasterization process can be to convert continuous line segments into discrete pixel points. After the segmented curve is rasterized, a pixel change curve with pixel values can be obtained on the segmented curve. Then, a mask image can be obtained through the pixel change curve. The mask image can be multiple mask images under one type of curve, or multiple mask images under multiple types of curves, and the size information of the multiple mask images under each type of curve can be different.
[0111] When multiple mask images of a type of curve are generated, the mask images can be stored in corresponding files. When rounding the image to be processed, the corresponding mask image can be matched according to the target rounding information of the rounded corner to be drawn, and the mask image can be decompressed to construct a corresponding preset relationship, and then the corresponding target mask image can be matched according to the target rounding information according to the preset relationship.
[0112] When multiple mask images of multiple types of curves are generated, multiple mask images under the multiple types of curves can be stored in a file. When rounding the image to be processed, multiple corresponding mask images can be matched in the file according to the curve type required by the user. In the process of decompressing the mask image, a corresponding preset relationship is constructed, and the corresponding target mask image is matched according to the target rounded corner information according to the preset relationship.
[0113] By rasterizing the line segment curve, a pixel change curve of pixel change information can be obtained. On the pixel change curve, the pixel values at the pixel points can be the same or different. The pixel value of each pixel point in the mask image can represent the curvature of the curve, and the curve can have better smoothness and anti-aliasing properties.
[0114] In possible ways, the mask map is determined according to the pixel change curve, including:
[0115] The pixel values in the closed area enclosed by the pixel change curve and the first side and the second side are set to 1.
[0116] It should be understood that when determining the mask image based on the pixel change curve, the closed area image connected to the first edge and the second edge can be first determined based on the curve, and the pixel value of each pixel in the closed area image is set to 1 to obtain the mask image.
[0117] like Figure 4 As shown in FIG. , the mask image can be obtained after the curve is segmented and rasterized. Figure 4 In the figure, the white area can be a closed area image connected by the curve, the first edge and the second edge. In the closed area image, the pixel value of each pixel can be 1. On the curve, Figure 5 As shown, Figure 5 is a schematic diagram showing an enlarged pixel value of a pixel point on a curve region image in a mask according to an exemplary embodiment, referring to Figure 5 ,exist Figure 5 In the upper right corner area image, the arc of the intersection of the black area image and the white area image can be a curve. And the pixel value of each pixel point on the curve can be obtained, and the pixel value from the pixel point of the white area image to the pixel point of the black area image can be changed in sequence, and then the corresponding colors can also be increased in sequence.
[0118] By rasterizing the curve and converting each pixel on the curve into pixel values that increase in sequence, the smoothing effect and anti-aliasing effect of the rounded corners of the rounded image can be improved, and the final rounded image can be made more aesthetically pleasing and provide a better user experience.
[0119] In a possible manner, determining a rounded corner image of an image to be processed according to a target area image and a target mask image includes:
[0120] For each first pixel position in the target area image, a second pixel position matching the first pixel position is determined in the target mask image, and the pixel value of the second pixel position is fused with the pixel value of the first pixel position to obtain a rounded image of the image to be processed.
[0121] It should be understood that when determining the rounded corner image of the image to be processed based on the target area image and the target mask image, the pixel change information in the target mask image can be fused into the target area image by matching the pixel values of the pixels to obtain the rounded corner image.
[0122] First, any first pixel position in the target area image can be determined, and then the second pixel position corresponding to the first pixel position can be matched in the target mask image. Then, the pixel value of the second pixel position can be fused to the first pixel position. After all the pixels in the target area image are fused, a rounded image can be obtained.
[0123] When the pixel value of the second pixel point position is fused to the first pixel point position, the pixel transparency of the point can be determined first according to the pixel value of the second pixel point position, and then the pixel transparency can be superimposed on the first pixel point position. When the pixel values of all the first pixel point positions in the target area image are fused, a rounded image can be obtained.
[0124] By matching the first pixel point position in the target area image with the second pixel point position in the target mask image, the pixel value of the second pixel point position is merged into the first pixel point position, thereby achieving the fusion of the pixel value in the target mask image with the target area image, which can reduce the time for rounding the corners of the image to be processed, and thus improve the efficiency of rounding the corners of the image to be processed.
[0125] In another possible manner, the first pixel point position is first determined, and the first pixel point position may be a position in a first coordinate system, and the first coordinate system may be a coordinate system constructed with the vertex in the upper left corner of the image to be processed as the origin. The first pixel point position is then converted to a second pixel point position in a second coordinate system, and the second coordinate system may be a coordinate system constructed with the center of the image to be processed as the origin. The second pixel point position may then be converted to a third pixel point position in a third coordinate system, and the third coordinate system is a coordinate system constructed with the origin determined according to the target rounded corner information, and the closest distance from the origin determined by the target rounded corner information to the two sides of the image to be processed may be the target rounded corner information. Finally, the sub-target area image may be determined according to the third pixel point position, and the shadow area image in the figure may be the sub-target area image, and the sub-target area image may be an image matched with the target mask image, and then the pixel value corresponding to each pixel point in the target mask image is fused with the sub-target area image to obtain a rounded corner image.
[0126] In the process of fusing the pixel value corresponding to each pixel point in the target mask image with the sub-target area image to obtain the rounded corner image, the pixel transparency in the target mask image can be extracted, and then the pixel transparency can be superimposed on the corresponding position in the target area image, which can be expressed by the following calculation formula: color = maseShader.α, where color can be a pixel in the target area image, and maseShader.α can be the pixel transparency extracted from the target mask image. By fusing the pixel value in the target mask image with the target area image, the time for rounding the image to be processed can be reduced, thereby improving the efficiency of processing the rounded corner image.
[0127] For example, Figure 6 As shown, in Figure 6In , assuming that the position of the first pixel is A, the coordinate point of the first pixel in the coordinate system constructed with the upper left corner Q of the image to be processed as the origin can be A(x0, y0). Figure 7 As shown, a second coordinate system can be constructed with the center point of the image to be processed as the origin O, and the first pixel point position A (x0, y0) can be converted to the second pixel point position A (x1, y1). Figure 8 As shown, a third coordinate system can be constructed based on the origin P determined by the target corner fillet information, and the second pixel position A(x1, y1) can be converted to the third pixel position A(x2, y2) in the third coordinate system, where the distance from the origin to the two nearest vertical line segments of the image to be processed in the third coordinate system is the same as the target corner fillet information. Figure 8 The shadow area image in is the sub-target area image, and the size of the sub-target area image is the same as the size of the target mask image. The pixel value corresponding to each pixel point in the target mask image can be fused with the sub-target area image to obtain a rounded corner image.
[0128] In a possible manner, determining a target area image in an image to be processed according to target rounded corner information includes:
[0129] Determine the vertices of the image to be processed;
[0130] According to the target rounded corner information, the image to be processed is divided into nine-square grid images by using the nine-square grid method;
[0131] The target area image is determined according to the vertices and the nine-square grid image.
[0132] It should be understood that when the image to be processed is a rectangular image, the vertex can be a right angle point in the rectangular image, and a rectangular image includes four vertices. In the rectangular image, the area image that needs to be rounded can be the corresponding area image where the vertex is located, and in the rectangular image, the right angle area image where one vertex is located can be rounded, and multiple right angle area images corresponding to multiple vertices can also be rounded. At this time, the image to be processed can be divided into a nine-square grid image according to the target rounded corner information and the nine-square grid method. In the nine-square grid image, the square image area where the vertex is located can be the target area image.
[0133] like Fig. 9As shown, in the image to be processed, nine sub-rectangular images are included, and in the sub-rectangular image where a vertex is located, the information is the same as the target rounded corner information. That is, when the target rounded corner information is used to characterize the size of the circular radius of the texture mapping, the length and width of the sub-rectangular image can be the same as the size of the circular radius. When the target rounded corner information is used to characterize the size of the major axis and the minor axis of the texture mapping, the length of the sub-rectangular image can be the same as the size of the major axis, and the width of the sub-rectangular image can be the same as the size of the minor axis. Therefore, in the nine-square grid image, the sub-rectangular images of the shadow areas corresponding to the four right angles can be the target area images.
[0134] By dividing the image to be processed into a nine-square grid image according to the target corner rounding information, the target area image that needs corner rounding can be accurately located, thereby reducing the time for corner rounding of the image to be processed and improving the efficiency of corner rounding of the image to be processed.
[0135] By using the above image processing method, the curve is rasterized to obtain a mask map, which can make the smoothness and anti-aliasing effect of the place where the curve and the straight line are connected in the final rounded image better. By integrating the pixel values in the target mask map into the target area image, the time for rounding the image to be processed can be reduced, thereby improving the efficiency of rounding the image to be processed. It will not bring too much burden to the semiconductor chip that handles the process, thereby expanding the application scenarios of this method, such as web design scenarios, display interface scenarios, etc. Reference Fig.10 , Fig.10 is a schematic diagram of a terminal interface according to an exemplary embodiment. Fig.10 In the example, each software presents a rounded rectangle on the interface, which can be realized by the above-mentioned image processing method.
[0136] Fig.11 is a block diagram of an image processing apparatus 1100 according to an exemplary embodiment. Fig.11 , the image processing device 1100 includes a first determining module 1110, a second determining module 1120 and a third determining module 1130;
[0137] The first determining module 1110 is configured to determine target rounded corner information of a to-be-drawn rounded corner of the to-be-processed image;
[0138] The second determination module 1120 is configured to determine a target mask image and a target area image in the image to be processed according to the target rounded corner information, wherein the target mask image includes pixel change information of the image to be processed, and the target area image is an area image in the image to be processed that needs to be rounded.
[0139] The third determination module 1130 is configured to determine the rounded corner image of the image to be processed according to the target area image and the target mask image.
[0140] Optionally, the second determining module 1120 is configured to:
[0141] The target mask image is determined according to the target fillet information and a preset relationship, wherein the preset relationship is used to characterize a preset corresponding relationship between the fillet information and the mask image.
[0142] Optionally, the preset relationship includes a preset level of fillet information and a corresponding mask map, and the second determining module 1120 is further configured to:
[0143] When the target rounded corner information belongs to the rounded corner information of the preset level, determining the target mask map according to the target rounded corner information and the rounded corner information of the preset level;
[0144] When the target rounded corner information does not belong to the rounded corner information of the preset level, two rounded corner information of the preset levels adjacent to the target rounded corner information are determined, and the target mask map is determined according to the two rounded corner information of the preset levels.
[0145] Optionally, the image processing device 1100 further includes:
[0146] A fourth determining module is configured to determine a curve that forms a closed area with the first side and the second side, wherein the first side and the second side are perpendicular to each other;
[0147] A first processing module is configured to perform segmentation processing on the curve to obtain a segmented curve;
[0148] A second processing module is configured to perform rasterization processing on the line segment curve to obtain a pixel change curve;
[0149] The fifth determination module is configured to determine the mask image corresponding to the curve according to the pixel change curve.
[0150] Optionally, the fifth determining module is further configured to:
[0151] The pixel values in the closed area enclosed by the pixel change curve, the first side and the second side are set to 1.
[0152] Optionally, the third determining module 1130 is configured to:
[0153] For each first pixel position in the target area image, a second pixel position matching the first pixel position is determined in the target mask image, and the pixel value of the second pixel position is fused with the pixel value of the first pixel position to obtain a rounded image of the image to be processed.
[0154] Optionally, the second determining module 1120 includes:
[0155] A first determination submodule is configured to determine the vertices of the image to be processed;
[0156] A region division module is configured to divide the image to be processed into nine-square grid images by a nine-square grid method according to the target rounded corner information;
[0157] The second determination submodule is configured to determine the target area image according to the vertices and the nine-square grid image.
[0158] According to the target rounded corner information of the image to be processed, the target area image of the image to be processed and the target mask image with the pixel change information of the rounded corner to be drawn are determined, and the rounded corner image of the image to be processed is determined according to the target mask image and the target area image. The rounded corner smoothness and anti-aliasing property of the rounded corner image can be improved, and the time for processing the image to be processed can be reduced, thereby improving the efficiency of processing the image to be processed.
[0159] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0160] The present disclosure also provides an image processing device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to: perform the steps of the image processing method provided by the present disclosure.
[0161] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, and when the program instructions are executed by a processor, the steps of the image processing method provided by the present disclosure are implemented.
[0162] Fig.12 1 is a block diagram of an apparatus 1200 for image processing according to an exemplary embodiment. For example, the apparatus 1200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0163] Reference Fig.12, the device 1200 may include one or more of the following components: a processing component 1202 , a memory 1204 , a power component 1206 , a multimedia component 1208 , an audio component 1210 , an input / output interface 1212 , a sensor component 1214 , and a communication component 1216 .
[0164] The processing component 1202 generally controls the overall operation of the device 1200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1202 may include one or more processors 1220 to execute instructions to complete all or part of the steps of the above-mentioned image processing method. In addition, the processing component 1202 may include one or more modules to facilitate the interaction between the processing component 1202 and other components. For example, the processing component 1202 may include a multimedia module to facilitate the interaction between the multimedia component 1208 and the processing component 1202.
[0165] The memory 1204 is configured to store various types of data to support the operation of the device 1200. Examples of such data include instructions for any application or method operating on the device 1200, contact data, phone book data, messages, pictures, videos, etc. The memory 1204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0166] The power supply component 1206 provides power to the various components of the device 1200. The power supply component 1206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 1200.
[0167] The multimedia component 1208 includes a screen that provides an output interface between the device 1200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1208 includes a front camera and / or a rear camera. When the device 1200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0168] The audio component 1210 is configured to output and / or input audio signals. For example, the audio component 1210 includes a microphone (MIC), and when the device 1200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1204 or sent via the communication component 1216. In some embodiments, the audio component 1210 also includes a speaker for outputting audio signals.
[0169] The input / output interface 1212 provides an interface between the processing component 1202 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0170] The sensor assembly 1214 includes one or more sensors for providing various aspects of the status assessment of the device 1200. For example, the sensor assembly 1214 can detect the open / closed state of the device 1200, the relative positioning of components, such as the display and keypad of the device 1200, the sensor assembly 1214 can also detect the position change of the device 1200 or a component of the device 1200, the presence or absence of user contact with the device 1200, the orientation or acceleration / deceleration of the device 1200, and the temperature change of the device 1200. The sensor assembly 1214 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1214 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1214 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0171] The communication component 1216 is configured to facilitate wired or wireless communication between the device 1200 and other devices. The device 1200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0172] In an exemplary embodiment, the device 1200 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above-mentioned image processing method.
[0173] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1204 including instructions, and the instructions can be executed by the processor 1220 of the device 1200 to complete the above-mentioned image processing method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0174] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned image processing method when executed by the programmable device.
[0175] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0176] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that: The method comprises: Determine target fillet information of the fillet to be drawn of the image to be processed; According to the target rounded corner information, determine a target mask image and a target area image in the image to be processed, wherein the target mask image includes pixel change information of the rounded corner to be drawn, and the target area image is an area image in the image to be processed that needs to be rounded; A rounded corner image of the image to be processed is determined according to the target area image and the target mask image.
2. The method according to claim 1, characterized in that The step of determining a target mask map according to the target fillet information includes: The target mask image is determined according to the target fillet information and a preset relationship, wherein the preset relationship is used to characterize a preset corresponding relationship between the fillet information and the mask image.
3. The method according to claim 2, characterized in that The preset relationship includes preset level of fillet information and its corresponding mask map, and determining the target mask map according to the target fillet information and the preset relationship includes: When the target rounded corner information belongs to the rounded corner information of the preset level, determining the target mask map according to the target rounded corner information and the rounded corner information of the preset level; When the target rounded corner information does not belong to the rounded corner information of the preset level, two rounded corner information of the preset levels adjacent to the target rounded corner information are determined, and the target mask map is determined according to the two rounded corner information of the preset levels.
4. The method according to claim 2 or 3, characterized in that: The method further comprises: Determine a curve that forms a closed area with a first side and a second side, wherein the first side and the second side are perpendicular to each other; Performing segmentation processing on the curve to obtain a segmented curve; Performing rasterization processing on the line segment curve to obtain a pixel change curve; According to the pixel change curve, the mask image corresponding to the curve is determined.
5. The method according to claim 4, characterized in that Determining the mask image according to the pixel change curve includes: The pixel values in the closed area enclosed by the pixel change curve, the first side and the second side are set to 1.
6. The method according to claim 1, characterized in that The step of determining the rounded corner image of the image to be processed according to the target area image and the target mask image comprises: For each first pixel position in the target area image, a second pixel position matching the first pixel position is determined in the target mask image, and the pixel value of the second pixel position is fused with the pixel value of the first pixel position to obtain a rounded image of the image to be processed.
7. The method according to any one of claims 1 to 6, characterized in that: The step of determining the target area image in the image to be processed according to the target rounded corner information includes: Determining the vertices of the image to be processed; According to the target rounded corner information, the image to be processed is divided into nine-square grid images by a nine-square grid method; The target area image is determined according to the vertices and the nine-square grid image.
8. An image processing device, characterized in that: The device comprises a first determination module, a second determination module and a third determination module; The first determination module is configured to determine target rounded corner information of a to-be-drawn rounded corner of the to-be-processed image; The second determination module is configured to determine a target mask image and a target area image in the image to be processed according to the target rounded corner information, wherein the target mask image includes pixel change information of the rounded corner to be drawn, and the target area image is an area image in the image to be processed that needs to be rounded; The third determination module is configured to determine the rounded corner image of the image to be processed according to the target area image and the target mask image.
9. An image processing device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: The steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.