Graph drawing method and device, electronic equipment and storage equipment

By loading irregular shape design drawings, extracting outline paths and drawing graphics using operating system API, the problem of complex graphics needs extending cycles and installation package sizes in Android and Linux development is solved, and efficient and standardized irregular graphics drawing is achieved. and installation package optimization.

CN119068083APending Publication Date: 2024-12-03BEI DOU ZHI LIAN KE JI YOU XIAN GONG SI +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411262095.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In Android and Linux development, when facing complex and irregular graphics needs, developers need to rely on UI designers, resulting in project cycles being extended, and the mismatch between images and development specifications may introduce additional adjustments, increasing the application installation package size and increasing the application installation package Data processing burden.

Method used

By loading irregular shape design drawings, preprocessing to obtain intermediate images, obtain pixel thresholds, performing edge detection to extract outline paths, and drawing graphic outlines using the path class API interface of the target operating system and drawing shape classes to avoid introducing images resource.

Benefits of technology

It realizes efficient and standardized drawing of irregular graphics in Android and Linux development, optimizes the application installation package size, improves development efficiency and ensures product quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068083A_ABST
    Figure CN119068083A_ABST
Patent Text Reader

Abstract

The invention provides a graph drawing method and device, electronic equipment and a storage medium, and belongs to the field of data processing.The method comprises the steps that a design drawing of an irregular shape is preprocessed, an intermediate image is obtained, and a pixel threshold value is obtained; based on a pixel threshold, performing edge detection on the intermediate image to obtain edge pixel points of the intermediate image; according to each edge pixel point, obtaining a contour path of an irregular shape; and drawing a graph contour corresponding to the contour path by using a path type API interface and a drawing shape type of the target operating system to obtain a target graph. Thus, after the contour path with the irregular shape is extracted from the design drawing, the path type API interface and the drawing shape type are called to draw the corresponding image contour, so that in the operating system development process, irregular graphs can be efficiently and normatively drawn, image resources do not need to be introduced into an application program installation package, and the development efficiency is improved. And a developed application program installation package can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a graphics drawing method, device, electronic equipment and storage medium. Background Art

[0002] In current Android and Linux development practices, for areas such as user interface (UI) design and control design, especially in scenarios involving graphics drawing, it is usually possible to use the system's built-in regular shapes, such as line segments, rectangles, circles, ellipses, and rounded rectangles, to draw efficiently. However, when faced with complex and irregular graphics requirements, developers often need to seek support from UI designers to meet the requirements by providing design drawings. This dependence may not only prolong the project cycle, but may also lead to additional adjustments due to the mismatch between images and development specifications, thereby affecting the overall development process. Furthermore, the use of image resources not only increases the size of the Android application installation package, but may also introduce additional data processing burdens.

[0003] In view of the above challenges, there is an urgent need to explore an irregular graphics drawing solution that can significantly improve efficiency, optimize the size of application installation packages, and strictly follow development specifications, so as to help improve the efficiency of development work while ensuring that the final product meets high quality standards and meets user expectations. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a graphics drawing method, device, electronic device and storage medium, which can efficiently and strictly follow the development specifications to draw irregular graphics in the development of operating systems such as Android and Linux, and there is no need to introduce image resources in the developed application installation package, which greatly optimizes the size of the developed application installation package.

[0005] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0006] In a first aspect, the present invention provides a graphics drawing method, the method comprising:

[0007] Loading a design drawing of an irregular shape, preprocessing the design drawing, and obtaining an intermediate image;

[0008] Obtaining a pixel threshold according to the pixel value of the intermediate image;

[0009] Based on the pixel threshold, edge detection is performed on the intermediate image to obtain edge pixel points of the intermediate image;

[0010] Obtaining a contour path of the irregular shape according to each of the edge pixel points;

[0011] The path class API interface and the shape drawing class of the target operating system are used to draw the graphic outline corresponding to the outline path to obtain the target graphic.

[0012] Optionally, the step of performing edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image includes:

