A method for generating a lamp strip modeling diagram, an electronic device, and a storage medium
By extracting the equivalent outer contour from the target image and removing feature points that do not meet the conditions, a light strip shape image is generated, which solves the problem of unclear target object contours, enabling users to accurately create beautiful shapes and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN INTELLIROCKS TECH CO LTD
- Filing Date
- 2025-02-14
- Publication Date
- 2026-04-28
AI Technical Summary
In existing technologies, the outline of the target object in the image or picture is not clear enough, making it difficult for users to accurately shape the animal or human figure, which affects the user experience.
By acquiring the target image, determining the equivalent outer contour of the target object, eliminating key feature points that do not meet the preset concave condition, generating the target contour, and rendering the target contour based on the light strip layout information, a light strip shape drawing is obtained.
It provides clear and personalized light strip design diagrams, allowing users to create accurate and aesthetically pleasing shapes based on these diagrams, enhancing both fun and user experience.
Smart Images

Figure CN119741399B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method for generating a light strip pattern, an electronic device, and a storage medium. Background Technology
[0002] With the increasing prevalence and development of mobile devices, users are becoming more and more reliant on them. These devices can accommodate a wide variety of applications, such as video apps, which users use to watch pictures or videos for entertainment. In some cases, users are interested in the animal or human figures depicted in these video apps and want to create their own likenesses.
[0003] Currently, most users capture images from videos or save pictures and directly model animals or people based on their appearance. However, because the images or pictures contain other objects unrelated to animals or people (such as various appliances, furniture, etc.), and the influence of light makes the outlines of animals or people unclear, users cannot distinguish them with the naked eye. As a result, it is difficult for users to accurately model animals or people using light strips, which cannot satisfy users' desire for fun activities and leads to a poor user experience. Summary of the Invention
[0004] In view of this, one objective of the present invention is to provide a method, electronic device and storage medium for generating a light strip shape image, in order to solve the technical problem in the prior art where the outline of the target object in the image or picture is not clear enough, making it difficult for users to create an accurate shape of the target object.
[0005] To address the aforementioned technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] In a first aspect, embodiments of the present invention provide a method for generating a light strip design, comprising:
[0007] Acquire a target image, wherein the target image includes the target image region occupied by the target object;
[0008] Based on the target image, an equivalent outer contour corresponding to the target object is determined, and the equivalent outer contour includes multiple key feature points;
[0009] In response to user input of smoothing parameters for the equivalent outer contour, key feature points that do not meet the preset concaveness condition are removed from the equivalent outer contour to obtain multiple candidate feature points;
[0010] Generate the target contour based on multiple candidate feature points;
[0011] Light strip layout information is generated based on a preset interval distance. The light strip layout information is used to indicate the positions of light strip segments of different colors on the target outline.
[0012] The target outline is rendered based on the light strip layout information to obtain a light strip shape drawing.
[0013] In some embodiments, determining the equivalent outer contour corresponding to the target object based on the target image includes:
[0014] The outer contour of the target object is extracted from the target image, and the outer contour includes multiple contour feature points;
[0015] In response to user input of precision parameters regarding the outer contour, multiple key feature points are selected from multiple contour feature points;
[0016] The equivalent outer contour is generated based on multiple key feature points.
[0017] In some embodiments, extracting the outer contour of the target object from the target image includes:
[0018] The target image region occupied by the target object is segmented from the target image to obtain a binary contour map, wherein the pixel value of the target image region is the first pixel value, and the pixel value of the image region in the target image excluding the target image region is the second pixel value;
[0019] The outer contour of the target object is extracted from the binary contour map based on a preset edge detection algorithm.
[0020] In some embodiments, segmenting the target image region occupied by the target object from the target image to obtain a binarized contour map includes:
[0021] In response to a user's selection operation on the target image region, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map; or...
[0022] In response to user input of text content regarding the segmentation of the target image region, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map; or...
[0023] In response to the default segmentation command, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map, wherein the target object is the object captured in focus in the target image.
[0024] In some embodiments, the smoothing parameter includes a preset angle threshold. The smoothing parameter, responding to user input regarding the equivalent outer contour, removes key feature points from the equivalent outer contour that do not meet a preset concave condition, resulting in multiple candidate feature points, including:
[0025] Obtain the user's input regarding the preset angle threshold of the equivalent outer contour;
[0026] Calculate the angle value corresponding to each of the key feature points;
[0027] By removing key feature points with angle values less than the preset angle threshold from the equivalent outer contour, multiple candidate feature points are obtained.
[0028] In some embodiments, calculating the angle value corresponding to each of the key feature points includes:
[0029] For any key feature point, determine the preceding and following key feature points corresponding to the key feature point.
[0030] The angle formed by the first line segment and the second line segment is determined as the angle value corresponding to the key feature point. The first line segment is the line segment connecting the previous key feature point and the key feature point, and the second line segment is the line segment connecting the key feature point and the next key feature point.
[0031] In some embodiments, generating the target contour based on the plurality of candidate feature points includes:
[0032] Multiple reference feature points are generated based on the multiple candidate feature points, wherein the distance between any two adjacent reference feature points is the same;
[0033] Perform curve fitting on all the reference feature points to obtain the reference contour;
[0034] Determine the perimeter of the reference profile;
[0035] Based on the preset light strip length, the reference contour is scaled so that the perimeter of the scaled reference contour is consistent with the preset light strip length.
[0036] In some embodiments, generating light strip arrangement information based on a preset interval distance includes:
[0037] Based on a preset interval distance, multiple reference feature points are sampled at equal intervals on the target contour, and the line segment between any two adjacent reference feature points is a sub-contour line segment.
[0038] Multiple light strip arrangement information corresponding to the multiple sub-contour segments are generated based on the multiple sub-contour segments, and one sub-contour segment corresponds to one light strip arrangement information.
[0039] In some embodiments, the light strip arrangement information includes the color of the light strip segments and the position of the light strip segments on the target contour. Rendering the target contour based on the light strip arrangement information to obtain a light strip shape drawing includes:
[0040] For any given light strip segment, the sub-contour segment corresponding to the light strip segment is determined as the target sub-contour segment based on the position of the light strip segment on the target contour.
[0041] The color of the target sub-contour line segment is rendered as the color of the light strip segment to obtain the light strip shape image, wherein any two adjacent sub-contour line segments have different colors.
[0042] In a second aspect, embodiments of the present invention provide an electronic device, comprising:
[0043] A processor and a memory communicatively connected to the processor;
[0044] The memory stores computer program instructions executable by the processor, which, when invoked by the processor, cause the processor to execute any of the methods for generating the light strip design proposed in the first aspect.
[0045] Thirdly, embodiments of the present invention provide a computer-readable storage medium storing processor-executable computer program instructions, which, when invoked by a processor, cause the processor to execute any of the methods for generating a light strip design diagram proposed in the first aspect.
[0046] The embodiments of the present invention have the following beneficial effects: Unlike the prior art, the method for generating a light strip shape image provided by the embodiments of the present invention includes: acquiring a target image, the target image including a target image region occupied by a target object; determining an equivalent outer contour corresponding to the target object based on the target image, the equivalent outer contour including multiple key feature points; responding to user input of smoothing parameters about the equivalent outer contour; removing key feature points that do not meet the preset concave condition from the equivalent outer contour to obtain multiple candidate feature points; generating a target contour based on the multiple candidate feature points; generating light strip arrangement information based on a preset interval distance, the light strip arrangement information being used to represent the position of light strip segments of different colors on the target contour; and rendering the target contour based on the light strip arrangement information to obtain a light strip shape image.
[0047] This invention extracts the equivalent outer contour of the target object from the target image, generates the target contour corresponding to the target object based on the smoothing parameters input by the user, and performs personalized rendering of the target contour based on the light strip layout information to obtain the light strip shape image. In this way, a clear and personalized light strip shape image can be provided to the user, and the user can create an accurate and beautiful shape based on the light strip shape image, thereby enhancing the fun and user experience. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the prior art or embodiments will be briefly introduced below. Obviously, the drawings described below only show some embodiments of the present invention and should not be considered as limiting the scope of protection. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram illustrating an application scenario of generating a light strip design in some embodiments of the present invention;
[0050] Figure 2 These are schematic diagrams of the structure of an electronic device provided in some embodiments of the present invention;
[0051] Figure 3 This is a flowchart illustrating the method for generating a light strip design diagram according to some embodiments of the present invention;
[0052] Figure 4 These are target images provided in some embodiments of the present invention;
[0053] Figure 5 These are binarized contour images of the target object provided in some embodiments of the present invention;
[0054] Figure 6 yes Figure 5 The embodiment shows a schematic diagram of the contour obtained by extracting the outer contour of the target object;
[0055] Figure 7 This is a schematic diagram of a contour provided by some embodiments of the present invention for filtering multiple key feature points;
[0056] Figure 8 This is another schematic diagram of the contour provided by some embodiments of the present invention for filtering multiple key feature points;
[0057] Figure 9 This is another schematic diagram of the contour provided by some embodiments of the present invention for filtering multiple key feature points;
[0058] Figure 10 These are LED strip design diagrams provided in some embodiments of the present invention. Detailed Implementation
[0059] To make the objectives and advantages of the embodiments of the present invention more readily understood, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. The detailed description of the embodiments of the present invention in the accompanying drawings is not intended to limit the scope of protection claimed by the present invention, but only to illustrate 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 creative effort are within the scope of protection of the present invention.
[0060] It should be noted that, unless there is a conflict, the various technical features involved in the embodiments of the present invention described below can be combined with each other, and all are within the protection scope of the present invention. Furthermore, although functional modules are divided in the device or structural schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. In addition, the terms "first," "second," "third," and other similar expressions used herein do not limit the data or execution order, but are only for illustrative purposes and to distinguish identical or similar items with substantially the same function and effect, and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features.
[0061] Unless otherwise defined, the technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. It should be understood that the term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0062] With the increasing prevalence and development of mobile devices, users are becoming more and more reliant on them. These devices can accommodate a wide variety of applications, such as video apps, which users use to watch pictures or videos for entertainment. In some cases, users are particularly interested in the plant, animal, or human figures depicted in these video apps and want to create their own likenesses.
[0063] Currently, most users capture images from videos or save pictures and directly model plants, animals, or people based on their shapes. However, the inventors discovered that because the images or pictures include other distracting objects unrelated to the plants, animals, or people (e.g., various appliances, furniture), and because the lighting affects the clarity of the plant, animal, or person outlines, users cannot visually distinguish the outlines. Therefore, it is difficult for users to use light strips to create accurate and aesthetically pleasing plant, animal, or person shapes, resulting in lower fun and a poor user experience.
[0064] In view of this, embodiments of the present invention provide a method for generating a light strip design image. This method involves extracting the target image region occupied by a target object (such as an animal, plant, or person) from an image or picture to obtain the equivalent outer contour corresponding to the target object. Based on smoothing parameters input by the user, feature points that do not meet preset concaveness conditions are removed from the equivalent outer contour, and a target contour corresponding to the target object is generated. The target contour is then rendered in a personalized manner based on light strip arrangement information to obtain a light strip design image. The light strip arrangement information indicates the positions of different colored light strip segments on the target contour. This provides users with a clear and personalized light strip design image, enabling them to create accurate and aesthetically pleasing designs based on the image, enhancing both enjoyment and user experience.
[0065] Please see Figure 1 , Figure 1 The illustration shows an application scenario diagram of the generated light strip design provided by some embodiments of the present invention.
[0066] Specifically, such as Figure 1 As shown, this application scenario includes an electronic device 100, which processes the acquired target image 101 to obtain a light strip design diagram 102 and outputs the light strip design diagram 102. In some embodiments, the electronic device 100 can be any suitable type of terminal device such as a laptop computer, desktop computer, tablet computer, or smartphone. In other embodiments, the electronic device 100 can also be any suitable type of component such as a microcontroller, microprocessor, or FPGA chip.
[0067] In some embodiments, a user can input the target image 101 to the electronic device 100 via a smart terminal such as a smartphone or tablet. For example, the user connects the smartphone or tablet to the electronic device 100 and sends the target image 101 to the electronic device 100, thereby the electronic device 100 obtains the target image 101.
[0068] In some embodiments, users can also access the target image 101 through the electronic device 100 by visiting an APP, webpage, etc. For example, they can access the webpage link of "Visual China" and filter to obtain the target image 101 they need.
[0069] Target image 101 includes a target object, for example, Figure 1 The tree enclosed by the rectangle in the target image 101 shown occupies a corresponding image area in the target image 101. After acquiring the target image 101, the electronic device 100 processes the target image 101 to extract the equivalent outer contour corresponding to the target object. The equivalent outer contour includes multiple key feature points.
[0070] The user inputs the smoothing parameters of the equivalent outer contour to the electronic device 100. The electronic device 100 removes key feature points that do not meet the preset concave condition from the equivalent outer contour according to the smoothing parameters, and retains multiple key feature points that meet the concave condition, thereby obtaining multiple candidate feature points. The target contour corresponding to the target object is generated based on the multiple candidate feature points, and light strip layout information is generated according to the preset interval distance. The light strip layout information is used to indicate the position of light strip segments of different colors on the target contour.
[0071] Based on the LED strip layout information, the electronic device 100 uses image processing technology to render the corresponding colors at various positions in the target outline to obtain an accurate, beautiful, and personalized LED strip design diagram 102. The electronic device 100 outputs and displays the LED strip design diagram 102, enabling users to create accurate and beautiful designs based on the LED strip design diagram 102, thereby enhancing the fun and user experience.
[0072] It should be understood that Figure 1 This is merely an illustrative representation of one scenario where the electronic device 100 extracts the equivalent outer contour of the target object from the target image 101 and generates a corresponding light strip shape image 102. Figure 1 In the illustrated application scenario, electronic device 100 is a laptop computer, but this does not limit the structure, type, or quantity of electronic devices in other application scenarios or embodiments. For example, in some other application scenarios or embodiments, the electronic device may also be a desktop computer, tablet computer, or other suitable type of device, and the electronic device in some other application scenarios or embodiments may also be... Figure 1 The laptop shown includes more or fewer components, or has the same... Figure 1 The laptops shown have different configurations.
[0073] To facilitate understanding of the method for generating the LED strip design provided in the embodiments of the present invention, the electronic device provided in the embodiments of the present invention will first be described in detail.
[0074] Please see Figure 2 , Figure 2 A schematic diagram of the structure of an electronic device provided in some embodiments of the present invention is shown.
[0075] like Figure 2 As shown, the electronic device 100 includes at least one processor 110 and a memory 120 connected in communication. Figure 2Taking a bus system 130 and a processor as an example, the various components in electronic device 100 are coupled together through the bus system 130, which is used to realize communication between the various components. It is easy to understand that the bus system 130 may include not only a data bus, but also a power bus, a control bus, and a status signal bus, etc. However, for clarity and brevity, in... Figure 2 The general labels all buses as Bus System 130. Understandably, Figure 2 The structures shown in the embodiments are merely illustrative and do not limit the structure of the electronic device described above. For example, the electronic device may also include components that are larger than... Figure 2 The structure shown has more or fewer components, or has the same as Figure 2 The diagram shows different configurations of the structure.
[0076] Specifically, the processor 110 provides computational and control capabilities to control the electronic device 100 to perform corresponding tasks. For example, it controls the electronic device 100 to execute any of the methods for generating a light strip design pattern provided in the embodiments of the present invention, or to execute the steps in any possible implementation of any of the methods for generating a light strip design pattern provided in the embodiments of the present invention. Those skilled in the art will understand that the processor 110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0077] The memory 120, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, instructions, and modules, such as the program, instructions, and modules corresponding to the method for generating the LED strip design pattern in the embodiments of the present invention. In some embodiments, the memory 120 may include a program storage area and a data storage area. The program storage area may store an operating system, an application program required for at least one function, and the data storage area may store data created according to the use of the processor 110. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the non-transitory software programs, instructions, and modules stored in the memory 120, to implement any of the LED strip design pattern generation methods provided in the embodiments of the present invention, or to execute the steps in any possible implementation of any of the LED strip design pattern generation methods provided in the embodiments of the present invention. In some embodiments, the memory 120 may include high-speed random access memory and may also include non-transitory memory. For example, at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 120 may also include memories remotely located relative to the processor 110, which can be connected to the processor 110 via a communication network. Understandably, examples of the aforementioned communication networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0078] As can be understood from the above, the entity executing any of the methods for generating LED strip design diagrams provided in the embodiments of the present invention can be any suitable type of electronic device with certain computing and control capabilities, for example, it can be executed by the aforementioned electronic device 100. In some feasible implementations, the method for generating any of the LED strip design diagrams provided in the embodiments of the present invention can be implemented by a processor calling computer program instructions stored in memory.
[0079] The following will describe in detail the method for generating the LED strip design diagram provided in the embodiments of the present invention, with reference to exemplary applications and implementations of the electronic devices provided in the embodiments of the present invention.
[0080] Please see Figure 3 , Figure 3 The schematic diagram illustrates a flowchart of a method for generating LED strip design diagrams according to some embodiments of the present invention.
[0081] Those skilled in the art will understand that the method for generating the LED strip design pattern provided in this embodiment of the invention can be applied to the aforementioned electronic device (e.g., electronic device 100). Specifically, the execution entity of this method for generating the LED strip design pattern is one or at least two processors of the electronic device.
[0082] like Figure 3As shown, the method for generating the light strip design includes, but is not limited to, the following steps S100-S600:
[0083] S100: Obtain the target image, which includes the target image area occupied by the target object.
[0084] In this step, the target image includes the target image area occupied by the target object. The target object refers to the object that the user needs to imitate and shape. The target object can be a plant, animal, or person, etc. Plants can be trees, flowers, etc., animals can be cats, dogs, tigers, etc., and people can be human figures in the image, such as children, women, middle-aged men, etc. The target object occupies a corresponding image area in the target image. The image areas occupied by different target objects may overlap or not. For example, please refer to [link / reference]. Figure 4 , Figure 4 The target objects in the image include a cat and a woman's torso. The cat is in the woman's arms, and the image area occupied by the cat overlaps with the image area occupied by the woman's torso.
[0085] In some embodiments, users can upload target images to electronic devices via smart terminals such as smartphones and tablets. For example, users can connect their smartphones or tablets to electronic devices via communication methods such as Wi-Fi or Bluetooth, upload target images to the electronic devices, and then the electronic devices can obtain the target images.
[0086] In some embodiments, users can also operate electronic devices to access apps, web pages, etc. to obtain target images. For example, they can access the webpage link of "Visual China" and filter to obtain the target images they need.
[0087] In some embodiments, users can also input keywords into the electronic device via voice or text. After receiving the keywords, the electronic device extracts the target object information and generates a corresponding target image, thereby enabling the electronic device to obtain the target image. The keywords include the target object information.
[0088] Of course, electronic devices can also acquire target images in other ways. Those skilled in the art can choose any suitable method according to actual needs, and the embodiments of the present invention do not limit this in any way.
[0089] S200: Determine the equivalent outer contour corresponding to the target object based on the target image. The equivalent outer contour includes multiple key feature points.
[0090] In this step, image processing techniques are used to convert the target image into a grayscale image. Gaussian filtering or median filtering methods are used to remove noise from the image, and histogram equalization or adaptive contrast enhancement methods are used to highlight the target object. Edge detection algorithms (such as Canny, Sobel, and Prewitt) or threshold segmentation algorithms (such as Otsu's algorithm) are used to identify the edges of the target object, obtaining its outer contour. Equivalent outer contours are generated using polygon approximation methods (such as the Ramer-Douglas-Peucker algorithm), B-spline curves, and Bézier curves. Important feature points on the target object's outer contour, such as inflection points, concave / convex points, and extreme points, are detected. Key feature points are retained, small and discontinuous boundaries are removed, and the main contour lines of the target object are smoothed to obtain the corresponding equivalent outer contour.
[0091] In some embodiments, the target object has distinct color characteristics. The target object can be converted to a color space such as HSV or Lab to identify its edges and obtain its outer contour. In other embodiments, a contour tracking algorithm (such as findContours from the OpenCV library) can be used to obtain the closed boundary of the target object, identify its edges, and obtain its outer contour.
[0092] In some embodiments, if there is an interruption in the equivalent outer contour, the interruption points are connected by an interpolation method (such as linear interpolation or Lagrange interpolation) to form a complete equivalent outer contour.
[0093] S300: In response to user input of smoothing parameters for the equivalent outer contour, key feature points that do not meet the preset concaveness condition are removed from the equivalent outer contour, resulting in multiple candidate feature points.
[0094] In this step, the smoothing parameter is used to control the smoothness of the equivalent outer contour. This embodiment of the invention presets multiple smoothing parameter levels, and the user can select and input any smoothing parameter level according to actual needs. In some embodiments, the smoothing parameter includes any one or more of curvature threshold, angle threshold, and distance threshold.
[0095] The electronic device receives the smoothing parameters input by the user, and removes key feature points that do not meet the preset concavity conditions (such as the concavity depth or angle not meeting the requirements) according to the smoothing parameters, and retains multiple key feature points that meet the preset concavity conditions to obtain multiple candidate feature points (that is, multiple key feature points that meet the preset concavity conditions).
[0096] For example, smoothing parameters include curvature thresholds. The electronic device calculates the curvature corresponding to each key feature point on the contour, compares the curvature of each key feature point with the curvature threshold, and filters out key feature points that do not meet the curvature threshold requirements. For example, key feature points with curvature greater than the curvature threshold are filtered out, resulting in multiple key feature points that meet the curvature threshold requirements (i.e., curvature less than or equal to the curvature threshold), which are thus multiple candidate feature points.
[0097] It is understandable that there are many methods for calculating the curvature of key feature points, and any suitable method in the existing technology can be used for calculation. They will not be described in detail here. For example, in some embodiments, NumPy or other mathematical libraries can be used to calculate the curvature of key feature points.
[0098] S400: Generates target contours based on multiple candidate feature points.
[0099] In this step, multiple candidate feature points are arranged in order on the equivalent outer contour. A suitable curve fitting or interpolation method is used to generate a smooth and continuous curve between the multiple candidate feature points, thereby obtaining a smooth and continuous target contour corresponding to the target object.
[0100] In some embodiments, a polygon fitting method can be used to connect candidate feature points to generate a polyline contour, thereby obtaining the target contour. The polygon fitting method is suitable for situations requiring low precision, but the resulting target contour is relatively rigid and lacks smoothness. Therefore, a suitable algorithm can be used to smooth the target contour to obtain a smoother one.
[0101] In some embodiments, B-spline curves, Bézier curves, and other methods can be used to fit and generate smooth, continuous curves, resulting in smooth, continuous target contours. This method is efficient and allows for easy adjustment of smoothing parameters, generating natural and fluid target contours.
[0102] In some embodiments, Lagrange interpolation or piecewise interpolation methods can also be used to interpolate multiple candidate feature points piecewise, smoothly transition between each point, generate a smooth and continuous curve, and obtain a smooth and continuous target contour.
[0103] Of course, any other suitable method can be used to generate the target contour. Those skilled in the art can use any suitable method according to actual needs, and the embodiments of the present invention do not limit this in any way.
[0104] S500: Generates LED strip layout information based on a preset interval distance. The LED strip layout information is used to indicate the position of LED strip segments of different colors on the target outline.
[0105] In this step, the preset interval distance refers to the distance between two adjacent lighting points, representing the length of each light strip segment. The light strip arrangement information indicates the position of the light strip segments on the target contour. The light strip segments include multiple colors, and lighting points are arranged on the target contour according to the positions of different colored light strip segments. Those skilled in the art can set the value of the preset interval distance according to actual needs; this embodiment of the invention does not impose any limitations on this.
[0106] Specifically, obtain the length of the target contour. According to the preset interval distance The number of lighting points was calculated. ,in, It means that the value is not greater than The largest integer. Preset interval distance along the target contour. Set one lighting point, and arrange multiple lighting points to form a light strip segment. Each adjacent lighting point corresponds to a light strip segment. Assign a color to each light strip segment, and generate light strip layout information for each segment based on its color and position on the target outline.
[0107] In some embodiments, the target contour is represented in the form of a point sequence or a parametric curve, wherein the point sequence is represented as: ( , (), , ), ..., ( , Then the length of the target contour The parameterized curve is represented as: ,in If the parameter is used, the length of the target contour is calculated through numerical integration. .
[0108] It is understandable that the assigned colors include at least two types, and each light strip segment can be assigned a corresponding color according to preset rules, such as according to the color arrangement order, or according to the counterclockwise or clockwise order along the target outline to assign a corresponding color to each light strip segment.
[0109] For example, the assigned colors include three types: green, red, and yellow, and the color arrangement is red, green, and yellow. The target outline corresponds to ten light strip segments. The colors assigned to the ten light strip segments along the target outline in a counter-clockwise order are: red, green, yellow, red, green, yellow, red, green, yellow, red.
[0110] Of course, other methods can also be used to assign colors to each light strip segment, and this embodiment of the invention does not limit this in any way.
[0111] S600: Render the target outline based on the light strip layout information to obtain the light strip shape drawing.
[0112] In this step, the information on the arrangement of the light strips includes the color of the light strip segments and the position of the light strip segments on the target outline.
[0113] Specifically, based on the positions of the light strip segments on the target contour, the sub-contours corresponding to each light strip segment are traversed across the target contour. The color of each sub-contour corresponding to each light strip segment is then rendered as the color of each light strip segment, resulting in a light strip design image with both aesthetic appeal and practical value. The generated light strip design image is then exported as a vector or pixel image for subsequent use. The light strip design image includes the color and position information of each light strip segment.
[0114] This invention extracts the equivalent outer contour of the target object from the target image, generates the target contour corresponding to the target object based on the smoothing parameters input by the user, and performs personalized rendering of the target contour based on the light strip layout information to obtain a light strip shape image with aesthetic effect and practical value. In this way, it can provide users with a clear and personalized light strip shape image, enabling users to create accurate and beautiful shapes based on the light strip shape image, thereby enhancing the fun and user experience.
[0115] In some embodiments, the equivalent outer contour corresponding to the target object is determined based on the target image, specifically including but not limited to the following steps S210-S230:
[0116] S210: Extract the outer contour of the target object from the target image. The outer contour includes multiple contour feature points.
[0117] Specifically, the target image is converted to grayscale, a filter (such as Gaussian filtering) is used to remove image noise, an edge detection algorithm (such as Canny or Sobel) is used to extract the edges in the image, the edges of the target object are identified, and a contour detection algorithm (such as findContours in the OpenCV library) is used to extract the outer contour of the target object. The outer contour includes multiple contour feature points, which are discrete representations of the edges of the target object.
[0118] In some embodiments, the outer contour of the target object is extracted from the target image, specifically including but not limited to the following steps S2110-S2120:
[0119] S2110: Segment the target image region occupied by the target object from the target image to obtain a binary contour map, wherein the pixel value of the target image region is the first pixel value, and the pixel value of the image region in the target image excluding the target image region is the second pixel value.
[0120] In this step, the target image is converted into a grayscale image. Grayscale conversion means converting each pixel of the RGB image into a grayscale value (usually a value between 0 and 255). Gaussian filtering or median filtering methods are used to remove image noise and avoid noise interfering with edge extraction.
[0121] Based on the color or brightness information of the target image region, the target image region occupied by the target object is segmented into other image regions (i.e., image regions in the target image other than the target image region) by setting a threshold. The pixel value of the target image region is the first pixel value, and the pixel value of other image regions (image regions in the target image other than the target image region) is the second pixel value.
[0122] In some embodiments, the target object has a significant color difference from other objects in the target image, and a fixed threshold can be used to segment the target image region occupied by the target object from the target image.
[0123] In some embodiments, if the brightness value of the target image region differs significantly from other image regions, a thresholding technique (such as Otsu's binarization method) can be used to select the optimal segmentation threshold. When the brightness or color difference of the target image is not significant, an adaptive thresholding method can be used to dynamically calculate the segmentation threshold based on the pixel values of the local region. For example, the cv2.adaptiveThreshold function in OpenCV can be used to implement adaptive thresholding.
[0124] After segmenting the target image region, a binarized contour map is generated. In the binarized contour map, the pixel value of the target image region is the first pixel value (assigned a value of 255, white), and the pixel value of other image regions is the second pixel value (assigned a value of 0, black). The binarized contour map clearly shows the position and contour of the target object. For example, please refer to... Figure 5 , Figure 5 The diagram shows a binary contour map of the target object generated in some embodiments of the present invention.
[0125] In some embodiments, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map, which includes, but is not limited to, the following step S2111:
[0126] S2111: In response to the user's selection operation on the target image region, segment the target image region occupied by the target object from the target image to obtain a binarized contour map.
[0127] In this step, the interactive selection function provided by an image processing library (such as OpenCV) is used, allowing users to select target objects in the target image using a mouse or touchscreen. The cv2.selectROI function is used to allow users to select target objects within the target image, with each target object occupying a corresponding image region (i.e., the target image region).
[0128] Specifically, the electronic device detects through an event listener that the user has performed a bounding operation on the target image region occupied by the target object in the target image. In response to the bounding operation, the electronic device segments the bounded target image region in the target image using threshold segmentation techniques (e.g., global thresholding or adaptive thresholding). Then, it performs binarization processing on the target image region and other image regions (i.e., image regions in the target image other than the target image region). The pixel value of the target image region is assigned as the first pixel value, and the pixel values of the other image regions are assigned as the second pixel value, resulting in a binarized contour map.
[0129] In some embodiments, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map, specifically including but not limited to the following step S2112:
[0130] S2112: In response to user input of text content about segmenting the target image region, segment the target image region occupied by the target object from the target image to obtain a binarized contour map.
[0131] In this step, the user can also input text content about segmenting the target image region via text or voice. For example, in some embodiments, after acquiring the target image, the user inputs the text content "capture the cat in the picture" using a microphone. After receiving the text content, the electronic device parses the text content, determines that the target object is a cat, and segments the target image region occupied by the target object (i.e., the cat) in the target image using threshold segmentation techniques (e.g., global thresholding or adaptive thresholding). The segmented target image region is then binarized with other image regions (i.e., image regions in the target image other than the target image region). The pixel value of the target image region is assigned as the first pixel value, and the pixel values of the other image regions are assigned as the second pixel value, resulting in a binarized contour map.
[0132] In some embodiments, the text content may specifically describe the location and size of the target object (e.g., the target object is located in the center of the image, or the boundary coordinates of the target object, etc.). For example, the text content may be "The target image area is the middle part of the image, with a width of 500px and a height of 400px." The electronic device parses the text content, extracts the location information and size of the target image area, and segments the target image area from the target image based on the location information and size of the target image area.
[0133] In some embodiments, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map, specifically including but not limited to the following step S2113:
[0134] S2113: In response to the default segmentation command, segment the target image region occupied by the target object from the target image to obtain a binarized contour map. The target object is the object in the target image that is focused on.
[0135] In this step, by default, the object in the target image that is in focus is the target object. When the user does not input any text content about segmenting the target image region or does not select the target image region, the system responds to the listened-to default segmentation command, iterates through the objects included in the target image one by one, and determines that the object in focus in the target image is the target object. The target object occupies the corresponding image region (i.e., the target image region) in the target image.
[0136] The target image region occupied by the target object in the target image is segmented by threshold segmentation techniques (such as global thresholding or adaptive thresholding). The segmented target image region is then binarized with other image regions (i.e., image regions in the target image other than the target image region). The pixel value of the target image region is assigned as the first pixel value, and the pixel values of other image regions are assigned as the second pixel value, resulting in a binarized contour map.
[0137] S2120: Extract the outer contour of the target object from the binary contour map based on the preset edge detection algorithm.
[0138] In this step, the preset edge detection algorithm can be any suitable edge detection algorithm, such as the Canny algorithm, the Sobel algorithm, etc. Of course, other suitable preset edge detection algorithms can also be used. The Canny algorithm is a commonly used edge detection method that identifies edges by detecting changes in image gradients.
[0139] In some embodiments, the Canny algorithm is used to identify the edges of the target object. First, the gradient of the image is calculated (using the Sobel operator or other operators), non-maximum suppression is applied to refine the edges, and double threshold detection is used to determine the edges of the target object, thereby identifying the outer contour of the target object.
[0140] After identifying the outer contour of the target object, the OpenCV `findContours` function is used to detect contours in the image. Based on the edge detection results, the contours are extracted to obtain the outer contour of the target object. The `findContours` function returns a list of contours, where each contour is a set of points representing the contour's boundary. The `cv2.drawContours` function is used to draw the extracted contours onto the original image or a blank image to visualize the outer contour of the target object. For example, please refer to [link to example]. Figure 6 , Figure 6 The diagram shows the outer contour of the target object extracted in some embodiments of the present invention. Figure 6 and Figure 5 The target object corresponds to this.
[0141] S220: In response to user input of precision parameters for the outer contour, select multiple key feature points from multiple contour feature points.
[0142] In this step, the precision parameter characterizes the selection criteria for contour feature points and is used to control the degree of simplification of the outer contour. This embodiment of the invention presets multiple precision parameter levels, and the user can select and input any precision parameter level according to actual needs. In some embodiments, the precision parameter includes any one or more of curvature threshold, angle threshold, and distance threshold.
[0143] The electronic device receives the precision parameters input by the user, and selects multiple contour feature points that meet the selection criteria from multiple contour feature points based on the precision parameters. Contour feature points that do not meet the selection criteria (such as the depth, angle, or curvature of the depression do not meet the criteria) are removed, resulting in multiple key feature points (i.e. multiple key feature points that meet the selection criteria).
[0144] For example, the accuracy parameters include angle thresholds. The electronic device calculates the angle corresponding to each contour feature point on the outer contour, compares the angle of each contour feature point with the angle threshold, and filters out multiple contour feature points that meet the angle threshold requirements. For example, it filters out contour feature points whose angles are greater than or equal to the angle threshold, thus obtaining multiple contour feature points that meet the angle threshold requirements (i.e., angles greater than or equal to the angle threshold), which are multiple key feature points.
[0145] For example, please see Figures 7 to 9 , Figures 7 to 9The diagrams show the key feature points selected after inputting three different precision levels. Figures 7 to 9 The red outline point 10 shown is the key feature point. Among them, Figure 7 The corresponding input precision parameter value is relatively large, the number of key feature points selected is small, the simplification degree of the subsequent equivalent outer contour is high, and there is a large difference between the equivalent outer contour and the original contour of the target object. Figure 8 The corresponding input precision parameter values are moderate, the number of key feature points selected is moderate, the simplification degree of the subsequent equivalent outer contour is moderate, and the difference between the equivalent outer contour and the original contour of the target object is moderate. Figure 9 The corresponding input precision parameter value is small, the number of key feature points selected is large, the simplification degree of the subsequent equivalent outer contour is low, and the equivalent outer contour is almost consistent with the original contour of the target object.
[0146] It is understandable that there are many methods for calculating the angle of contour feature points, and any suitable method in the existing technology can be used for calculation. They will not be described in detail here. For example, in some embodiments, NumPy or other mathematical libraries can be used to calculate the angle of contour feature points.
[0147] S230: Generates an equivalent outer contour based on multiple key feature points.
[0148] In this step, polygon approximation methods (such as the Ramer-Douglas-Peucker algorithm), Bézier curves, B-spline curves, and other fitting methods are used to generate a smooth and continuous equivalent outer contour through multiple key feature points, thereby obtaining the equivalent outer contour corresponding to the target object.
[0149] In some embodiments, the fitted equivalent outer contour is segmented, and a smoothing algorithm (such as Gaussian smoothing or B-spline smoothing) can be used to smooth the equivalent outer contour to obtain a smooth, continuous, and natural equivalent outer contour.
[0150] In some embodiments, in response to user input of smoothing parameters about the equivalent outer contour, key feature points that do not meet the preset concavity condition are removed from the equivalent outer contour to obtain multiple candidate feature points, specifically including but not limited to the following steps S310-S330:
[0151] S310: Obtain the user input of a preset angle threshold for the equivalent outer contour.
[0152] In this step, the smoothing parameters include preset angle thresholds. In this embodiment of the invention, preset angle thresholds for multiple gears are preset, and the user can select and input any preset angle threshold according to actual needs.
[0153] In some embodiments, the user inputs a preset angle threshold, which represents the minimum angle formed between two adjacent feature points. Key feature points with angle values less than the preset angle threshold do not meet the preset concave condition and need to be removed.
[0154] Specifically, users can select and input the preset angle threshold of any gear from a set of preset angle thresholds for the equivalent outer contour through the interactive interface of the electronic device, so that the electronic device can obtain the preset angle threshold.
[0155] S320: Calculate the angle value corresponding to each key feature point.
[0156] Understandably, the calculation of feature point angle values is based on three adjacent feature points on the contour. By calculating the angle between three adjacent feature points, the angle value corresponding to each key feature point is determined.
[0157] In this step, the vector method is used to calculate the angle values corresponding to each key feature point. For any three consecutive key feature points on the contour... , , Calculation by arrive and by arrive The angle value formed, i.e., the line segment and line segments The angle value formed.
[0158] For each key feature point, the angle value of the key feature point is calculated using the vector angle formula, which is as follows:
[0159]
[0160] In the above formula, , , , Then, the arccosine function is used to calculate the angle value of each key feature point. .
[0161] In some embodiments, the angle value corresponding to each key feature point is calculated, specifically including but not limited to the following steps S321-S322:
[0162] S321: For any key feature point, determine the preceding and following key feature points corresponding to the key feature point.
[0163] S322: Determine the angle formed by the first line segment and the second line segment as the angle value corresponding to the key feature point. The first line segment is the line segment obtained by connecting the previous key feature point and the key feature point, and the second line segment is the line segment obtained by connecting the key feature point and the next key feature point.
[0164] Specifically, for any current key feature point Find the preceding key feature point adjacent to it. and the next key feature point Connect the previous key feature point. and current key feature points Obtain the first line segment and its vector. Connect the current key feature points. and the next key feature point Obtain the second line segment and the vector of the second line segment. .
[0165] The dot product formula is used to calculate the angle between vectors (i.e., the angle formed by the first line segment and the second line segment). The dot product formula is as follows:
[0166]
[0167] In the above formula, , , The angle value of the current key feature point The angle value corresponding to each key feature point can be calculated using the above method.
[0168] S330: Remove key feature points with angle values less than a preset angle threshold from the equivalent outer contour to obtain multiple candidate feature points.
[0169] Specifically, the angle value corresponding to each key feature point is compared with a preset angle threshold. Key feature points with angle values less than the preset angle threshold are removed from the equivalent outer contour. Multiple key feature points with angle values greater than or equal to the preset angle threshold are retained. These key feature points with angle values greater than or equal to the preset angle threshold are used as candidate feature points to obtain multiple candidate feature points.
[0170] In some embodiments, a target contour is generated based on multiple candidate feature points, including but not limited to the following steps S410-S440:
[0171] S410: Generate multiple reference feature points based on multiple candidate feature points, wherein the distance between any two adjacent reference feature points is the same.
[0172] S420: Perform curve fitting operation on all reference feature points to obtain the reference contour.
[0173] For example, the number of reference feature points is set by those skilled in the art according to actual needs, and multiple reference feature points are generated by combining the distances between each candidate feature point. The distance between any two adjacent reference feature points is the same.
[0174] In some embodiments, the total distance between candidate feature points is calculated, and a target step size for uniformly generating reference feature points is determined. Multiple uniformly distributed reference feature points are generated at the target step size, with adjacent reference feature points having the same distance.
[0175] Curve fitting algorithms (such as spline interpolation or Bézier curve fitting) are used to fit curves to all reference feature points to generate a smooth and continuous reference profile. It should be understood that any other suitable method (such as polynomial fitting) can also be used to fit and generate the reference profile, and the embodiments of the present invention do not limit this in any way.
[0176] S430: Determine the perimeter of the reference profile.
[0177] In this step, the fitted reference contour is sampled to obtain multiple sampled contour segments. The length of each sampled contour segment is calculated, and the lengths of all sampled contour segments are summed to obtain the perimeter of the reference contour.
[0178] S440: Based on the preset light strip length, scale the reference contour so that the perimeter of the scaled reference contour is consistent with the preset light strip length.
[0179] In this step, the preset light strip length refers to the length of the light strip used by the user to simulate and shape the light strip design. The user can input the preset light strip length into the electronic device in any suitable way.
[0180] Specifically, based on the preset light strip length and the perimeter of the reference contour, a scaling factor is calculated, which is the ratio of the preset light strip length to the perimeter of the reference contour. Then, the scaling factor is applied to each reference feature point on the reference contour, and the reference contour is translated and scaled to adjust its perimeter so that the perimeter of the scaled reference contour matches the preset light strip length, thus obtaining the target contour. The shape of the target contour is the same as the shape of the reference contour.
[0181] In some embodiments, light strip layout information is generated based on a preset interval distance, including but not limited to the following steps S510-S520:
[0182] S510: Based on a preset interval distance, multiple reference feature points are sampled at equal intervals in the target contour, and the line segment between any two adjacent reference feature points is the sub-contour line segment.
[0183] In this step, the preset interval distance refers to the distance used to sample multiple reference feature points. Those skilled in the art can set the value of the preset interval distance according to actual needs. The line segment between any two adjacent reference feature points is a sub-contour segment, and each sub-contour segment has the same length.
[0184] For example, the arc-length parameterization method is used to sample multiple reference feature points at equal intervals on the target contour according to a preset interval distance, so as to obtain multiple reference feature points that are evenly distributed. The distance between two adjacent sampling points (reference feature points) is the preset interval distance.
[0185] Among them, the line segment between every two adjacent reference feature points is a sub-contour line segment, and each group of adjacent reference feature points corresponds to a sub-contour line segment. Each sub-contour line segment includes the position information of two adjacent reference feature points.
[0186] S520: Generate LED strip layout information corresponding to multiple sub-contour segments based on multiple sub-contour segments, with one LED strip layout information corresponding to one sub-contour segment.
[0187] In this step, for each sub-contour segment, LED strip layout information is generated based on the coordinates of the starting and ending reference feature points. This results in multiple LED strip layout information corresponding to multiple sub-contour segments, with one LED strip layout information corresponding to one sub-contour segment. The LED strip layout information includes the starting and ending positions of the LED strip segment and its attribute information (such as the length, color, and brightness of the LED strip segment).
[0188] In some embodiments, the target outline is rendered based on the light strip layout information to obtain a light strip shape drawing, specifically including but not limited to the following steps S610-S620:
[0189] S610: For any given light strip segment, determine the corresponding sub-contour segment as the target sub-contour segment based on the position of the light strip segment on the target contour.
[0190] S620: Render the color of the target sub-contour line segment to the color of the light strip segment to obtain the light strip shape drawing, wherein any two adjacent sub-contour line segments have different colors.
[0191] In this step, the light strip layout information includes the color of the light strip segment and the position of the light strip segment on the target outline.
[0192] Specifically, for any given light strip segment, based on its position (start and end points) on the target contour, a corresponding sub-contour segment is found on the target contour. This sub-contour segment shares the same start and end points as the light strip segment. This sub-contour segment is then designated as the target sub-contour segment, and its color is rendered to match the color of the light strip segment, thus obtaining the light strip design. In other words, for each sub-contour segment of the target contour, its color is rendered to match the color of the corresponding light strip segment, and any two adjacent sub-contour segments have different colors.
[0193] In some embodiments, a cyclical rendering color switching mechanism can be used to ensure that adjacent sub-contour segments have different colors. For example, a predefined list of colors, such as red and green, can be used to render each sub-contour segment in turn, resulting in a target contour where adjacent sub-contour segments have different colors. For example, see [link to relevant documentation]. Figure 10 , Figure 10 The following are illustrations of the LED strip design after color rendering in some embodiments of the present invention. Figure 10 In the light strip design shown, red and green are used to alternately render the various sub-outline segments.
[0194] In summary, the method for generating a light strip design image provided in this embodiment of the invention includes: acquiring a target image, the target image including a target image region occupied by a target object; determining an equivalent outer contour corresponding to the target object based on the target image, the equivalent outer contour including multiple key feature points; in response to user input of smoothing parameters about the equivalent outer contour, removing key feature points that do not meet the preset concave condition from the equivalent outer contour to obtain multiple candidate feature points; generating a target contour based on the multiple candidate feature points; generating light strip arrangement information based on a preset interval distance, the light strip arrangement information being used to represent the positions of light strip segments of different colors on the target contour; and rendering the target contour based on the light strip arrangement information to obtain a light strip design image.
[0195] This invention extracts the equivalent outer contour of the target object from the target image, generates the target contour of the target object according to the smoothing parameters input by the user, and performs personalized rendering of the target contour based on the light strip layout information to obtain the light strip shape image. In this way, a clear and personalized light strip shape image can be provided to the user, and the user can create an accurate and beautiful shape according to the light strip shape image, which enhances the fun and user experience.
[0196] This invention provides a computer-readable storage medium storing processor-executable computer program instructions. When invoked by a processor, the computer program instructions cause the processor to execute any of the methods for generating LED strip design patterns provided in this invention, or to execute the steps in any of the methods for generating LED strip design patterns provided in this invention.
[0197] In some embodiments, the storage medium may be a flash memory, a hard disk, an optical disk, a register, a magnetic surface memory, a removable disk, a CD-ROM, a random access memory (RAM), a read-only memory (ROM), an electrically programmable ROM, and an electrically erasable programmable ROM, or any other form of storage medium known in the art, or various devices including one or any combination of the above storage media.
[0198] In some embodiments, computer program instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0199] As an example, computer program instructions may, but do not necessarily, correspond to files in a file system, and may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0200] As an example, computer program instructions can be deployed to execute on a single computing device (including devices such as smart terminals and servers), or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network. It is readily understood that all or part of the steps of the methods described in the embodiments of the present invention above can be implemented directly using electronic hardware or processor-executable computer program instructions, or a combination of both.
[0201] Those skilled in the art will understand that the embodiments provided by this invention are merely illustrative. The order in which the steps in the methods of the embodiments are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The order can be adjusted, merged, and deleted according to actual needs. Modules or sub-modules, units or sub-units in the apparatus or system of the embodiments can be merged, divided, and deleted according to actual needs. For example, the division of units is only a logical functional division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0202] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or it can be implemented using hardware. Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0203] It should be noted that the above embodiments are for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. Those skilled in the art can understand that all or part of the processes of the above embodiments can be implemented by modifying the technical solutions described in the embodiments of the present invention, or by making equivalent substitutions for some of the technical features. It is understood that these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and should be considered as equivalent changes and modifications made based on the embodiments of the present invention, all of which should fall within the scope of the claims of the present invention.
Claims
1. A method for generating a light strip design diagram, characterized in that, include: Acquire a target image, wherein the target image includes the target image region occupied by the target object; Based on the target image, an equivalent outer contour corresponding to the target object is determined, and the equivalent outer contour includes multiple key feature points; In response to user input of smoothing parameters for the equivalent outer contour, key feature points that do not meet the preset concaveness condition are removed from the equivalent outer contour to obtain multiple candidate feature points; Generating a target contour based on multiple candidate feature points includes: generating multiple reference feature points based on the multiple candidate feature points, wherein the distance between any two adjacent reference feature points is the same; performing a curve fitting operation on all the reference feature points to obtain a reference contour; determining the perimeter of the reference contour; and scaling the reference contour based on a preset light strip length so that the perimeter of the scaled reference contour is consistent with the preset light strip length. Generating LED strip layout information based on a preset interval distance includes: sampling multiple reference feature points at equal intervals on the target contour based on the preset interval distance, wherein the line segment between any two adjacent reference feature points is a sub-contour line segment; generating LED strip layout information corresponding to multiple sub-contour line segments based on multiple sub-contour line segments, wherein the LED strip layout information is used to indicate the position of LED strip segments of different colors on the target contour, one sub-contour line segment corresponds to one LED strip layout information, and the LED strip layout information includes the color of the LED strip segment and the position of the LED strip segment on the target contour, wherein any two adjacent sub-contour line segments have different colors; The target outline is rendered based on the light strip layout information to obtain a light strip shape drawing.
2. The method according to claim 1, characterized in that, Determining the equivalent outer contour corresponding to the target object based on the target image includes: The outer contour of the target object is extracted from the target image, and the outer contour includes multiple contour feature points; In response to user input of precision parameters regarding the outer contour, multiple key feature points are selected from multiple contour feature points; The equivalent outer contour is generated based on multiple key feature points.
3. The method according to claim 2, characterized in that, Extracting the outer contour of the target object from the target image includes: The target image region occupied by the target object is segmented from the target image to obtain a binary contour map, wherein the pixel value of the target image region is the first pixel value, and the pixel value of the image region in the target image excluding the target image region is the second pixel value; The outer contour of the target object is extracted from the binary contour map based on a preset edge detection algorithm.
4. The method according to claim 3, characterized in that, The step of segmenting the target image region occupied by the target object from the target image to obtain a binarized contour map includes: In response to a user's selection operation on the target image region, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map; or... In response to user input of text content regarding the segmentation of the target image region, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map; or... In response to the default segmentation command, the target image region occupied by the target object is segmented from the target image to obtain a binarized contour map, wherein the target object is the object captured in focus in the target image.
5. The method according to claim 1, characterized in that, The smoothing parameters include a preset angle threshold. The smoothing parameters, responding to user input regarding the equivalent outer contour, remove key feature points from the equivalent outer contour that do not meet the preset concavity condition, resulting in multiple candidate feature points, including: Obtain the user's input regarding the preset angle threshold of the equivalent outer contour; Calculate the angle value corresponding to each of the key feature points; By removing key feature points with angle values less than the preset angle threshold from the equivalent outer contour, multiple candidate feature points are obtained.
6. The method according to claim 5, characterized in that, The calculation of the angle value corresponding to each key feature point includes: For any key feature point, determine the preceding and following key feature points corresponding to the key feature point. The angle formed by the first line segment and the second line segment is determined as the angle value corresponding to the key feature point. The first line segment is the line segment connecting the previous key feature point and the key feature point, and the second line segment is the line segment connecting the key feature point and the next key feature point.
7. The method according to claim 1, characterized in that, The step of rendering the target outline based on the light strip layout information to obtain a light strip shape drawing includes: For any given light strip segment, the sub-contour segment corresponding to the light strip segment is determined as the target sub-contour segment based on the position of the light strip segment on the target contour. The color of the target sub-contour line segment is rendered as the color of the light strip segment to obtain the light strip shape drawing.
8. An electronic device, characterized in that, include: A processor and a memory communicatively connected to the processor; The memory stores computer program instructions executable by the processor, which, when invoked by the processor, cause the processor to perform the method for generating the light strip design as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores processor-executable computer program instructions, which, when invoked by the processor, cause the processor to perform the method for generating the light strip design as described in any one of claims 1-7.
Citation Information
Patent Citations
Light-emitting equipment, lamp effect light-emitting area editing method and device, medium and product
CN117794029A
Object contour adjustment method and device, equipment, storage medium and program product
CN118314158A