Method, apparatus, and storage medium for smoothing object edges
Patent Information
- Application Number
- CN202310574168.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-19
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-05-19
AI Technical Summary
[0002]对于虚拟现实(Virtual Reality,简称为VR)全景图中的物体,通常无法直接通过实时计算描述会物体的边缘,虽然相关技术中可以通过边缘检测mask算法学习并输出图像中物体的mask边缘,但是所输出的mask边缘可能存在大量的毛刺
[0063]基于本公开上述实施例提供的用于平滑物体边缘的方法、装置以及存储介质,应用于支持全球广域网图形函数库(Web Graphics Library,简称为WebGL)2.0的浏览器客户端,响应于用户触发的生成操作,在三维空间场景中生成一个承载物体,并将目标物体的边缘mask图贴在所述承载物体的表面,该承载物体的中心点位置为相机所在位置;在着色器中读取目标物体的边缘mask图,得到目标物体边缘上至少一个像素点的坐标信息;根据目标物体边缘上至少一个像素点的坐标信息以及边缘路径的路径信息,计算目标物体边缘上至少一个像素点与边缘路径的最小距离;然后基于目标物体边缘上至少一个像素点与边缘路径的最小距离,确定目标物体边缘上至少一个像素点的透明度,以实现目标物体边缘的平滑。本公开技术方案通过调用三维纹理应用程序编程接口即可实现空间VR游览时,全景图中目标物体的边缘平滑,通过将目标物体的边缘mask图贴在一个三维的承载物体上,即可在着色器中读取该边缘mask图,并根据目标物体边缘上至少一个像素点与边缘路径的距离,设置目标物体边缘上至少一个像素点的透明度,即可实现对边缘mask图中边缘毛刺的平滑处理,本公开技术方案可以不基于alpha通道对原始边缘mask做平滑处理。
Smart Images