[0013] Using multiple blur scales respectively to denoise the intermediate image to obtain multiple denoised images;

[0014] For each of the denoised images, extracting preselected edge points from the denoised image according to the pixel threshold, and obtaining a binary image of the denoised image according to the preselected edge points;

[0015] The binary images are merged to obtain a composite image, and edge pixels are extracted from the composite image.

[0016] Optionally, the intermediate image includes a plurality of image blocks, and the pixel threshold includes a high threshold and a low threshold of each of the image blocks;

[0017] The step of extracting preselected edge points from the denoised image according to the pixel threshold comprises:

[0018] For each pixel of each of the image blocks, if the pixel value of the pixel is greater than a high threshold of the image block, the pixel is regarded as a strong edge point; if the pixel value of the pixel is between a high threshold and a low threshold of the image block, the pixel is regarded as a weak edge point;

[0019] For each of the weak edge points, when the weak edge point has an adjacent relationship with any of the strong edge points, the weak edge point is retained;

[0020] Each of the strong edge points and the retained weak edge points are used as pre-selected edge points.

[0021] Optionally, the step of merging the binary images to obtain a composite image comprises:

[0022] The binary images are combined through a logical OR operation to obtain a composite image.

[0023] Optionally, the step of using a plurality of blur scales to denoise the intermediate image to obtain a plurality of denoised images comprises:

[0024] Using multiple blur scales respectively, Gaussian blur processing is performed on the intermediate image to obtain multiple smooth images;

[0025] For each of the smoothed images, calculating the gradient amplitude of each pixel point of the smoothed image;

[0026] According to the gradient amplitude, non-maximum suppression is performed on each of the smoothed images to obtain a denoised image.

[0027] Optionally, the step of obtaining a pixel threshold according to the pixel value of the intermediate image comprises:

[0028] Dividing the intermediate image into a plurality of image blocks;

[0029] For each of the image blocks, a median value is obtained according to the pixel values ​​of each pixel point of the image block, and a high threshold value and a low threshold value of the image block are obtained according to the median value.

[0030] Optionally, the step of obtaining the contour path of the irregular shape according to each of the edge pixel points comprises:

[0031] Each of the edge pixel points is connected, and a morphological operation is performed on the path obtained after the connection to obtain the contour path of the irregular shape.

[0032] In a second aspect, the present invention provides a graphics drawing device, including a preprocessing module, a threshold acquisition module, an edge detection module, a path acquisition module and a drawing module;

[0033] The preprocessing module is used to load the design drawing of irregular shape, preprocess the design drawing, and obtain an intermediate image;

[0034] The threshold acquisition module is used to obtain a pixel threshold according to the pixel value of the intermediate image;

[0035] The edge detection module is used to perform edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image;

[0036] The path acquisition module is used to obtain the contour path of the irregular shape according to each of the edge pixels;

[0037] The drawing module is used to use the path class API interface and the drawing shape class of the target operating system to draw the graphic outline corresponding to the outline path to obtain the target graphic.

[0038] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement a graphics drawing method as described in any one of the aforementioned embodiments.

[0039] In a fourth aspect, the present invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a graphics drawing method as described in any one of the aforementioned embodiments.

[0040] The graphics drawing method, device, electronic device and storage medium provided by the embodiments of the present invention include: loading a design drawing of an irregular shape, preprocessing the design drawing to obtain an intermediate image; obtaining a pixel threshold according to the pixel value of the intermediate image; performing edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image; obtaining an irregular shape contour path according to each edge pixel point; using the path class API interface and the shape drawing class of the target operating system to draw the graphic contour corresponding to the contour path to obtain the target graphic. In this way, after extracting the contour path of the irregular shape from the design drawing, calling the path class API interface and the shape drawing class to draw the image contour corresponding to the contour path, in the process of operating system development, irregular graphics can be drawn quickly, efficiently and in a standardized manner, and there is no need to introduce image resources in the developed application installation package, which greatly optimizes the size of the developed application installation package.

[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 A block diagram of a graphics drawing system provided by an embodiment of the present invention is shown.

[0044] Figure 2 A block diagram of an electronic device provided by an embodiment of the present invention is shown.

[0045] Figure 3 One of the flowchart diagrams of the graphics drawing method provided by the embodiment of the present invention is shown.

[0046] Figure 4 Shows Figure 3 Schematic diagram of the process flow of some sub-steps of step 13.

[0047] Figure 5 Shows Figure 3 Schematic diagram of the process flow of some sub-steps of step 15.

[0048] Figure 6 Shows Figure 5 A flowchart of some sub-steps of step 151.

[0049] Figure 7 Shows Figure 5 A flowchart of some sub-steps of step 153.

[0050] Figure 8 A block diagram of a graphics drawing device provided by an embodiment of the present invention is shown.

[0051] Explanation of the accompanying drawings: 10 - graphics drawing system; 110 - development equipment; 120 - client terminal; 20 - electronic device; 210 - memory; 220 - processor; 230 - communication module; 30 - graphics drawing device; 310 - preprocessing module; 320 - threshold acquisition module; 330 - edge detection module; 340 - path acquisition module; 350 - drawing module. DETAILED DESCRIPTION

[0052] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0053] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.

[0054] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0055] The graphics drawing method provided by the embodiment of the present invention can be applied to Figure 1In the graphics drawing system 10 shown, the graphics drawing system 10 includes a development device 110 and a client terminal 120. The development device 110 can be communicatively connected with the client terminal 120 through networking, network connection, wired connection or other wireless connection.

[0056] The client terminal 120 is used to obtain a design drawing according to the user's drawing operation, or to scan or take a photo of the user's paper design drawing, and store the design drawing in the disk of the development device 110. The design drawing can be any design drawing of an irregular shape, for example, a design drawing depicting a human body, or a design drawing of a five-pointed star, etc.

[0057] The development device 110 is used to load the design drawing in the disk and implement the graphics drawing method provided by the embodiment of the present invention based on the design drawing.

[0058] The development device 110 may be, but is not limited to, a server, a server cluster, a personal computer, a laptop computer, a tablet computer, a mobile phone, or other mobile terminals. The client terminal 120 may be, but is not limited to, a scanning device, a personal computer, a tablet computer, a laptop computer, a camera, a mobile phone, a wearable portable device, or the like. It should be noted that the development device 110 and the client terminal 120 may be the same device or may be independent devices, which is not limited in this embodiment.

[0059] Please refer to Figure 2 , is a block diagram of an electronic device 20, the electronic device 20 may be Figure 1 The development device 110 in the graphics drawing system 10 shown. The electronic device 20 includes a memory 210, a processor 220 and a communication module 230. The memory 210, the processor 220 and the communication module 230 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0060] The memory 210 is used to store programs or data and can be, but not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable read-only memory, an electrically erasable read-only memory, and the like.

[0061] The processor 220 is used to read / write data or programs stored in the memory 210 and execute corresponding functions. For example, the processor 220 of the electronic device 20 executes the computer program stored in the memory 210 to implement the graphics drawing method provided by the embodiment of the present invention.

[0062] The communication module 230 is used to establish a communication connection between the electronic device 20 and other communication terminals through the network, and to send and receive data through the network. Figure 1 The client terminal 120 in sends and receives data.

[0063] It should be understood that Figure 2 The structure shown is only a schematic diagram of the structure of the electronic device 20. The electronic device 20 may also include Figure 2 More or fewer components as shown, or with Figure 2 Different configurations are shown. Figure 2 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0064] Please refer to Figure 3 The image acquisition method provided by the embodiment of the present invention may include steps 11 to 19. Figure 1 The development device 110 may Figure 2 The structure shown in FIG. 11 is executed through step 19 to implement the graphics drawing method.

[0065] Step 11, load the design drawing of the irregular shape, pre-process the design drawing, and obtain an intermediate image.