Figure CN116612228B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of three-dimensional texture and image processing technology, and in particular to a method, apparatus and storage medium for smoothing the edges of objects. Background Technology
[0002] For objects in virtual reality (VR) panoramic images, it is usually impossible to directly describe the edges of the objects through real-time calculation. Although related technologies can learn and output the mask edges of objects in the image using edge detection mask algorithms, the output mask edges may contain a large number of jagged edges. In object edge scanning applications, these jagged edges have a negative impact on the visual effect. Summary of the Invention
[0003] One technical problem to be solved by the embodiments of this disclosure is to provide a method, apparatus and storage medium for smoothing the edges of an object.
[0004] According to one aspect of the present disclosure, a method for smoothing object edges is provided, applied to a WebGL-enabled browser client, the method comprising:
[0005] In response to a user-triggered generation operation, a carrier object is generated in a three-dimensional space scene, and the edge mask image of the target object is applied to the surface of the carrier object. The center point of the carrier object is the location of the camera.
[0006] Read the edge mask image of the target object in the shader to obtain the coordinate information of at least one pixel on the edge of the target object;
[0007] Based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path, calculate the minimum distance between at least one pixel on the edge of the target object and the edge path;
[0008] The transparency of at least one pixel on the edge of the target object is determined based on the minimum distance between the pixel and the edge path, so as to achieve smoothing of the edge of the target object.
[0009] In one embodiment of this disclosure, reading the edge mask image of the target object in the shader to obtain the coordinate information of at least one pixel on the edge of the target object includes:
[0010] Read the pixel coordinates of at least one pixel point of the edge mask map in the shader;
[0011] The pixel value of at least one pixel in the edge mask image is determined based on the pixel coordinates of at least one pixel in the edge mask image.
[0012] The pixel with the set pixel value is determined as the pixel on the edge of the target object, and the coordinate information of the pixel on the edge of the target object is used as the coordinate information of the corresponding pixel on the edge of the target object.
[0013] In another embodiment of this disclosure, calculating the minimum distance between at least one pixel on the edge of the target object and the edge path based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path includes:
[0014] Based on the path information of the edge path, calculate the multiple line segments that are connected end to end of the edge path;
[0015] Starting from at least one pixel on the edge of the target object, draw perpendicular lines to each of the multiple line segments to obtain the distance between at least one pixel on the edge of the target object and the multiple line segments;
[0016] For at least one pixel on the edge of the target object, the minimum value among the distances to the multiple line segments is taken as the minimum distance to the edge path.
[0017] In yet another embodiment of this disclosure, the method further includes:
[0018] Receive user-triggered light-display operation;
[0019] The sweeping display pixels of the initial frame are determined based on the starting angle and ending angle corresponding to the sweeping display operation.
[0020] Based on the set display angle and set rotation direction, determine the sweeping display pixels for any subsequent frame;
[0021] Render and highlight the scanned display pixels for each frame, and discard the rendering of pixels on the edge of the target object other than the scanned display pixels.
[0022] In another embodiment of this disclosure, determining the sweeping display pixels of the initial frame based on the start angle and end angle corresponding to the sweeping display operation includes:
[0023] Calculate the angle between the line connecting at least one pixel on the edge of the target object and the center point of the edge object and the positive x-axis;
[0024] The pixels on the edge of the target object with the included angle between the starting angle and the ending angle are determined as the scanning display pixels of the initial frame.
[0025] In another embodiment of this disclosure, determining the transparency of at least one pixel on the edge of the target object based on the minimum distance between at least one pixel on the edge of the target object and the edge path includes:
[0026] The transparency of at least one pixel on the edge of the target object is calculated using equation (1):
[0027] alpha=1.0-k*normalize(distance(point,closedpoint)) Formula (1)
[0028] In equation (1), k is an empirical value, and normalize() is a normalization function used to normalize the minimum distance between the at least one pixel and the edge path.
[0029] In yet another embodiment of this disclosure, the method further includes:
[0030] The edge mask image and edge path information of the target object are generated offline.
[0031] The edge path information of the target object is input into the shader in the form of a two-dimensional array, and the edge mask image of the target object is input into the shader in the form of being pasted onto the surface of the carrying object.
[0032] According to another aspect of the present disclosure, an apparatus for smoothing the edges of an object is provided, applied to a WebGL-enabled browser client, the apparatus comprising:
[0033] The first generation module is used to generate a carrier object in a three-dimensional space scene in response to a user-triggered generation operation, and to attach the edge mask image of the target object to the surface of the carrier object. The center point of the carrier object is the location of the camera.
[0034] The reading module is used to read the edge mask image of the target object in the shader and obtain the coordinate information of at least one pixel point on the edge of the target object;
[0035] The distance calculation module is used to calculate the minimum distance between at least one pixel on the edge of the target object and the edge path based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path.
[0036] The transparency determination module is used to determine the transparency of at least one pixel on the edge of the target object based on the minimum distance between at least one pixel on the edge of the target object and the edge path, so as to achieve smoothing of the edge of the target object.
[0037] In one embodiment of this disclosure, the reading module includes:
[0038] A read submodule is used to read the pixel coordinates of at least one pixel point of the edge mask map in the shader;
[0039] The pixel value determination submodule is used to determine the pixel value of at least one pixel in the edge mask image based on the pixel coordinates of at least one pixel in the edge mask image.
[0040] The first determining submodule is used to determine the pixel point with the pixel value set as the pixel point on the edge of the target object, and use the coordinate information of the pixel point on the edge of the target object as the coordinate information of the corresponding pixel point on the edge of the target object.
[0041] In yet another embodiment of this disclosure, the distance calculation module includes:
[0042] The calculation submodule is used to calculate multiple line segments that are connected end to end in the edge path based on the path information of the edge path;
[0043] The perpendicular line submodule is used to draw perpendicular lines to the multiple line segments, starting from at least one pixel on the edge of the target object, to obtain the distance between at least one pixel on the edge of the target object and the multiple line segments.
[0044] The second determining submodule is used to determine the minimum distance among the distances to the multiple line segments for at least one pixel point on the edge of the target object as the minimum distance to the edge path.
[0045] In yet another embodiment of this disclosure, the apparatus further includes:
[0046] The receiving module is used to receive the user-triggered light-scanning display operation;
[0047] The first determining module is used to determine the scanning display pixels of the initial frame based on the starting angle and the ending angle corresponding to the scanning display operation.
[0048] The second determining module is used to determine the sweeping display pixels of any subsequent frame according to the set display angle and set rotation direction;
[0049] The rendering module is used to render and highlight the scanned display pixels in each frame, and discard the rendering of pixels on the edge of the target object other than the scanned display pixels.
[0050] In yet another embodiment of this disclosure, the first determining module includes:
[0051] Angle calculation submodule is used to calculate the angle between the line connecting at least one pixel on the edge of the target object and the center point of the edge object and the positive x-axis direction;
[0052] The third determining submodule is used to determine the pixel points on the edge of the target object with the included angle between the starting angle and the ending angle as the scanning display pixels of the initial frame.
[0053] In yet another embodiment of this disclosure, the transparency determination module is specifically used to calculate the transparency of at least one pixel on the edge of the target object using equation (1):
[0054] alpha=1.0-k*normalize(distance(point,closedpoint)) Formula (1)
[0055] In equation (1), k is an empirical value, and normalize() is a normalization function used to normalize the minimum distance between the at least one pixel and the edge path.
[0056] In yet another embodiment of this disclosure, the apparatus further includes:
[0057] The second generation module is used to generate the edge mask image of the target object and the edge path information of the target object offline;
[0058] The input module is used to input the edge path information of the target object into the shader in the form of a two-dimensional array, and to input the edge mask image of the target object into the shader in the form of being pasted onto the surface of the carrying object.
[0059] According to another aspect of the present disclosure, an electronic device is provided, the electronic device comprising:
[0060] Memory, used to store computer programs;
[0061] A processor is configured to execute a computer program stored in the memory, wherein, when the computer program is executed, the method described above for smoothing the edges of an object is implemented.
[0062] According to another aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the above-described method for smoothing the edges of an object.
[0063] Based on the method, apparatus, and storage medium for smoothing object edges provided in the above embodiments of this disclosure, applied to a browser client supporting Web Graphics Library (WebGL) 2.0, in response to a user-triggered generation operation, a carrier object is generated in a three-dimensional space scene, and the edge mask image of the target object is pasted onto the surface of the carrier object, the center point of the carrier object being the location of the camera; the edge mask image of the target object is read in the shader to obtain the coordinate information of at least one pixel on the edge of the target object; based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path, the minimum distance between at least one pixel on the edge of the target object and the edge path is calculated; then, based on the minimum distance between at least one pixel on the edge of the target object and the edge path, the transparency of at least one pixel on the edge of the target object is determined to achieve smoothing of the target object edge. This disclosed technical solution can achieve edge smoothing of target objects in a panoramic image during spatial VR tours by calling a 3D texture application programming interface. By pasting the edge mask image of the target object onto a 3D carrier object, the edge mask image can be read in the shader. The transparency of at least one pixel on the edge of the target object can be set according to the distance between at least one pixel on the edge of the target object and the edge path, thereby achieving the smoothing of edge burrs in the edge mask image. This disclosed technical solution can smooth the original edge mask without relying on the alpha channel.
[0064] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0065] The accompanying drawings, which form part of this specification, illustrate embodiments of this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0066] This disclosure will become clearer with reference to the accompanying drawings and the following detailed description, wherein:
[0067] Figure 1 A flowchart illustrating one embodiment of the method for smoothing object edges disclosed herein;
[0068] Figure 2A This is a flowchart of an embodiment of the sweeping display based on the method for smoothing object edges disclosed herein;
[0069] Figure 2B For this disclosure Figure 2A The flowchart illustrating the implementation of step 202 in the illustrated embodiment;
[0070] Figure 2CThis is a schematic diagram of the edge where the display angle is set in a frame of data in the sweeping light display of this disclosure;
[0071] Figure 3A A flowchart illustrating an embodiment of the present disclosure for determining the coordinate information of at least one pixel on the edge of a target object;
[0072] Figure 3B This is a schematic diagram of the panoramic view used to determine the location of the target object in this disclosure;
[0073] Figure 3C This disclosure provides an edge mask image of the target object in the panoramic view where the target object is located.
[0074] Figure 3D This is a schematic diagram of the burr effect of the target object edge mask image in the panoramic view of the target object in this disclosure.
[0075] Figure 4 This is a flowchart illustrating an embodiment of the present disclosure for calculating the minimum distance between at least one pixel on the edge of a target object and the edge path;
[0076] Figure 5 This is a schematic diagram of one embodiment of the apparatus for smoothing the edges of an object disclosed herein;
[0077] Figure 6 This is a schematic diagram of another embodiment of the apparatus for smoothing the edges of an object disclosed herein;
[0078] Figure 7 This is a structural diagram of an electronic device provided as an illustrative embodiment of the present disclosure. Detailed Implementation
[0079] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.
[0080] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0081] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.
[0082] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0083] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0084] This disclosure can be applied to electronic devices such as computer systems / servers, which can operate with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known computing systems, environments, and / or configurations suitable for use with electronic devices such as computer systems / servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0085] Electronic devices such as computer systems / servers can be described in the general context of computer-executable instructions (such as program modules) executed by the computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are performed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0086] This disclosure outlines
[0087] The technical solution provided in this disclosure is applied to scenarios where object edges need to be depicted on a panoramic image during VR tours. This disclosure provides a technical solution for edge smoothing without relying on the alpha channel. To achieve this solution, the browser needs to support WebGL. The WebGL-based 3D texture application programming interface can load the edge mask image pasted onto the surface of the object into the video memory for rendering and display. Furthermore, the WebGL shader can obtain the coordinate information of at least one pixel of the target object's edge in the edge mask image, as well as the minimum distance between at least one pixel of the target object's edge and the edge path. This allows setting the transparency of at least one pixel based on the minimum distance between at least one pixel of the target object's edge and the edge path. Thus, edge smoothing of the target object in the panoramic image is achieved through the browser's WebGL environment.
[0088] Exemplary embodiments
[0089] Figure 1This is a flowchart illustrating one embodiment of the method for smoothing object edges disclosed herein; this method for smoothing object edges can be applied to electronic devices (such as mobile terminals), and the browser on the electronic device needs to support WebGL 2.0. Figure 1 As shown, the method for smoothing object edges includes the following steps:
[0090] In step 101, in response to a user-triggered generation operation, a carrier object is generated in the three-dimensional space scene, and the edge mask image of the target object is applied to the surface of the carrier object, wherein the center point of the carrier object is the location of the camera.
[0091] In one embodiment, before specifically implementing the embodiments of this disclosure, it is necessary to ensure that the browser supports WebGL. If the browser does not support it, a prompt message can be displayed to remind the user to upgrade the browser version.
[0092] In one embodiment, the user can trigger the generation operation via a button in the browser client interface, or trigger the object generation operation via related menu instructions to generate a carrier object.
[0093] The supporting object can be a sphere, a cube, or an object of other shapes.
[0094] In one embodiment, an assignment operation can be used to apply an edge mask image of the target object to the surface of a carrier object, and then the carrier object with the edge mask image applied can be placed into a three-dimensional spatial scene with the camera's location as the center point. The assignment operation is a function of the browser client, and this disclosure does not limit its scope.
[0095] In one embodiment, to implement the technical solution of this disclosure, it is necessary to generate the edge mask image and edge path information of the target object offline in advance. See also Figure 3B This illustrates a panoramic image. The edge mask image of this panoramic image can be generated using edge mask image generation algorithms from related technologies, such as... Figure 3C As shown, the edge mask image has the same resolution as the panoramic image.
[0096] It should be noted that edge mask images generated by algorithms often exhibit jagged edges; see [link / reference]. Figure 3D The locations indicated by reference numerals 31 and 32 in this embodiment of the present disclosure can achieve smoothing of burr phenomena.
[0097] It should be noted that at least one pixel (or all pixels) on the edge mask image and the edge path of the target object can be defined on a normalized image coordinate system.
[0098] The edge path information of the target object can be composed of some two-dimensional points in the image coordinate system, and can be input into the shader in the form of a two-dimensional array. The edge mask map of the target object can be input into the shader by pasting it onto the surface of the supporting object.
[0099] In one embodiment, when the edge mask image of the target object is applied to the surface of the carrier object and input into the shader, the pixel information of the edge mask image is also input into the corresponding shader. The pixel information may include the coordinates of the pixel and the corresponding pixel value.
[0100] In step 102, the edge mask image of the target object is read in the shader to obtain the coordinate information of at least one pixel on the edge of the target object.
[0101] In one embodiment, after the edge mask image of the target object is applied to the surface of the supporting object and input into the shader, the shader reads the pixel coordinates of each pixel on the edge mask image of the target object, and then reads the corresponding pixel value based on the pixel coordinates. The pixel value is then used to determine the pixel on the edge of the target object. For example, if the coordinates of a pixel on the edge mask image are (0.5, 0.5), the input pixel information shows that the pixel value of the pixel at coordinates (0.5, 0.5) is RGB(1,1,1), indicating that this pixel is white. Since the edge mask image defines the object edge as white and the background as black, the pixel at coordinates (0.5, 0.5) can be determined as a pixel on the edge of the target object. After reading the edge mask image of the target object and obtaining the pixel value of each pixel in the shader, the coordinate information of all pixels on the edge of the target object can be determined.
[0102] In step 103, the minimum distance between at least one pixel on the edge of the target object and the edge path is calculated based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path.
[0103] In one embodiment, based on the path information of the edge path, multiple line segments connecting the beginning and end of the edge path can be calculated. Then, the line segment distance between at least one pixel on the edge of the target object and the multiple line segments connecting the beginning and end of the edge path can be calculated. Thus, the minimum distance between at least one pixel on the edge of the target object and the edge path can be calculated. For details, please refer to [link to relevant documentation]. Figure 4 The embodiments shown are not described in detail here.
[0104] In step 104, the transparency of at least one pixel on the edge of the target object is determined based on the minimum distance between at least one pixel on the edge of the target object and the edge path, so as to achieve smoothing of the edge of the target object.
[0105] In one embodiment, when calculating the transparency of each pixel based on the minimum distance between at least one pixel on the edge of the target object and the edge path, a predefined formula (1) can be used:
[0106] alpha=1.0-k*normalize(distance(point,closedpoint)) Formula (1)
[0107] In equation (1), k is an empirical value, and normalize() is a normalization function used to normalize the minimum distance between the at least one pixel and the edge path.
[0108] Therefore, by using equation (1), the transparency of a pixel can be made closer to 0 the farther away from the edge path, thus achieving a smooth effect.
[0109] It should be noted that by controlling the empirical value k, the smoothing rate can be changed. The more jagged edges there are in the edge mask image, the larger k can be set to achieve fast smoothing.
[0110] Steps 101-104 above involve generating a carrier object in a 3D spatial scene and attaching the edge mask image of the target object to the surface of the carrier object, with the center point of the carrier object being the location of the camera. The edge mask image of the target object is read in the shader to obtain the coordinate information of at least one pixel on the edge of the target object. Based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path, the minimum distance between at least one pixel on the edge of the target object and the edge path is calculated. Based on the minimum distance between at least one pixel on the edge of the target object and the edge path, the transparency of at least one pixel on the edge of the target object is determined to achieve smoothing of the target object's edge. This disclosed technical solution can achieve edge smoothing of target objects in a panoramic image during spatial VR tours by calling a 3D texture application programming interface. By attaching the edge mask image of the target object to a 3D carrier object, the edge mask image can be read in the shader, and the transparency of at least one pixel on the edge of the target object can be set according to the distance between at least one pixel on the edge of the target object and the edge path, thus achieving smoothing of edge burrs in the edge mask image. This disclosed technical solution can perform smoothing of the original edge mask without based on the alpha channel.
[0111] To better illustrate the scheme of this disclosure for smoothing the edges of objects, another embodiment is described below.
[0112] Figure 2A This is a flowchart of an embodiment of the scanning display based on the method for smoothing object edges disclosed herein. Figure 2B For this disclosure Figure 2A The flowchart illustrating the implementation of step 202 in the illustrated embodiment is as follows: Figure 2C This is a schematic diagram of the edge of a frame of data in the sweeping light display of this disclosure, showing the angle of the display. This embodiment uses the example of how to achieve sweeping light display on the basis of edge smoothing for illustrative purposes. Figure 2A As shown, it includes the following steps:
[0113] In step 201, a user-triggered light-scanning display operation is received.
[0114] In one embodiment, the sweeping light display is a display effect with an edge sweeping light surround effect, and the user can trigger the sweeping light display operation through WebGL 2.0 menu commands, buttons and other operation methods.
[0115] In step 202, the sweeping display pixels of the initial frame are determined according to the starting angle and ending angle corresponding to the sweeping display operation.
[0116] In one embodiment, the specific implementation of determining the sweeping display pixels of the initial frame can be found in [reference needed]. Figure 2B This includes the following steps 221 and 222:
[0117] In step 221, the angle between the line connecting at least one pixel on the edge of the target object and the center point of the edge object and the positive x-axis is calculated.
[0118] In step 222, the pixels on the edge of the target object with the included angle between the starting angle and the ending angle are determined as the scanning display pixels of the initial frame.
[0119] In steps 221 and 222, the user can set the corresponding start angle and end angle on the operation interface, thereby determining the sweeping display pixels of the initial frame. For example, if the display angle range of the initial frame is 30 degrees to 90 degrees, the center point coordinates (x0, y0), the start angle of 30 degrees, and the end angle of 90 degrees of the target object can be passed to the fragment shader. The fragment shader can then calculate the angle between the line connecting the pixel point to the center point and the positive x-axis for each pixel point (x, y) on the edge of the target object. If the angle is within 30 degrees to 90 degrees, the pixel point is rendered. Pixel points outside this angle range are not rendered. By cyclically changing the display angle range, edge sweeping can be achieved.
[0120] It should be noted that, in addition to directly setting the starting angle and ending angle, a starting point A and an ending point B can also be selected based on the user's triggered operation. Then, the angle between the line connecting point A and the center point and the x-axis is calculated to obtain the starting angle, and the angle between the line connecting point B and the center point and the x-axis is calculated to obtain the ending angle. The initial frame's sweeping display pixels are then calculated, and subsequent sweeping is still based on the angle.
[0121] In step 203, the sweeping display pixels of any subsequent frame are determined according to the set display angle and set rotation direction.
[0122] In this context, "sweeping light display" can be understood as periodically displaying a portion of the edge according to a set display angle and rotation direction, where the positive direction of the x-axis can be defined as 0 degrees. See also... Figure 2C Set the display angle to the range of angles that need to be displayed in each frame, for example, Figure 2C The corresponding display angle is set to 60 degrees. Figure 2C The current frame needs to display the edge within an angle of 30-90 degrees (60-degree display range) (the edge segment indicated by label 21). Here, 30 degrees means that the angle between the line connecting pixel point A on the edge of the target object to the center point O and the positive x-axis is 30 degrees, and 90 degrees means that the angle between the line connecting pixel point B on the edge of the target object to the center point O and the positive x-axis is 90 degrees.
[0123] Setting the rotation direction refers to whether the sweeping light display rotates counterclockwise or clockwise. If the current frame needs to display an edge within an angle of 30-90 degrees (a display range of 60 degrees), and the rotation direction is set to counterclockwise, then the next frame needs to display an edge within an angle range of 90-150 degrees. This allows the edge to be displayed in each frame to be determined, and the sweeping light effect of the edge to be displayed is completed within one cycle.
[0124] In step 204, the scanned display pixels of each frame are rendered and highlighted, while the pixels on the edge of the target object other than the scanned display pixels are discarded.
[0125] In one embodiment, during the sweeping light display, for the edge of the target object in each frame of data, only the sweeping light display pixels can be rendered and highlighted, while pixels other than the sweeping light display pixels on the edge of the target object are omitted from rendering, thereby achieving the sweeping light display effect. The sweeping light display pixels in each frame include the sweeping light display pixels of the initial frame and the sweeping light display pixels of any subsequent frame.
[0126] In practice, the discard function can be used to discard the pixels on the edge of the target object that are outside the rendered and scanned pixels.
[0127] Through steps 201 to 204 above, based on the achievement of edge smoothing, the edge pixels to be displayed in each frame can be determined according to the set display angle and rotation direction, and the edge sweeping and surrounding effect can be completed within one cycle, while ensuring that the edge is relatively smooth; avoiding the problem that the edge sweeping and surrounding effect cannot be achieved when using the alpha channel to achieve edge smoothing in related technologies.
[0128] Figure 3A This is a flowchart illustrating an embodiment of the present disclosure for determining the coordinate information of at least one pixel on the edge of a target object. Figure 3B This is a schematic diagram of the panoramic view used in this disclosure to determine the location of the target object. Figure 3C This is the edge mask image of the target object in the panoramic view used to determine the location of the target object in this disclosure. Figure 3D This is a schematic diagram illustrating the burr effect of the target object edge mask image in the panoramic view of the target object in this disclosure; this embodiment uses the example of how to determine at least one pixel point on the edge of the target object for illustrative purposes. Figure 3A As shown, it includes the following steps:
[0129] In step 301, the pixel coordinates of at least one pixel point of the edge mask map are read in the shader.
[0130] In step 302, the pixel value of at least one pixel in the edge mask image is determined based on the pixel coordinates of at least one pixel in the edge mask image.
[0131] In step 303, the pixel with the set pixel value is determined as the pixel on the edge of the target object, and the coordinate information of the pixel on the edge of the target object is used as the coordinate information of the corresponding pixel on the edge of the target object.
[0132] In steps 301 to 303, after the edge mask image of the target object is applied to the surface of the supporting object and input into the shader, the shader can read the pixel coordinates of each pixel on the edge mask image of the target object. Based on the pixel coordinates, the corresponding pixel value can be read. The pixel with the pixel value RGB(1,1,1) is the pixel on the edge of the target object. For example, if the pixel coordinates are (0.5,0.5), based on the input pixel information, the pixel value of the pixel with coordinates (0.5,0.5) can be obtained as RGB(1,1,1), which is a white pixel. Since white is defined as the object edge and black as the background in the edge mask image, this pixel (0.5,0.5) is the pixel on the edge of the target object.
[0133] In one embodiment, by obtaining the pixel value of each pixel in the edge mask image of the target object, all pixels with a pixel value of RGB(1,1,1) can be obtained, that is, the pixels on the edge of the target object can be obtained.
[0134] Through steps 301 to 303 above, by attaching the edge mask image to a carrier object, the shader can read each pixel on the edge mask image, and then determine the edge of the target object based on the pixel value corresponding to the pixel.
[0135] Figure 4 This is a flowchart illustrating an embodiment of the present disclosure for calculating the minimum distance between at least one pixel on the edge of a target object and the edge path; this embodiment uses the example of how to determine the minimum distance between at least one pixel and the edge path as an example for illustrative purposes. Figure 4 As shown, it includes the following steps:
[0136] In step 401, based on the path information of the edge path, multiple line segments that are connected end to end of the edge path are calculated.
[0137] In one embodiment, after generating the edge path offline, multiple line segments connecting the beginning and end of the edge path can be calculated based on the coordinates of each two-dimensional point on the edge path.
[0138] In step 402, perpendicular lines are drawn from at least one pixel on the edge of the target object to each of the multiple line segments to obtain the distance between at least one pixel on the edge of the target object and the multiple line segments.
[0139] In one embodiment, by drawing perpendicular lines from at least one pixel on the edge of the target object to multiple line segments, the foot of the perpendicular for each line segment can be obtained, and the distance between each foot of the perpendicular and the pixel can be calculated, thus obtaining the distance between the pixel and each line segment.
[0140] In step 403, for at least one pixel on the edge of the target object, the minimum value among the distances to the multiple line segments is taken as the minimum distance to the edge path.
[0141] In one embodiment, after calculating the distance to each line segment of the edge path for at least one pixel on the edge of the target object, the minimum distance corresponding to each pixel is determined as the minimum distance between the corresponding pixel and the edge path.
[0142] By calculating the minimum distance between at least one pixel on the edge of the target object and the edge path in steps 401 to 403, it is possible to achieve a smoothing effect on the edge of the target object by making the transparency closer to 0 the farther away from the edge path and the transparency closer to 1 the closer to the edge path.
[0143] Corresponding to the foregoing embodiments of the method for smoothing object edges, this disclosure also provides embodiments of the apparatus for smoothing object edges.
[0144] Figure 5 This is a schematic diagram of one embodiment of the apparatus for smoothing object edges disclosed herein. The apparatus is applied to an electronic device (such as a computer system or server) that supports a WebGL browser client, such as... Figure 5 As shown, the device includes:
[0145] The first generation module 51 is used to generate a carrier object in a three-dimensional space scene in response to a generation operation triggered by the user, and to attach the edge mask image of the target object to the surface of the carrier object, wherein the center point of the carrier object is the location of the camera.
[0146] The reading module 52 is used to read the edge mask image of the target object in the shader to obtain the coordinate information of at least one pixel point on the edge of the target object;
[0147] The distance calculation module 53 is used to calculate the minimum distance between at least one pixel on the edge of the target object and the edge path based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path.
[0148] The transparency determination module 54 is used to determine the transparency of at least one pixel on the edge of the target object based on the minimum distance between at least one pixel on the edge of the target object and the edge path, so as to achieve smoothing of the edge of the target object.
[0149] Figure 6 This is a schematic diagram of another embodiment of the apparatus for smoothing the edges of an object disclosed herein, as shown below. Figure 6 As shown, in Figure 5 Based on the illustrated embodiment, in one embodiment, the reading module 52 includes:
[0150] The reading submodule 521 is used to read the pixel coordinates of at least one pixel point of the edge mask map in the shader;
[0151] The pixel value determination submodule 522 is used to determine the pixel value of at least one pixel in the edge mask image based on the pixel coordinates of at least one pixel in the edge mask image.
[0152] The first determining submodule 523 is used to determine the pixel point with the pixel value set as the pixel point on the edge of the target object, and use the coordinate information of the pixel point on the edge of the target object as the coordinate information of the corresponding pixel point on the edge of the target object.
[0153] In one embodiment, the distance calculation module 53 includes:
[0154] The calculation submodule 531 is used to calculate multiple line segments that are connected end to end in the edge path based on the path information of the edge path.
[0155] The perpendicular line submodule 532 is used to draw perpendicular lines to the multiple line segments starting from at least one pixel point on the edge of the target object, and to obtain the distance between at least one pixel point on the edge of the target object and the multiple line segments.
[0156] The second determining submodule 533 is used to determine the minimum distance among the distances to the plurality of line segments for at least one pixel point on the edge of the target object as the minimum distance to the edge path.
[0157] In one embodiment, the device further includes:
[0158] Receiver module 55 is used to receive the user-triggered light-scanning display operation;
[0159] The first determining module 56 is used to determine the scanning display pixels of the initial frame according to the starting angle and the ending angle corresponding to the scanning display operation;
[0160] The second determining module 57 is used to determine the sweeping display pixel point of any subsequent frame according to the set display angle and the set rotation direction;
[0161] The rendering module 58 is used to render and highlight the scanned display pixels in each frame, and discard the rendering of pixels on the edge of the target object other than the scanned display pixels.
[0162] In one embodiment, the first determining module 56 includes:
[0163] Angle calculation submodule 561 is used to calculate the angle between the line connecting at least one pixel point on the edge of the target object and the center point of the edge object and the positive direction of the x-axis;
[0164] The third determining submodule 562 is used to determine the pixel point on the edge of the target object with the included angle between the starting angle and the ending angle as the scanning display pixel point of the initial frame.
[0165] In one embodiment, the transparency determination module 54 is specifically used to calculate the transparency of at least one pixel on the edge of the target object using equation (1):
[0166] alpha=1.0-k*normalize(distance(point,closedpoint)) Formula (1)
[0167] In equation (1), k is an empirical value, and normalize() is a normalization function used to normalize the minimum distance between the at least one pixel and the edge path.
[0168] In one embodiment, the device further includes:
[0169] The second generation module 59 is used to generate the edge mask image of the target object and the edge path information of the target object offline.
[0170] The input module 60 is used to input the edge path information of the target object into the shader in the form of a two-dimensional array, and to input the edge mask image of the target object into the shader in the form of being pasted onto the surface of the carrying object.
[0171] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0172] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0173] Below, for reference Figure 7 This describes an electronic device according to embodiments of the present disclosure, wherein apparatus for implementing methods according to embodiments of the present disclosure may be integrated. Figure 7 This is a structural diagram of an electronic device provided in an illustrative embodiment of the present disclosure, such as... Figure 7 As shown, the electronic device includes one or more processors 71, one or more memory 72s of computer-readable storage media, and a computer program stored in the memory and executable on the processor. When the program in the memory 72 is executed, the method described above for smoothing the edges of an object can be implemented.
[0174] Specifically, in practical applications, the electronic device may also include components such as an input device 73 and an output device 74, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown). Those skilled in the art will understand that... Figure 7 The structure of the electronic device shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or certain components, or different component arrangements. Wherein:
[0175] The processor 71 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities. It performs various functions and processes data by running or executing software programs and / or modules stored in memory 72 and calling data stored in memory 72, thereby providing overall monitoring of the electronic device.
[0176] The memory 72 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 71 may execute the program instructions to implement the methods for smoothing object edges and / or other desired functions described in the various embodiments of this disclosure above. Various contents such as input signals, signal components, and noise components may also be stored in the computer-readable storage medium.
[0177] The input device 73 can be used to receive input digital or character information, and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0178] The output device 74 can output various information to the outside, including determined distance information, direction information, etc. The output device 74 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0179] Electronic devices may also include a power supply for powering various components, which can be logically connected to the processor 71 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. The power supply may also include one or more DC or AC power sources, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and any other components.
[0180] Of course, for the sake of simplicity, Figure 7Only some of the components of the electronic device relevant to this disclosure are shown, omitting components such as buses and input / output interfaces. In addition, the electronic device may include any other suitable components depending on the specific application.
[0181] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods for smoothing object edges according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.
[0182] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0183] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods for smoothing object edges according to various embodiments of this disclosure as described in the "Exemplary Methods" section above.
[0184] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0185] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0186] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0187] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as ROM, RAM, magnetic disk, or optical disk.
[0188] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0189] The description in this disclosure is provided for illustrative and descriptive purposes only and is not intended to be exhaustive or to limit the disclosure to its forms. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of this disclosure and to enable those skilled in the art to understand this disclosure and to design various embodiments with various modifications suitable for a particular purpose.
Claims
1. A method for smoothing the edges of an object, characterized in that, Applied to browser clients that support WebGL, the method includes: In response to a user-triggered generation operation, a carrier object is generated in a three-dimensional space scene, and the edge mask image of the target object is applied to the surface of the carrier object. The center point of the carrier object is the location of the camera. Read the edge mask image of the target object in the shader to obtain the coordinate information of at least one pixel on the edge of the target object; Based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path, calculate the minimum distance between at least one pixel on the edge of the target object and the edge path; The transparency of at least one pixel on the edge of the target object is determined based on the minimum distance between the pixel and the edge path, so as to achieve smoothing of the edge of the target object.
2. The method according to claim 1, characterized in that, The step of reading the edge mask image of the target object in the shader to obtain the coordinate information of at least one pixel point on the edge of the target object includes: Read the pixel coordinates of at least one pixel point of the edge mask map in the shader; The pixel value of at least one pixel in the edge mask image is determined based on the pixel coordinates of at least one pixel in the edge mask image. The pixel with the set pixel value is determined as the pixel on the edge of the target object, and the coordinate information of the pixel on the edge of the target object is used as the coordinate information of the corresponding pixel on the edge of the target object.
3. The method according to claim 1, characterized in that, The step of calculating the minimum distance between at least one pixel on the edge of the target object and the edge path based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path includes: Based on the path information of the edge path, calculate the multiple line segments that are connected end to end of the edge path; Starting from at least one pixel on the edge of the target object, draw perpendicular lines to each of the multiple line segments to obtain the distance between at least one pixel on the edge of the target object and the multiple line segments; For at least one pixel on the edge of the target object, the minimum value among the distances to the multiple line segments is taken as the minimum distance to the edge path.
4. The method according to claim 1, characterized in that, The method further includes: Receive user-triggered light-display operation; The sweeping display pixels of the initial frame are determined based on the starting angle and ending angle corresponding to the sweeping display operation. Based on the set display angle and set rotation direction, determine the sweeping display pixels for any subsequent frame; Render and highlight the scanned display pixels for each frame, and discard the rendering of pixels on the edge of the target object other than the scanned display pixels.
5. The method according to claim 4, characterized in that, The step of determining the initial frame's sweeping display pixels based on the start and end angles corresponding to the sweeping display operation includes: Calculate the angle between the line connecting at least one pixel on the edge of the target object and the center point of the edge object and the positive x-axis; The pixels on the edge of the target object with the included angle between the starting angle and the ending angle are determined as the scanning display pixels of the initial frame.
6. The method according to claim 1, characterized in that, Determining the transparency of at least one pixel on the edge of the target object based on the minimum distance between at least one pixel on the edge of the target object and the edge path includes: The transparency of at least one pixel on the edge of the target object is calculated using equation (1): alpha=1.0-k*normalize(distance(point,closedpoint)) Formula (1) In equation (1), k is an empirical value, and normalize() is a normalization function used to normalize the minimum distance between the at least one pixel and the edge path.
7. The method according to claim 1, characterized in that, The method further includes: The edge mask image and edge path information of the target object are generated offline. The edge path information of the target object is input into the shader in the form of a two-dimensional array, and the edge mask image of the target object is input into the shader in the form of being pasted onto the surface of the carrying object.
8. A device for smoothing the edges of an object, characterized in that, For use in browser clients that support WebGL, the apparatus includes: The first generation module is used to generate a carrier object in a three-dimensional space scene in response to a user-triggered generation operation, and to attach the edge mask image of the target object to the surface of the carrier object. The center point of the carrier object is the location of the camera. The reading module is used to read the edge mask image of the target object in the shader and obtain the coordinate information of at least one pixel point on the edge of the target object; The distance calculation module is used to calculate the minimum distance between at least one pixel on the edge of the target object and the edge path based on the coordinate information of at least one pixel on the edge of the target object and the path information of the edge path. The transparency determination module is used to determine the transparency of at least one pixel on the edge of the target object based on the minimum distance between at least one pixel on the edge of the target object and the edge path, so as to achieve smoothing of the edge of the target object.
9. An electronic device, characterized in that, include: Memory, used to store information in computer products; A processor for executing a computer product stored in the memory, wherein, when the computer product is executed, it implements the method described in any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions thereon, characterized in that, When the computer instructions are executed by the processor, they implement the method described in any one of claims 1-7.
Citation Information
Patent Citations
Image rendering method and device, equipment and medium
CN115965727A
Image forming device and image forming method
US20070279695A1