[0066] Step 13, obtaining a pixel threshold according to the pixel value of the intermediate image.

[0067] Step 15: Perform edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image.

[0068] Step 17, obtaining a contour path of an irregular shape according to each edge pixel point.

[0069] Step 19, using the path class API interface and shape drawing class of the target operating system, draw the graphic outline corresponding to the outline path to obtain the target graphic.

[0070] The target operating system may be, but is not limited to, an Android system, a Linux system, etc. In step 19, the contour path is composed of multiple straight lines, each of which is composed of two adjacent edge pixels, so the proportional relationship between the straight lines and the positional relationship between the edge pixels can be obtained from the contour path. Thus, the development device 110 can call a path class API interface (such as a straight line drawing function, etc.) to draw a graphic contour according to the positional relationship between the edge pixels and the proportional relationship between the straight lines. The shape of the image contour is consistent with the shape on the design drawing.

[0071] For example, in combination Figure 1The graphics drawing system 10 shown, when it is necessary to add a control background or graphics to an application developed on Android or Linux, and the control background or graphics is an irregular shape, the user can draw a design on paper, or use the client terminal 120 to scan or photograph the design, or use a drawing tool (such as Paint, CAD, etc.) on the client terminal 120 to draw the design, and store the design on the disk of the development device 110.

[0072] Next, the development device 110 loads the design drawing from the disk and performs preprocessing on the design drawing, such as cropping, filtering, noise reduction, etc., to obtain an intermediate image. Thus, based on the pixel value of each pixel point of the intermediate image, a pixel threshold for distinguishing the contour edge of the irregular shape is calculated. Furthermore, based on the pixel threshold, the development device 110 performs edge detection on the intermediate image to obtain the edge pixel points of the intermediate image, and obtains the contour path of the irregular shape based on all the obtained edge pixel points. The development device 110 calls the path class API interface and the shape drawing class of the target operating system, and draws the graphic contour corresponding to the contour path according to the positional relationship between the edge pixel points of the contour path and / or the proportional relationship between the straight lines, and the target graphic can be obtained. Finally, the target graphic can be written into the corresponding application.

[0073] It should be noted that the development device 110 can configure a unique identification number for the irregular shape, use the identification number as an index, and store the contour path of the irregular shape and / or the position coordinates of each point on the contour path. Therefore, in subsequent development, if a graphic of the same shape is to be drawn, it can be directly retrieved from the memory 210.

[0074] In the above-mentioned graphics drawing method, after extracting the contour path of the irregular shape from the design drawing, the path class API interface and the drawing shape class are called to draw the image contour corresponding to the contour path, so as to strictly follow the development specifications. Therefore, during the operating system development process, irregular graphics can be drawn quickly, efficiently and in a standardized manner, and there is no need to introduce image resources in the developed application installation package, which greatly optimizes the size of the developed application installation package.

[0075] Among them, in step 11, when the design drawing is preprocessed, the preprocessing method adopted can be flexibly selected, for example, it can be any one or several of cropping, image enhancement and filtering, and its specific implementation method is not limited.

[0076] In order to improve the contrast between the contour area required in the design and other areas, and to improve the accuracy of subsequent contour extraction, the concept of grayscale is introduced in the preprocessing. For example, the OpenCV library can be used to grayscale the design to obtain an intermediate image.

[0077] After obtaining the grayscale intermediate image, a variety of methods can be used to obtain the pixel threshold in step 13. For example, the pixel average value of the intermediate image can be calculated to obtain the pixel threshold, or the median pixel value of each pixel point in the intermediate image can be calculated to obtain the pixel threshold. The above methods are only examples, and the specific implementation method is not limited.

[0078] Considering the differences in brightness, clarity, and line thickness in different areas of the intermediate image, the pixel values ​​in different areas vary greatly. Therefore, in order to make the subsequent edge pixel extraction more accurate, the idea of ​​partitioning the intermediate image and dynamically calculating the pixel threshold is introduced in step 13. Figure 4 , step 13 may include steps 131 to 133.

[0079] Step 131, dividing the intermediate image into a plurality of image blocks.

[0080] The sizes and shapes of the multiple image blocks may be consistent or different, which is not limited in this embodiment. In addition, the intermediate image may be divided into 9 image blocks in a nine-square grid manner, or the intermediate image may be divided into image blocks according to brightness, line thickness or clarity.

[0081] For example, the brightness or clarity of each area of ​​the intermediate image is obtained, the intermediate image is partitioned according to the brightness or clarity, and the intermediate image is divided into multiple image blocks according to the partition result.

[0082] Step 133 , for each image block, a median value is obtained according to the pixel value of each pixel point of the image block, and a high threshold and a low threshold of the image block are obtained according to the median value.

[0083] It should be understood that the median value is the median value of the pixel values ​​at each point in the image block, and the median value may also be replaced by an average value, etc. Moreover, after obtaining the median value, the preset empirical value is subtracted from the median value to obtain the low threshold value of the image block, and the preset empirical value is added to the median value to obtain the high threshold value of the image block.

[0084] It should be noted that the above method of obtaining pixel thresholds is only an example, and any other method of obtaining thresholds can be used to replace it in actual applications.

[0085] After the pixel thresholds of each image block are adaptively obtained through the above steps 131 to 133, the edge pixel points in the intermediate image can be obtained in multiple ways in step 15. For example, an edge detection method can be used to extract edge contour pixel points of irregular shapes, and a pre-trained neural network model can be used to extract edge contour pixel points of irregular shapes. In addition, the above two methods are only examples, and the implementation method of obtaining edge pixel points in the intermediate image is not limited.

[0086] In order to make the edge pixel points obtained more accurate, the concept of combining multi-scale denoising and edge detection is introduced in the process of extracting edge pixel points in step 15. Figure 5 The process of obtaining edge pixel points of the intermediate image in step 15 may include steps 151 to 155.

[0087] Step 151 , denoising the intermediate image using multiple blur scales respectively, to obtain multiple denoised images.

[0088] Step 153 , for each denoised image, pre-selected edge points are extracted from the denoised image according to the pixel threshold, and a binary image of the denoised image is obtained according to the pre-selected edge points.

[0089] Step 155, merging the binary images to obtain a composite image, and extracting edge pixels from the composite image.

[0090] There are many methods that can be used to perform denoising in step 151, for example, wavelet transform denoising, bilateral filtering, or Gaussian blurring. In this embodiment, the multi-scale denoising method is not limited.

[0091] In order to make the edges in the denoised image more accurate, clear, smooth and coherent, a Gaussian blur and non-maximum suppression combined processing can be introduced in step 151 to obtain the concept of the denoised image. Figure 6 , multiple denoised images can be obtained through steps 1511 to 1515.

[0092] Step 1511 , using multiple blur scales respectively, performs Gaussian blur processing on the intermediate image to obtain multiple smooth images.

[0093] The number and size of the fuzzy scales can be arbitrarily selected, for example, there can be three fuzzy scales about the standard deviation, which are 1, 2, and 4, or there can be four fuzzy scales about the standard deviation, which are 1, 2, 3, and 4. There can also be fuzzy scales about the kernel size, for example, the kernel size can be 3 and 5, or the kernel size can be 3, 5, and 9. The above method is only an example, and its specific setting is not limited.

[0094] Step 1513: For each smoothed image, calculate the gradient amplitude of each pixel point of the smoothed image.

[0095] The method for calculating the gradient in the above step 1513 can be flexibly set, for example, it can be a Sobel operator, a Prewitt operator, a Roberts cross operator, a Scharr operator or any other method for calculating the image gradient, which is not limited in this embodiment. In this way, the gradient components in the horizontal and vertical directions of the smoothed image are estimated by the gradient calculation operator, and then the gradient components in the horizontal and vertical directions are combined to obtain the gradient intensity of each pixel point.

[0096] Step 1515, performing non-maximum suppression on each smoothed image according to the gradient amplitude to obtain a denoised image.

[0097] After executing the above step 1513 to obtain the gradient amplitude of each smoothed image, each smoothed image can be divided into multiple small areas in step 1515, for example, it can be divided into 1000 small areas, etc., and the pixel points with the maximum gradient amplitude in each small area are retained, and the pixel points with non-maximum gradient amplitude are suppressed to obtain a denoised image.

[0098] After obtaining the denoised image through the above steps 1511 to 1515, a variety of methods can be used in step 153 to extract pre-selected edge points from the denoised image. For example, pixel points whose pixel values ​​are greater than the pixel threshold can be used as pre-selected edge points, or pixel points whose relationship with the pixel threshold meets preset conditions can be used as pre-selected edge points, which is not limited in this embodiment.

[0099] In order to obtain all pre-selected edge points as much as possible and make the pre-selected edge points more accurate, the concept of combining the adjacency of edge points and the pixel threshold adaptive extraction of each image block is introduced in step 153. Based on the pixel thresholds of multiple image blocks obtained in the above step 13, refer to Figure 7 , step 153 may include steps 1531 to 1535.

[0100] Step 1531, for each pixel of each image block, if the pixel value of the pixel is greater than the high threshold of the image block, the pixel is regarded as a strong edge point; if the pixel value of the pixel is between the high threshold and the low threshold of the image block, the pixel is regarded as a weak edge point.

[0101] It should be understood that, for a pixel point whose pixel value is less than a low threshold value of an image block, the pixel point is suppressed.

[0102] Step 1533: for each weak edge point, when the weak edge point has an adjacent relationship with any strong edge point, the weak edge point is retained.

[0103] By way of example, for each weak edge point, the distance between the weak edge point and the strong edge points around it can be calculated. If there is a strong edge point whose distance is less than a preset distance threshold, the weak edge point is considered to be adjacent to the strong edge point and is an edge point, and the weak edge point is retained.

[0104] Step 1535: Use each strong edge point and the retained weak edge point as pre-selected edge points.

[0105] Through the above steps 1531 to 1535, the corresponding pixel thresholds are used in different image blocks to realize adaptive extraction of pre-selected edge points, which can avoid the situation where some edge points are omitted due to using the same pixel threshold for areas with different brightness or clarity. At the same time, weak edge points adjacent to strong edge points are also retained to further avoid missing edge points. Therefore, all pre-selected edge points are obtained as much as possible, and the pre-selected edge points are made more accurate.

[0106] After all pre-selected edge points in the denoised image are extracted using the above steps 1531 to 1535, in order to facilitate the merging operation in the subsequent step 155, the pre-selected edge points in the denoised image can be set to 1 and other pixels can be set to 0 in step 153 to obtain a binary image. It should be understood that the pre-selected edge points in the denoised image can also be set to 0 and other pixels can be set to 1 to obtain a binary image.

[0107] After obtaining the binary images of each denoised image, they can be merged in a variety of ways in step 155. For example, the binary images can be merged using any existing logical operation, or using a preset rule, which is not limited in this embodiment.

[0108] In order to retain the pixels that may be edge points in the integrated image, the binary images are combined by a logical OR operation to obtain the integrated image in step 155. Then, the pixels that represent edge points in the integrated image are taken as edge pixels.

[0109] For example, when the binary image sets the pre-selected edge points to 1 and the other pixels to 0, for each pixel, if there is at least one binary image in which the pixel is 1, the pixel is set to 1. In this way, a comprehensive image can be obtained, and the pixels in the comprehensive image that are 1 are taken as edge pixels.

[0110] Similarly, when the binary image sets the pre-selected edge points to 0 and the other pixels to 1, for each pixel, if there is at least one binary image where the pixel is 0, the pixel is set to 0. In this way, a comprehensive image can be obtained, and the pixels that are 0 in the comprehensive image are taken as edge pixels.

[0111] Furthermore, by establishing a coordinate system for the comprehensive image, the position coordinates of each edge pixel can be obtained.

[0112] Through the above steps 151 to 155 and related sub-steps, all edge pixel points and their position coordinates can be extracted quickly and accurately.

[0113] After all edge pixels are obtained, the edge pixels are connected in a nearest neighbor connection manner to obtain the irregular contour path in the design drawing. In order to make the obtained contour path smoother, in step 17, each edge pixel can be connected, and a morphological operation can be performed on the path obtained after the connection to obtain the irregular contour path. Thus, the edge is smoothed by the morphological operation, so that the obtained contour path is smoother.

[0114] After obtaining the contour path, in step 19, the path class API interface of the target operating system is called to create the path in combination with the position coordinates between the points on the contour path, and the shape drawing class (i.e., ShapeDrawable class) is called to draw the points, and the drawn points are connected in the order of connection of the points on the contour path, and the target graphics that strictly follow the development specifications can be obtained. The generated target image can be used as a control background or an ImageView picture.

[0115] Based on the same inventive concept as the above-mentioned graphics drawing method, refer to Figure 8 The embodiment of the present invention further provides a graphics drawing device 30 , including a preprocessing module 310 , a threshold acquisition module 320 , an edge detection module 330 , a path acquisition module 340 and a drawing module 350 .

[0116] The preprocessing module 310 is used to load the design drawing of irregular shape, preprocess the design drawing, and obtain an intermediate image.

[0117] The threshold acquisition module 320 is used to obtain a pixel threshold according to the pixel value of the intermediate image.

[0118] The edge detection module 330 is used to perform edge detection on the intermediate image based on a pixel threshold to obtain edge pixel points of the intermediate image.

[0119] The path acquisition module 340 is used to obtain the contour path of the irregular shape according to each edge pixel point.

[0120] The drawing module 350 is used to draw the graphic outline corresponding to the outline path by using the path class API interface and the drawing shape class of the target operating system to obtain the target graphic.

[0121] The above-mentioned graphics drawing device 30, under the coordinated action of the preprocessing module 310, the threshold acquisition module 320, the edge detection module 330, the path acquisition module 340 and the drawing module 350, extracts the contour path of the irregular shape from the design drawing, and then calls the path class API interface and the drawing shape class to draw the image contour corresponding to the contour path. In this way, during the operating system development process, irregular graphics can be drawn quickly, efficiently and in a standardized manner, and there is no need to introduce image resources in the developed application installation package, which greatly optimizes the size of the developed application installation package.

[0122] For the specific implementation and effect of the graphics drawing device 30, please refer to the description of the implementation of the graphics drawing method above, such as, the specific implementation and effect of the preprocessing module 310 please refer to the description of the relevant content of step 11 above, the specific implementation and effect of the threshold acquisition module 320 please refer to the description of the relevant content of step 13 above, the specific implementation and effect of the edge detection module 330 please refer to the description of the relevant content of step 15 above, the specific implementation and effect of the path acquisition module 340 please refer to the description of the relevant content of step 17 above, the specific implementation and effect of the drawing module 350 please refer to the description of the relevant content of step 19 above, and no further details will be given here.

[0123] In addition, each module in the above-mentioned graphics drawing device 30 can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor 220 in the electronic device 20 in the form of hardware, or can be stored in the memory 210 of the electronic device 20 in the form of software, so that the processor 220 can call and execute the operations corresponding to the above-mentioned modules to implement the graphics drawing method provided above.

[0124] Based on the same inventive concept as the above-mentioned graphics drawing method, an embodiment of the present invention also provides an electronic device 20, including a processor 220 and a memory 210, the memory 210 stores a computer program that can be executed by the processor 220, and the processor 220 can execute the computer program to implement the graphics drawing method proposed in the embodiment of the present invention.

[0125] The embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by the processor 220, the graphics drawing method proposed in the embodiment of the present invention is implemented.

[0126] In addition, an embodiment of the present invention further provides a computer program product, which includes computer instructions, wherein when the computer instructions are executed by the processor 220, the graphics drawing method proposed in the embodiment of the present invention is implemented.

[0127] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0128] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0129] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0130] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A graphics drawing method, characterized in that: The method comprises: Loading a design drawing of an irregular shape, preprocessing the design drawing, and obtaining an intermediate image; Obtaining a pixel threshold according to the pixel value of the intermediate image; Based on the pixel threshold, edge detection is performed on the intermediate image to obtain edge pixel points of the intermediate image; Obtaining a contour path of the irregular shape according to each of the edge pixel points; The path class API interface and the shape drawing class of the target operating system are used to draw the graphic outline corresponding to the outline path to obtain the target graphic.

2. The graphics drawing method according to claim 1, characterized in that: The step of performing edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image includes: Using multiple blur scales respectively to denoise the intermediate image to obtain multiple denoised images; For each of the denoised images, extracting preselected edge points from the denoised image according to the pixel threshold, and obtaining a binary image of the denoised image according to the preselected edge points; The binary images are merged to obtain a composite image, and edge pixels are extracted from the composite image.

3. The graphics drawing method according to claim 2, characterized in that: The intermediate image includes a plurality of image blocks, and the pixel threshold includes a high threshold and a low threshold of each of the image blocks; The step of extracting preselected edge points from the denoised image according to the pixel threshold comprises: For each pixel of each of the image blocks, if the pixel value of the pixel is greater than a high threshold of the image block, the pixel is regarded as a strong edge point; if the pixel value of the pixel is between a high threshold and a low threshold of the image block, the pixel is regarded as a weak edge point; For each of the weak edge points, when the weak edge point has an adjacent relationship with any of the strong edge points, the weak edge point is retained; Each of the strong edge points and the retained weak edge points are used as pre-selected edge points.

4. The graphics drawing method according to claim 2, characterized in that: The step of merging the binary images to obtain a composite image comprises: The binary images are combined through a logical OR operation to obtain a composite image.

5. The graphics drawing method according to claim 2, characterized in that: The step of using a plurality of blur scales to denoise the intermediate image to obtain a plurality of denoised images comprises: Using multiple blur scales respectively, Gaussian blur processing is performed on the intermediate image to obtain multiple smooth images; For each of the smoothed images, calculating the gradient amplitude of each pixel point of the smoothed image; According to the gradient amplitude, non-maximum suppression is performed on each of the smoothed images to obtain a denoised image.

6. The graphics drawing method according to any one of claims 1 to 5, characterized in that: The step of obtaining a pixel threshold according to the pixel value of the intermediate image comprises: Dividing the intermediate image into a plurality of image blocks; For each of the image blocks, a median value is obtained according to the pixel values ​​of each pixel point of the image block, and a high threshold value and a low threshold value of the image block are obtained according to the median value.

7. The graphics drawing method according to any one of claims 1 to 5, characterized in that: The step of obtaining the contour path of the irregular shape according to each of the edge pixel points comprises: Each of the edge pixel points is connected, and a morphological operation is performed on the path obtained after the connection to obtain the contour path of the irregular shape.

8. A graphics drawing device, characterized in that: It includes a preprocessing module, a threshold acquisition module, an edge detection module, a path acquisition module and a drawing module; The preprocessing module is used to load the design drawing of irregular shape, preprocess the design drawing, and obtain an intermediate image; The threshold value acquisition module is used to obtain a pixel threshold value according to the pixel value of the intermediate image; The edge detection module is used to perform edge detection on the intermediate image based on the pixel threshold to obtain edge pixel points of the intermediate image; The path acquisition module is used to obtain the contour path of the irregular shape according to each of the edge pixels; The drawing module is used to draw the graphic outline corresponding to the outline path by using the path class API interface and the drawing shape class of the target operating system to obtain the target graphic.

9. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the graphics drawing method according to any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the graphics drawing method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Animation coloring method and device based on video generation model

    CN119693507A