Methods, devices, equipment and media for generating lighting effect animation data
By constructing a color palette and using probability-driven spatial modulation to update color values, technical problems were solved and the user's visual experience was improved.
Patent Information
- Application Number
- CN202511412044.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-09-29
AI Technical Summary
Traditional lighting effect generation methods result in the LED arrays failing to blend visually, with stepped breaks and color bands appearing in the gradient areas. They cannot utilize the spatial mixing effect of the human eye to mitigate quantization errors and cannot meet users' expectations for smooth and natural lighting effects.
By constructing a color palette containing a fixed number of reference colors, the probability distribution of each pixel is determined, and the reference color is selected according to the parity of the pixel's position in the planar space. The color value is updated using probability-driven spatial modulation to form a soft and coherent lighting effect.
It effectively alleviates the color banding and step-by-step discontinuity phenomenon, improves the user's visual experience, and makes the limited number of base colors present a more natural lighting effect during actual playback.
Smart Images

Figure CN120873829B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of lighting effect control technology, and in particular to a method, apparatus, device and medium for generating lighting effect animation data. Background Technology
[0002] In practical applications of ambient lighting, designers often need to convert images or animations with continuous tones into lighting effect files suitable for display with discrete LED arrays. Because the LEDs are arranged in a grid, with significant spacing between adjacent LEDs, the overall appearance is naturally pixelated. Therefore, the industry commonly uses a "downsampling + limited color palette" approach: first, the original image is scaled to the physical resolution of the LED array; then, a clustering algorithm is used to compress the colors into several representative colors; subsequently, each pixel is forced to map to the nearest color center using the shortest distance rule; finally, it is packaged into a lighting effect file that can be directly sent to ambient lighting fixtures for playback. This process is stylistically consistent with pixel art, but it reveals significant shortcomings in color transitions.
[0003] First, traditional techniques rely on the principle of "one-time hard decision": each pixel is assigned only to the nearest color center in the current color palette, and the color palette itself is determined once by global statistics and is not iterated upon again. Due to the limited number of LEDs and their fixed spacing, these discrete color blocks cannot be visually blended, and the gradient area is abruptly cut into several monochrome rectangles, resulting in obvious stepped discontinuities in the image transition, which looks mechanical and lacks depth.
[0004] Secondly, traditional techniques end after color mapping is complete, without applying any modulation to the spatial relationships between pixels. Therefore, they cannot utilize the spatial mixing effect of the human eye to mitigate quantization errors. Adjacent LEDs can only be arranged side by side in pure colors, and cannot "fake" intermediate tones through the interlacing of tiny color dots. This causes continuous changes to be simplified into abrupt jumps, further weakening the subtlety of the ambient effect.
[0005] Furthermore, because the color palette is limited by style and thus kept small, the errors caused by color compression are magnified many times over on low-resolution light arrays, making it easy for the overall image to show color banding, color blocks, and jagged edges, which is difficult to meet users' expectations for smooth and natural lighting effects.
[0006] It is evident that lighting effect files generated by traditional technologies, due to their inherent limitations, result in poor visual quality when played, failing to meet the increasingly sophisticated aesthetic demands of users and requiring further evolution. Summary of the Invention
[0007] The primary objective of this application is to solve at least one of the above-mentioned problems by providing a method, apparatus, device, and medium for generating lighting effect animation data.
[0008] To achieve the various objectives of this application, the following technical solution is adopted:
[0009] A method for generating lighting effect animation data, provided for one of the purposes of this application, includes the following steps:
[0010] Obtain the target image used to construct the lighting effect animation data;
[0011] Based on the color values of pixels in the target image, a color palette containing a fixed number of reference colors is constructed, and the probability distribution of each pixel being mapped to each reference color in the color palette is determined.
[0012] The color value of a pixel is updated by selecting a reference color based on the parity of its planar spatial position in the target image and according to the assigned probability distribution.
[0013] The target image with updated color values is encapsulated into the lighting animation data.
[0014] A lighting effect animation data generation apparatus, proposed to meet one of the purposes of this application, is a lighting effect animation data generation method, comprising:
[0015] The image acquisition module is configured to acquire the target image used to construct the lighting effect animation data.
[0016] The distribution determination module is configured to construct a color palette containing a fixed number of reference colors based on the color values of pixels in the target image, and determine the probability distribution of each pixel corresponding to each reference color in the color palette.
[0017] The color selection update module is configured to correspond to the parity of each pixel's planar spatial position in the target image and select a reference color based on the assigned probability distribution to update the pixel's color value.
[0018] The data encapsulation module is configured to encapsulate the target image with updated color values into the lighting effect animation data.
[0019] In another aspect, a computer device provided for one of the purposes of this application includes a processor and a memory, wherein the processor invokes and runs a computer program in the memory to perform the steps of the lighting effect animation data generation method.
[0020] On another aspect, a computer-readable storage medium is provided to suit another purpose of this application, which stores in the form of computer-readable instructions a computer program implemented according to the described lighting animation data generation method, which, when called by a computer, executes the steps included in the corresponding method.
[0021] This application introduces probability-driven spatial modulation to create the lighting animation data required for ambient lighting to play lighting effects. This effectively alleviates the common color banding and step discontinuity phenomena in the discrete LED array of ambient lighting, enabling a limited number of reference colors to present a more natural and coherent lighting effect during actual playback, significantly improving the user's visual experience.
[0022] Compared to traditional technologies, this application, in pixelated lighting effects with a limited color palette, first replaces the traditional hard decision method with an attribution probability distribution, using a flexible decision mechanism to weaken abrupt edges; then, it selects colors based on the parity of pixel row and column coordinates, allowing adjacent LEDs to alternately present primary or secondary colors, and uses human visual space color mixing to generate additional transition colors; the two work together to significantly compress color band width and smooth step breaks without adding a base color, so that the discrete LED array presents a soft, coherent and high-quality lighting effect. Attached Figure Description
[0023] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0024] Figure 1 This is a schematic diagram of the structure of an exemplary ambient lighting fixture of this application;
[0025] Figure 2 This is a flowchart illustrating a typical embodiment of the lighting effect animation data generation method of this application;
[0026] Figure 3 This is a schematic block diagram of the lighting effect animation data generation device of this application;
[0027] Figure 4 This is a schematic diagram of the structure of a computer device used in this application. Detailed Implementation
[0028] The ambient lighting fixtures described in this application differ from those used in commercial settings such as stage performances and large-scale architectural curtain wall decorations. They are more suitable for home use, and their product form can be indoor curtain lights, panel lights, etc. Figure 1 Taking a curtain light as an example, the ambient lighting fixture of this application includes a controller 1 and a lighting unit 2. The controller 1 and the lighting unit 2 can be directly connected by wire or wirelessly, as long as they can communicate with each other.
[0029] The number of lighting units 2 is unlimited, depending only on the support capability of controller 1. Unlike traditional display products, lighting units 2 are implemented as multiple LEDs with discrete but relatively regular arrangement in terms of human visual effect. They are responsible for controlling the large number of LEDs inside to emit light according to the lighting effect data sent by controller 1 to display the corresponding lighting effect.
[0030] In some embodiments, the ambient lighting fixture may include, in addition to the control chip that functions as controller 1, components such as control panels, communication components, and displays that can be configured as needed.
[0031] The controller of the ambient lighting fixture can interact with the user through its display screen, obtain the lighting effect animation data provided or specified by the user, and use it to drive its lighting unit to play the various images in the lighting effect animation data to present the corresponding lighting effect.
[0032] The control chip can be implemented using various embedded chips, such as Bluetooth SoC (System on Chip), WiFi SoC, MCU (Micro Controller Unit), DSP (Digital Signal Processing), and other types of chips. The control chip typically includes a central processing unit (CPU) and a memory. The memory and CPU are used to store and execute program instructions to achieve the corresponding functions, respectively. The control panel usually provides one or more buttons for controlling the controller 1, selecting various preset lighting effects, etc. A communication component is used to achieve wireless communication connections with each lighting unit 2. The display screen can be used to display various control information to cooperate with the buttons on the control panel, supporting human-machine interaction. The control panel and the display screen can also be integrated into the same touch screen.
[0033] The lighting unit 2 can be implemented as a planar light 4, which includes multiple light strips 21, each light strip 21 connected in series with multiple LED beads 210. The light strips 21 are arranged regularly, thus regularly arranging a large number of LED beads 210 on a plane. The arrangement of these LED beads 210 constitutes the LED bead layout information, which actually describes an LED bead layout interface. This interface can be mapped to the images in the lighting effect animation data, so that each pixel in the image is mapped to the corresponding LED bead 210 in the lighting unit 2, determining the corresponding light emission parameters of each LED bead 210. The light emission parameters provide corresponding color values for each color channel of the LED bead. The light emission parameters corresponding to each LED bead 210 are constructed into lighting effect data. This lighting effect data controls the color rendering of each LED bead 210 in the lighting unit 2 to display the corresponding image. Multiple ordered images in the lighting effect animation data are played in the lighting unit 2 to create an animation effect.
[0034] In some embodiments, the controller 1 of the ambient lighting fixture of this application can be implemented in a separate computer device, as long as the computer device is equipped with a control chip that functions as the controller 1. When the controller 1 is implemented in a computer device, the various resources inherent in the computer device can be shared to save overall implementation costs. The computer device referred to herein can be any terminal device for user use, such as a smartphone, personal computer, laptop, tablet computer, etc.
[0035] In another embodiment, it can also be in Figure 1 Based on the structure of the ambient lighting fixture shown, an independent computer device is used to communicate with the controller 1 of the ambient lighting fixture and coordinate and cooperate according to the preset business logic. Each device is responsible for different tasks in this application and provides the controller with various data and instructions required to implement the technical solutions of this application.
[0036] Based on the above product architecture and working principle of ambient lighting fixtures, the lighting effect animation data generation method of this application can be implemented as a computer program product, stored in the storage medium of the computer device of this application or the controller 1 of the ambient lighting fixture, and called and run by the computer device or the controller 1 of the ambient lighting fixture from the storage medium in order to control each lighting unit 2 to play lighting effects with superimposed filter effects.
[0037] Please see Figure 2 In some embodiments, the lighting effect animation data generation method of this application can be implemented as an application program, installed and run on a computer device or ambient lighting fixture, including:
[0038] Step S5100: Obtain the target image used to construct the lighting effect animation data;
[0039] Using one or more given images, lighting effect animation data can be constructed. This lighting effect animation data can be converted into lighting effect data by ambient lighting fixtures to control the lighting units within them to play corresponding lighting effects. Since the lighting units in the ambient lighting fixtures of this application are implemented using a large number of LEDs in a dot matrix manner, after obtaining the given image as the target image, it needs to be converted into a pixelated final image before being encapsulated into lighting effect animation data and sent to the ambient lighting fixtures for use.
[0040] The target image can be a single still image or any image from a continuous animation; its source can be a JPEG or PNG file stored locally by the user, or data pulled in real time from a video stream, GIF sequence, or cloud interface.
[0041] In one embodiment, the user can provide animation description text, call a preset and well-trained text-to-image model, directly generate GIF animation data based on the animation description text, parse the animation data, extract the images as target images for subsequent processing in this application, and provide target images by automatically generating animation data, which is more intelligent and efficient.
[0042] Before further processing, the target image can be represented in RGB or RGBA bitmap format, with a bit depth of 8 bits per channel to facilitate subsequent color statistics and probability calculations. If the original material is HDR or 16-bit image, it can be converted to 8-bit image through linear scaling or gamma correction to avoid the computational burden caused by high bit depth.
[0043] In terms of acquisition methods, disk paths can be read directly via the file system API, the operating system's media library interface can be used to traverse the photo album, or network resources can be downloaded via HTTP / HTTPS protocols. For scenarios involving real-time camera capture, the camera SDK can be called to capture frames one by one, converting each frame's YUV data to RGB to serve as the target image. In the example, when a user selects a 500×500 pixel preview image as the target image input via a mobile app, the image is stored in memory as a two-dimensional array, with each element containing three unsigned 8-bit integers: R, G, and B, thus forming the complete set of color samples required for subsequent color palette construction. At this point, the target image has been reliably acquired and is in a format and data structure that can be directly processed.
[0044] Step S5200: Based on the color values of pixels in the target image, construct a color palette containing a fixed number of reference colors, and determine the probability distribution of each pixel being mapped to each reference color in the color palette.
[0045] To facilitate pixelation of the target image, a baseline color palette can be established based on the target image, and the probability distribution of each pixel's assignment to each baseline color in this palette can be simultaneously provided. The number of baseline colors in the palette can be a preset fixed number, which is usually specified during the clustering stage. Common values for this fixed number are any values between 6 and 16, but are not limited to this.
[0046] The first step in creating this color palette is to collect all the pixel colors of the entire target image as samples. These samples can be RGB triples or RGB quadruples with added transparency, as long as all samples are in the same color space.
[0047] After data collection, there are multiple paths to derive the reference colors and calculate their assignment probabilities. In one embodiment, clustering algorithms—such as K-means, mean shift, or hierarchical clustering—are first used to find several high-density color centers in the color space, which are then used as initial reference colors. Subsequently, a Bayesian Gaussian mixture model is run, starting with these initial colors. Each Gaussian component in the model corresponds to a reference color, and the weights are based on a Dirichlet distribution to ensure that the components do not collapse too quickly during iteration, nor does an imbalance occur where one color dominates. At the end of the EM iteration, the model outputs two types of results: one is the corrected reference color coordinates, i.e., the final color palette; the other is the posterior probability of each pixel for each reference color, i.e., the assignment probability distribution.
[0048] In another embodiment, clustering initialization can be skipped, and a Bayesian Gaussian mixture model can be run directly on the color samples. The model will determine the number of components and output the same baseline color and probability matrix. In this approach, the concentration parameter of the Dirichlet prior will automatically suppress the number of components, so that the final number of components is consistent with the fixed number.
[0049] In another embodiment, a self-organizing map network or a neural vector quantization network can be used to compress the high-dimensional color space into a codebook of fixed dimensions, and then use the codewords in the codebook as the base color. At the same time, the attribution probability distribution can be derived through the activation degree or distance metric of the network.
[0050] The membership probability distribution is represented by a probability vector corresponding to each pixel. The length of the vector is equal to the number of reference colors, and the sum of the element values in the vector is 1. The larger the element value, the higher the membership degree of the pixel to the corresponding reference color. This distribution can be directly output by the model, or it can be obtained by converting the distance metric into a probabilistic form through kernel density estimation, Softmax, or the Sigmoid function.
[0051] Regardless of the implementation method, the final color palette and the assigned probability distribution together form the basis for subsequent spatial modulation: the color palette provides a limited but representative set of colors, while the assigned probability distribution provides a quantifiable selection basis for each pixel, enabling subsequent steps to make flexible choices based on odd or even positions without having to retraceive the original color space.
[0052] Step S5300: Based on the parity of each pixel's planar spatial position in the target image, and according to the assigned probability distribution, a reference color is selected to update the pixel's color value.
[0053] Given a fixed number of baseline colors and their probability distributions for each pixel in the target image, the color of each pixel can be updated probabilistically by utilizing the parity of the pixel's position in the image plane.
[0054] Specifically, considering the physical resolution requirements of the lighting units for adapting to ambient lighting fixtures, the target image can be scaled up to the physical resolution of the lighting fixtures as needed, so that each pixel corresponds one-to-one with an LED. Then, for each pixel, the category of whether the sum of its row and column coordinates is odd or even is calculated, and different decision thresholds are set accordingly. Based on this decision threshold, the highest and second-highest probability values in the probability distribution are compared to determine whether to retain the base color corresponding to the highest probability or to use the base color corresponding to the second-highest probability. By alternating between primary and secondary colors at odd and even positions, adjacent LEDs can form a visual blend from the human eye's perspective, effectively reducing color banding and step-like breaks.
[0055] In implementation, scaling can employ nearest-neighbor interpolation to maintain pixel sharpness, or bilinear interpolation to obtain smoother boundaries. Parity determination can be achieved by directly summing and moduloing the row and column coordinates, or by pre-generating a checkerboard pattern of the same size as the light array using a mask matrix, where each grid point stores a parity flag. The decision threshold can be statically set, for example, a threshold of 0.5 for even positions and 0.3 for odd positions; or it can be dynamically generated and adaptively adjusted based on the second-highest probability statistical distribution of the entire image.
[0056] The probability comparison can be performed with a single vector operation. Specifically, for each pixel, its probability vector is read, and the largest and second-largest elements are found. If the ratio or difference between the second-largest and largest elements exceeds a decision threshold, the pixel is replaced; otherwise, it remains unchanged. This operation can be efficiently performed using a general-purpose matrix library, GPU shaders, or SIMD instructions. The color of the replaced pixel is the final mapped color. Alternatively, it can be directly written to the frame buffer or output buffer for use in subsequent encapsulation steps without having to write back the original image.
[0057] Step S5400: Encapsulate the target image with updated color values into the lighting effect animation data.
[0058] After the color value update is completed, the target image is ready to present the final pixelated appearance. For cases where target images need to be used to construct lighting effect animation data, after completing the above processing of each target image required for the animation, the process can directly enter the encapsulation stage to package multiple target images into lighting effect animation data according to their playback sequence. After sending it to the ambient lighting fixtures, the ambient lighting fixtures can read it frame by frame and drive the LEDs to emit light.
[0059] In one embodiment, before encapsulating the target image with updated color values into lighting effect animation data, the saturation and brightness of each pixel can be optimized and adjusted before being encapsulated into the lighting effect animation data.
[0060] In another embodiment, before encapsulating the target image with updated color values into lighting effect animation data, it is possible to further identify whether the color value of each pixel belongs to black or gray. If it belongs to black or gray, it can be replaced with other colors before being encapsulated into the lighting effect animation data to maintain a more beautiful playback effect.
[0061] Once the lighting animation data is sent to the ambient lighting fixtures, the controllers of the ambient lighting fixtures analyze each image in the lighting animation data frame by frame and drive the discrete LED array in the lighting unit to emit light accordingly. Each image faithfully presents a pixelated image after probability modulation and parity threshold adjustment. A limited number of base colors are arranged alternately between the LEDs, forming a delicate transition with the help of the human eye's spatial mixing effect. The color edges are soft and jagged, the overall lighting effect is smooth and coherent, and the atmosphere is significantly enhanced.
[0062] Through the above embodiments, this application has achieved a significant technological leap in the pixelated representation of discrete LED arrays, which is of great benefit to the further popularization of ambient lighting fixtures. Its technical advantages include, but are not limited to, the following aspects:
[0063] First, to address the step-like tortuosity problem caused by one-time hard decision in traditional technologies, this application retains the assignment probability distribution for each pixel while constructing the color palette. This makes color assignment no longer a simple forced classification based on nearest distance, but a flexible decision based on probability, thereby weakening the abrupt edges caused by hard decision and significantly reducing the visual intensity of the step-like tortuosity.
[0064] Secondly, addressing the lack of spatial modulation in traditional technologies, this application utilizes the parity of pixel positions in the image plane to correlate the assignment probability with spatial position, enabling adjacent LEDs to alternately present primary or secondary colors based on parity differences. This probabilistic selection based on spatial parity allows the human eye to naturally mix colors at a distance, forming a smooth transition and effectively simulating intermediate tones beyond the number of baseline colors.
[0065] In addition, to address the issues of color banding and jagged edges caused by the limited size of the color palette, this application uses a combination of attribution probability and odd / even position to visually fake more transition colors without increasing the number of base colors, thereby reducing the width of the color banding, weakening edge jagged edges, and making the overall lighting effect softer and more natural, thus meeting users' expectations for high-quality pixelated lighting effects.
[0066] Based on any embodiment of the method in this application, obtaining a target image for constructing lighting effect animation data includes:
[0067] Step S5110: Obtain the image sequence of the animation data, and convert each image in the image sequence into a standardized specification;
[0068] Acquiring an animation data image sequence and converting it to a standardized specification essentially unifies dynamic visual content from any source into a standard canvas required for subsequent pixelation processing. Animation data can be a locally stored GIF, APNG, or MP4 file, or it can be an HLS stream, RTMP stream, or even a WebP sequence generated in the cloud, all pulled in real-time via network protocols; regardless of the source, it can first be split into consecutive image sequences.
[0069] During frame splitting, the decoder outputs frame by frame according to the timestamp of the container. Each frame resides in memory as an RGB or RGBA bitmap with a bit depth of eight bits per channel. If the original material has a high bit depth, it is reduced to eight bits in advance through linear scaling or gamma correction to avoid subsequent computational burden.
[0070] Regarding frame rate, high frame rate source material can be extracted at fixed intervals or using an adaptive algorithm to ensure that the number of frames falls within a preset range, thus ensuring animation continuity while reducing data volume; the frame interval time is scaled proportionally to the interval required for the lighting to play, ensuring consistent rhythm.
[0071] Subsequently, each image is uniformly scaled to a preset canvas size suitable for subsequent processing, such as the canvas size adapted to the image segmentation model. The scaling process uses nearest neighbor to maintain pixel sharpness, or bilinear interpolation to obtain softer edges. If the canvas ratio is inconsistent with the source material, it is adapted by center cropping or edge filling, ultimately resulting in a standardized image sequence with row and column alignment and consistent color space.
[0072] Step S5120: Perform image segmentation on each image in the image sequence to determine its image mask, and remove the background image from the image based on the image mask, while retaining its foreground image;
[0073] Each image in the image sequence is input into a preset image segmentation model to perform image segmentation and determine its image mask. Based on the image mask, the background image in the corresponding image can be removed, thereby preserving its foreground image. Thus, the foreground subject related to the lighting effect is extracted from the original animation frame, and background content that may interfere with the pixelation effect or the LED mapping is removed, thereby ensuring that the input image for subsequent color correction, pixelation and spatial modulation steps has a clear and clean visual subject.
[0074] The task of an image segmentation model is to perform pixel-level classification on each frame of the input image and generate an image mask with the same size as the input image. The image mask is a binary map or probability map, where the value of each pixel represents the probability or confidence that the pixel belongs to the foreground. Regions in the mask close to 1 are considered foreground, and regions close to 0 are considered background. This can be determined by a threshold or by the element values 0 and 1 in the binary map. After the mask is generated, the original input image is processed pixel by pixel based on the mask: pixels marked as foreground are retained, while pixels marked as background are made transparent or uniformly filled with a neutral color, thus completing the background removal operation.
[0075] In practical implementations, image segmentation models can employ various architectures. First, there are saliency detection models based on deep convolutional neural networks, such as BiRefNet. Through multi-scale feature fusion and edge refinement mechanisms, they can accurately distinguish foreground subjects from complex backgrounds, making them particularly suitable for animation frames containing people, animals, or objects. Second, there are semantic segmentation networks, such as DeepLab or Mask R-CNN, suitable for scenarios where the foreground category is known and training data is sufficient, providing category-level mask outputs. Third, there are lightweight segmentation networks, such as Mobile-SAM or U... 2 -Net is suitable for resource-constrained edge devices, and can reduce computational overhead while maintaining segmentation accuracy.
[0076] In one embodiment, to maintain the consistency and stability of the foreground subject over time, temporal consistency constraints can be introduced during the animation frame sequence processing. For example, optical flow estimation or inter-frame differencing methods can be used to smooth the mask sequence, preventing drastic jitter in the foreground contour between adjacent frames. Alternatively, recurrent neural networks or temporal convolutional networks can be used to model the mask sequence, ensuring that the segmentation results remain temporally coherent. For scenarios requiring user interaction, a semi-automatic segmentation mode can also be provided, allowing users to annotate foreground regions on keyframes, thereby automatically generating masks for the remaining frames.
[0077] Ultimately, the foreground image after background removal will serve as the input target image for subsequent steps. Its content is clear, the edges are complete, and the background is transparent, providing a high-quality data foundation for pixelation, palette generation, and spatial modulation.
[0078] Step S5130: Perform super-resolution processing on each image in the image sequence, and use each image as the target image for constructing lighting effect animation data.
[0079] Super-resolution processing of individual images in an image sequence refers to inputting the foreground-extracted image into a pre-defined deep learning model. While maintaining the original aspect ratio, the model enlarges the low- or medium-resolution image to a higher desired clarity, ensuring that subsequent pixelation, color correction, and spatial modulation steps can be performed based on an image with complete details and sharp edges. This processing does not alter the geometric information of the original content; it only improves visual fidelity by increasing the effective pixel density.
[0080] In practical implementations, super-resolution models can utilize publicly available network structures such as Real-ESRGAN, ESRGAN, SRCNN, EDSR, SwinIR, or Swin2SR, or lightweight models quantized for mobile or embedded devices, such as Real-ESRGAN-mobile and ESRGAN-tiny. Real-ESRGAN, based on generative adversarial networks, extracts high-frequency textures through degenerate kernel estimation and residual dense blocks, achieving excellent reconstruction results for hair, text, or gradient regions in animation frames. ESRGAN introduces a relative average discriminant loss in the discriminator, which can further suppress artifacts. SwinIR and Swin2SR utilize a shifted window attention mechanism, taking into account both global dependencies and local details, making them suitable for processing animation frames containing complex foreground subjects.
[0081] After super-resolution processing, the number of pixels is typically increased by 4 or 16 times, for example, from 256×256 to 1024×1024. When the image is then scaled down to the physical resolution of the lighting fixture in subsequent steps, blocky blurring caused by directly enlarging a low-resolution image can be avoided. Jagged edges in the foreground are suppressed, and fine textures are preserved, providing high-quality input for subsequent pixelation, color clustering, and odd-even space modulation. Ultimately, this results in a delicate and coherent visual effect on planar lights or curtain lights.
[0082] Through the above process, the original animation data is transformed into a sequence of target images with uniform specifications, clean foreground, and high resolution. This result provides several irreplaceable technical advantages in terms of pixelation style adaptation: First, the standardized canvas and inter-frame temporal synchronization ensure that all images are precisely aligned with the physical array of lighting fixtures in terms of spatial coordinates and temporal rhythm, eliminating mapping errors caused by size drift or frame rate misalignment. Second, the sharp edges and complete structure of the foreground subject after background culling make the correspondence between the subsequent finite color palette and pixel grid clearer, avoiding interference from background noise on color clustering, thereby improving the color purity of pixel blocks. Third, super-resolution reconstruction maintains high-frequency textures and gradient details while amplifying pixel density, ensuring sufficient visual information is retained even when downsampled to the lighting fixture resolution. This ensures smooth transitions and jagged edges in the pixelated color blocks, resulting in a high-fidelity, low-distortion, and coherent overall lighting effect. It is evident that the above embodiment is an organic processing procedure that ensures the target image is converted into images of lighting effect animation data adapted for use with ambient lighting fixtures according to a standardized mechanism.
[0083] Based on any embodiment of the method in this application, an image sequence of animation data is obtained, and each image in the image sequence is converted into a standardized specification, including:
[0084] Step S5111: Obtain animation data and parse the animation data to obtain the corresponding image sequence;
[0085] When users need to use ambient lighting to play corresponding pixelated animated lighting effects, corresponding animation data can be provided. This animation data can be local files, live streams, or cloud-generated content. Local files include common container formats such as GIF, APNG, MP4, MOV, and WebM stored on the terminal's disk or external media; live streams cover HLS slices pulled via HTTP, RTMP push streams, UDP multicast streams, and WebRTC real-time channels; cloud-generated content can be a multi-frame WebP sequence returned instantly according to API requests, or a packaged file downloaded directly from object storage. In one embodiment, the animation data can be high-definition GIF animation data generated by a text-based image model based on the prompt text entered by the user.
[0086] Once the user provides animation data, the data is first read in binary format and then parsed by the corresponding decoder. For local files, FFmpeg, OpenCV, Pillow, or a system-level decoder can be used to open the container and extract basic metadata. For real-time streams, a network session is first established to obtain the SDP or M3U8 index, and then the media segments are pulled in timestamp order. For cloud sequence frames, they can be read directly by filename or index order.
[0087] After opening the file or stream, the decoder immediately scans the container-level metadata to obtain key fields such as total frames, frame rate, time base, color space, bit depth, and duration per frame. The time base is recorded in rational number form, for example, 1 / 30 represents 30fps. The decoder uses this to convert the presentation timestamp (pts) of each frame into an absolute time in milliseconds. If the container supports a variable frame rate, the duration of each frame is calculated from the difference between adjacent pts. The decoding function is called frame by frame in timestamp order to restore the compressed data to an RGB or RGBA bitmap, with a fixed bit depth of eight bits per channel. During decoding, the index number, pts, and duration of each frame are recorded simultaneously, forming a metadata table that corresponds one-to-one with the image sequence. This table can be directly referenced in subsequent frame extraction, time scaling, and canvas alignment steps without requiring further file parsing.
[0088] Step S5112: Extract frames from the image sequence according to a preset rule, and control the number of images in the sequence within a preset range;
[0089] While maintaining the semantic coherence of the animation, redundant frames in the image sequence are removed by preset rules, so that the total number of images in the sequence falls within the preset range allowed by the processing capacity of the lighting fixture, thus achieving a better adaptation effect.
[0090] The preset number corresponding to the total number of images in the image sequence can be determined by the computing power budget of subsequent pixelation, color correction, and spatial modulation stages. In one embodiment, it is divided into two levels: 10 frames and 20 frames. When the image sequence does not require subsequent manual editing, 20 frames are used to achieve smoother dynamic performance. When the image sequence needs to be continuously annotated or color blocks replaced frame by frame within the mobile application, 10 frames can be used to reduce the user's interactive load. The frame extraction rule can use the original total number of frames as the criterion and adopt a progressive interval strategy to avoid motion jumps caused by a fixed step size and ensure that any length of material can be uniformly compressed to the target number of frames.
[0091] In specific frame extraction, for example, in a 20-frame scene, if the original frame count is less than or equal to 20, all frames are retained; from 21 to 40 frames, equal-interval sampling with indices 0, 2, 4… is used, retaining every other frame; from 41 to 80 frames, indices 0, 3, 6… are retained every two frames; and for frames exceeding 80, equal-interval resampling is performed, with the step size calculated by dividing the total frame count by 10, and 20 time points are selected evenly along the time axis. In a 10-frame scene, if the original frame count is less than or equal to 10, all frames are retained; from 11 to 30 frames, equal-interval resampling is used, with the step size calculated by dividing the total frame count by 10; from 31 to 60 frames, frames are retained every other frame; and for frames exceeding 60, frames are retained every two frames. If the number of frames extracted according to the above rules is still insufficient to reach the target number, the remaining unextracted frames are supplemented at equal intervals until the difference is made up, ensuring that the frame count is strictly equal to the set value.
[0092] Step S5113: Scale the time interval between each image in the image sequence to a preset range proportional to the original frame interval;
[0093] Furthermore, the original interval time between each frame in the image sequence obtained after frame extraction can be mapped proportionally to the preset interval required for the ambient lighting to play, thereby restoring a dynamic effect on the lamp array that is consistent with the rhythm of the original animation and meets the comfort of the human eye.
[0094] To this end, the duration field of each frame recorded in the metadata table is read first. This field is in milliseconds and is calculated by the decoding stage based on the difference between the container time base and the PTS of adjacent frames. It has been saved in memory in frame index order. Then, the maximum frame interval Tr and the minimum frame interval Om of the entire sequence are calculated. If Tr equals Om, the original animation is determined to be at a constant frame rate, and the new interval t of each frame is directly set to the middle value of the preset range. If Tr is greater than Om, the frame-by-frame scaling is performed according to the formula t=m+(Ta−Om) / Tr×(x−m), where m is the minimum frame interval allowed by the lamp (200 ms), x is the maximum frame interval (400 ms), and Ta is the original average interval between the current retained frame and its next retained frame.
[0095] The above linear mapping formula ensures that the fastest motion is no shorter than 200 ms and therefore difficult to discern, and the slowest motion is no longer than 400 ms and therefore appears sluggish, while maintaining the original rhythmic characteristics of acceleration, deceleration, or constant speed. In implementation, scaling operations are performed on the CPU as floating-point numbers and then rounded to the millisecond level; the result is written back to the delay field in the frame header structure. If the lighting control protocol only supports increments of 100 milliseconds, secondary quantization is performed through rounding or down-rounding. For the 10-frame and 20-frame output levels, the formula parameters m and x remain the same, thus the playback duration ratio of the same original animation is fixed in both levels, and there are no sudden rhythmic changes when the user switches levels.
[0096] Step S5114: According to the preset canvas, scale each image in the image sequence to the canvas to convert it to a standardized size.
[0097] Each frame in the resulting image sequence after frame extraction is uniformly scaled and adapted to a preset canvas. This ensures that subsequent image segmentation models, super-resolution models, and pixelation algorithms can operate stably at a fixed input size, while also ensuring that the image content and the physical LED array of the ambient lighting fixtures are spatially mapped. The specific scaling process functionally includes coupled steps such as canvas creation, size calculation, scaling execution, and boundary filling.
[0098] First, the default canvas dimensions are determined by the input requirements of the downstream model and the lighting resolution. A common practice is to fix the canvas at 512×512 or 1024×1024 pixels, which covers the standard input of mainstream image segmentation and super-resolution models, while maintaining power-of-two boundaries during scaling and downsampling, facilitating parallel processing of SIMD instructions. Once the canvas size is determined, it is written to the configuration file as an integer, and all subsequent images must fall within this rectangular area.
[0099] Secondly, the scaling factor required to maintain the aspect ratio is calculated based on the relationship between the original frame's aspect ratio and the target canvas. Let the original frame's width be *w* and height be *h*, and the canvas's width be *ew* and height be *eh*. Then, we first calculate *scale = min(ew / w, eh / h). This factor ensures that the image does not exceed the canvas boundaries in any dimension, while avoiding deformation caused by non-proportional stretching. If the original frame's aspect ratio differs significantly from the canvas's aspect ratio, blank areas will remain within the canvas after scaling.
[0100] The scaling process then proceeds, involving either bicubic or bilinear interpolation. Bicubic interpolation uses a weighted average of 16 neighboring pixels to preserve edge sharpness, making it suitable for foreground subjects containing text or hair. Bilinear interpolation has lower computational cost, making it suitable for batch processing or edge device scenarios. After scaling, the new width nw = w × scale, and the new height nh = h × scale. The resulting image is converted to integer coordinates after processing in the floating-point domain to avoid accumulated errors.
[0101] Finally, perform boundary padding, centering the image smaller than the canvas. Vertically, the top margin is set to (eh-nh) / 2, and the bottom margin to (eh-nh-top); horizontally, the left margin is set to (ew-nw) / 2, and the right margin to (ew-nw-left); missing areas are filled with RGBA(0,0,0,0) transparent pixels to ensure a completely transparent background, facilitating subsequent masking operations.
[0102] If the canvas size matches the physical resolution of the lamp, the filled image can be directly aligned with the lamp coordinates; if there is still a difference, then nearest neighbor downsampling can be performed again in the subsequent pixelation step.
[0103] At this point, all images are converted into standardized specifications with row and column alignment, consistent width and height, and transparent background. This not only meets the input requirements of deep learning models but also ensures that coordinate offsets do not need to be recalculated when mapping each LED at the lamp end, significantly reducing the implementation complexity of subsequent pixelation and color adjustment steps.
[0104] Through the chained processing described above, animation data is parsed, frame-by-frame extracted, time-scaled, and canvas-standardized in a single process, all within a single pipeline. This eliminates redundant computations caused by repeated decoding and format conversion, significantly reducing the time overhead from raw materials to a processable image. The frame-by-frame extraction strategy locks the number of frames within a preset range, satisfying the upper limit of the lighting fixture's computing power while reducing the processing load of subsequent pixelation, color correction, and spatial adjustment, thereby improving system throughput. Proportional scaling of the timeline eliminates the need for users to manually correct the rhythm, and the standardized canvas ensures zero offset in the mapping of LED coordinates, further reducing manual interaction steps. Transparent filling and proportional preservation avoid post-processing cropping or stretching, allowing users to directly replace color blocks or doodle frame by frame on mobile devices without worrying about coordinate errors, thus lowering the editing threshold. Finally, standardized output ensures strict consistency of all frames in spatial, temporal, and color spaces, eliminating the need for secondary alignment during lighting fixture parsing, resulting in smooth, accurate, and low-latency lighting effects for users.
[0105] Based on any embodiment of the method in this application, a color palette containing a fixed number of reference colors is constructed according to the color values of pixels in the target image, and the probability distribution of each pixel mapping to each reference color in the color palette is determined, including:
[0106] Step S5210: Extract color samples from all pixels of the target image, and use a clustering algorithm to cluster the color samples to obtain a fixed number of initial color centers;
[0107] Extracting color samples from all visible pixels in a target image that has undergone standardized size conversion, and then using a clustering algorithm to compress the high-dimensional color space into a fixed number of initial color centers, can provide a starting point for subsequent Bayesian-Gaussian mixture models.
[0108] Color sample extraction can be performed directly on the RGB or RGBA channels. Specifically, by traversing the entire target image, the R, G, B triplet or R, G, B, A quadruple of each non-transparent pixel is added to the sample set; transparent pixels are ignored because their alpha value is zero to avoid interfering with foreground clustering. To improve computational efficiency, color values can be quantized into integers from 0 to 255, and the sample set can be directly placed into a contiguous memory buffer, forming an N×3 or N×4 two-dimensional floating-point matrix, where N is the total number of effective pixels.
[0109] After obtaining color samples, a clustering algorithm is called to perform unsupervised partitioning of the samples. Implementable clustering methods include K-means, K-means++, Mini-Batch K-means, Mean-Shift, and Agglomerative Clustering. Taking K-means as an example, the number of cluster centers is pre-set to be equal to the desired number of baseline colors, for example, 9. The algorithm iteratively updates the center positions until the centroid displacement is less than 1e-4 or the preset maximum number of iterations (128) is reached. To avoid local minima, a K-means++ initialization strategy is used, selecting initial centers in the sample space according to a probability distribution to ensure that the minimum distance between centers is maximized. Mini-Batch K-means is suitable for memory-constrained scenarios. By randomly sampling 4096 color vectors for each iteration, it reduces memory usage by an order of magnitude, while the convergence result differs from the full K-means by less than 0.5 ΔE. Mean-Shift clustering does not require a preset number of centers and automatically identifies density peaks through kernel density gradient ascent. However, its computational complexity increases quadratically with the sample size, making it suitable for scenarios with frame sizes smaller than 256×256. Hierarchical clustering uses the Ward minimum variance criterion, first generating a hierarchical tree and then pruning it according to a threshold. This allows for dynamically obtaining a fixed number of centers, facilitating the pruning of the number of clusters based on computing power budget during runtime.
[0110] After clustering, the algorithm outputs a fixed number of initial color centers, each represented as an RGB or RGBA floating-point vector. The number of centers is strictly consistent with the user's gear selection or the capacity of the lighting fixture's color palette. These initial color centers serve as the prior means for the next step, the Bayesian-Gaussian mixture model, and are input along with the sample matrix into subsequent steps to achieve a smooth transition from discrete cluster centers to a probability distribution.
[0111] Step S5220: Starting from the initial color center, run the Bayesian Gaussian mixture model, and use the Dirichlet distribution as the weight prior to iteratively correct the multiple initial color centers to obtain the reference color of the final color palette, and simultaneously output the probability distribution of each pixel corresponding to each reference color.
[0112] Using the initial color centers from the cluster output as the mean vector, a Bayesian Gaussian mixture model is started. The mean, covariance, and mixture weights are iteratively corrected through maximum a posteriori estimation. Finally, a fixed number of base colors constituting the color palette and the probability distribution of each pixel's association with all base colors can be output.
[0113] The model structure is a weighted superposition of a finite number of Gaussian components, each corresponding to a base color. The number of components is determined before execution, specifically the nine determined in the previous clustering step, and this number remains constant throughout the EM iterations. The initial mean is directly taken from the RGB or RGBA center coordinates obtained from K-means or K-means++. The initial covariance matrix is set to the identity matrix multiplied by 0.01 to ensure that the components do not overlap excessively or exhibit numerical singularities in the first iteration. The initial mixing weights are generated by Dirichlet priors, and the concentration parameter α is uniformly set to 1.0 to ensure that the prior weights of each component follow a uniform distribution, preventing any single color from gaining an absolute advantage in the early iterations.
[0114] In the model iteration process, the E-step calculates the posterior probability of each pixel to all components based on the current parameters, i.e., the probability distribution of its affiliation. Specifically, the color sample matrix is input into the model, and a multivariate Gaussian probability density is calculated for each pixel vector and multiplied by the corresponding weight. This is then normalized using Softmax to obtain a probability vector with a length equal to the number of components, and the sum of the vector elements is always 1. The M-step uses these posterior probabilities to re-estimate the mean, covariance, and weights: the new mean equals the centroid of the pixel color weighted posteriorly, the new covariance equals the weighted covariance matrix, and the new weights equal the sum of the posterior probabilities divided by the total number of pixels. To avoid overfitting, a Dirichlet prior pseudo-count is introduced in the M-step. The MAP update formula for the weights is (Σγ+α−1) / (N+Kα−K), where γ is the posterior sum, N is the total number of pixels, and K is the number of components. When α is 1.0, the pseudo-count is equivalent to adding an extra virtual pixel to the sample, making the weight update smoother. Using diagonal or spherical constraints on the covariance matrix can significantly reduce the number of parameters; if the full covariance is preserved, eigenvalue pruning is performed after the update to limit the minimum eigenvalue to 1e-6, preventing matrix singularity.
[0115] The iteration termination condition can be set to two consecutive log-likelihood increases being less than 1e-4 or reaching a preset maximum number of iterations, such as 128. After convergence, the mean of each Gaussian component is the base color of the final color palette, maintaining RGB or RGBA floating-point format; the probability distribution of each pixel's affiliation is directly written into the frame-level metadata as the probability vector output by Softmax, for use in subsequent odd-even space modulation steps.
[0116] If the operating environment has limited video memory, such as when running this algorithm in the control chip of an ambient lighting controller, a Mini-Batch EM can be used: 4096 pixels are randomly selected each time to perform the E and M steps, and the remaining pixels only have their assignment probabilities calculated in the last iteration. This reduces video memory usage while the convergence result differs from the full EM by less than 0.5 ΔE. On edge devices, the floating-point model can be quantized to FP16 or INT8, with weights and covariance stored using 16-bit half-precision. Fixed-point Softmax is used during the inference stage, keeping the error within 1% to meet real-time processing requirements.
[0117] By implementing a clustering algorithm and a Gaussian mixture model in a cascaded manner, the color space of the target image is first rapidly compressed into a fixed number of high-purity initial centers by the clustering algorithm. Then, with the help of the Bayesian Gaussian mixture model, iterative refinement is carried out under the maximum a posteriori framework to generate a compact and representative baseline color palette, and simultaneously output the pixel-level assignment probability distribution. This process smoothly transitions the discrete clustering results into a continuous probability expression, significantly suppressing the color banding and step discontinuities caused by traditional hard decision. At the same time, Dirichlet prior and covariance regularization effectively prevent overfitting and numerical singularities, ensuring real-time convergence even under low computing power at the lighting fixture. The final output baseline color set and assignment probability matrix directly drive the subsequent spatial modulation steps without having to traverse the pixels again or re-cluster. The overall link is superior to one-time clustering or simple Gaussian mixture model schemes in terms of accuracy, stability and real-time performance, thus obtaining the pixelated lighting effect with the highest visual fidelity with the least computational cost.
[0118] Based on any embodiment of the method in this application, corresponding to the parity of each pixel's planar spatial position in the target image, and selecting a reference color according to the assigned probability distribution to update the pixel's color value, includes:
[0119] Step S5310: Scale the target image to a preset physical resolution to obtain a pixel matrix that corresponds one-to-one with the LED beads in the ambient light fixture with that physical resolution.
[0120] In some embodiments disclosed above in this application, the target image is upscaled to a higher resolution and larger scale in advance because it is necessary to highlight its foreground subject, extract the reference color by clustering, and determine the assignment probability distribution. In this step, the target image that has completed the color palette construction and assignment probability distribution calculation can be downsampled and scaled to the same physical resolution as the ambient light lamp bead array, thereby obtaining a pixel matrix with the number of rows and columns corresponding one-to-one with the lamp beads in the ambient light.
[0121] The physical resolution is given once by the luminaire's factory parameters. It is usually in the form of an integer pair of width × height, such as 256×256 or 512×512, and is stored in the luminaire description file or the controller's flash memory. This value can be read when the ambient light is started and used to build an empty pixel matrix of the same size.
[0122] If the original width and height of the target image are rw and rh, then the scaling factor scale = min(ew / rw, eh / rh) is calculated, where ew and eh are the physical width and height of the lamp, ensuring that the image is scaled down proportionally to avoid geometric distortion. Scaling methods include nearest neighbor, bilinear, or Lanczos kernels. Nearest neighbor interpolation has the lowest computational cost and preserves sharp pixel edges, making it suitable for low-power embedded scenarios; bilinear interpolation provides a smoother transition, suitable for high-contrast animations; the Lanczos kernel strikes a balance between sharpness and smoothness and can be performed in real-time on desktop GPUs. After scaling, a new image with width ew and height eh is obtained, where each pixel position (i,j) strictly corresponds to the LED in the i-th column and j-th row of the lamp. If the original image ratio is inconsistent with the lamp ratio, the blank rows and columns after scaling are filled with transparent pixels at the edges, with the fill value uniformly set to RGBA(0,0,0,0), ensuring that subsequent steps only affect the foreground pixels.
[0123] The pixel matrix thus determined is the direct object of subsequent odd-even threshold modulation and color update, without the need for coordinate transformation or secondary alignment, thereby ensuring zero-error mapping between spatial modulation logic and the physical arrangement of LEDs.
[0124] Step S5320: Set different decision thresholds according to the parity of the sum of the row and column coordinates of each pixel in the pixel matrix;
[0125] For each pixel in the pixel matrix, a decision threshold is set based on the parity of the sum of its row and column coordinates, which can be used to control the sensitivity of subsequent color replacement. Specifically, the pixel matrix is first traversed, and the row index i and column index j of each pixel are read. s = i + j is calculated. When s is even, the pixel is marked as "even position", and when s is odd, it is marked as "odd position".
[0126] Subsequently, different decision thresholds are applied to the two types of positions: the even-position threshold Te and the odd-position threshold To are stored in registers or constant tables, typically set to Te=0.5 and To=0.3, respectively. These thresholds can also be dynamically adjusted by the user via a slider in the app interface within the range of 0.2-0.7. The thresholds are stored as single-precision floating-point numbers and are directly loaded into the vector register during comparison operations, where they are judged in parallel with the second-highest probability value, requiring no additional conversion.
[0127] This mechanism generates a chessboard-like modulation by simply determining the odd or even position of the spatial location, providing a quantitative basis for adjacent LEDs to alternately present the primary or secondary color, and thus achieving a smooth transition by using spatial color mixing of the human eye without increasing the base color.
[0128] Step S5330: For each pixel in the pixel matrix, determine its highest probability value and second highest probability value in the attribution probability distribution;
[0129] After completing the one-to-one correspondence between the pixel matrix and the LED beads, the previously generated probability distribution of each pixel is read, and the highest and second-highest probability values in the distribution are immediately extracted to provide a quantitative basis for subsequent threshold comparison.
[0130] The attribution probability distribution is represented as a floating-point vector of length K, where K equals the number of base colors in the color palette and is fixed at 9. The sum of the vector elements is always 1. Each element represents the posterior probability that the current pixel belongs to the corresponding base color. In implementation, the maximum and second-maximum values are retrieved from this vector, and their corresponding probability values are used in the subsequent threshold decision stage.
[0131] Step S5340: When the second highest probability value exceeds the decision threshold set for the corresponding parity, update the color value of the pixel with the reference color corresponding to the second highest probability value; otherwise, update the color value of the pixel with the reference color corresponding to the highest probability value.
[0132] Given the previously established pixel matrix, probability distribution, and parity decision threshold, a probability-driven color decision is performed for each pixel. Specifically, for each pixel, its highest and second-highest probability values are denoted as Pmax and Psec, respectively. These are compared using the parity flag of the sum of the pixel's row and column coordinates, s, to select the corresponding decision threshold Te or To. If Psec is greater than or equal to the selected decision threshold, the current pixel color is immediately overwritten with the base color corresponding to the index of the second-highest probability; otherwise, the base color corresponding to the index of the highest probability is used. The thresholds Te and To can also be updated in real-time by the user via a slider during runtime, without requiring model retraining or probability recalculation.
[0133] When the base color is replaced with the second-highest color, adjacent LEDs exhibit an alternation of primary and secondary colors due to the odd-even cycle. This utilizes the spatial color mixing of the human eye to generate additional transition colors, thus significantly reducing color banding and step breaks under a fixed color palette. When the highest color is retained, edge areas remain sharp, ensuring that key contours are not blurred. The final output pixel matrix is perfectly aligned with the LED array in color depth, row and column positions, and can be directly used in subsequent packaging steps without secondary mapping.
[0134] Through the above embodiments, the target image is accurately downsampled to the physical resolution of the lamp, and the pixels and lamp beads achieve a zero-error one-to-one correspondence. The chessboard-style modulation mechanism composed of row and column parity markers and differential thresholds allows adjacent lamp beads to alternately present the primary or secondary color. It utilizes human eye spatial color mixing to generate additional transition colors within a fixed color palette, thereby significantly reducing color banding and step discontinuities without increasing the number of colors. The comparison between the attribution probability vector and the threshold is completed in parallel at the pixel level, and the color decision has no branch delay, so the edge areas can maintain sharp contours. The final output pixel matrix is completely aligned with the lamp bead array and can be directly encapsulated as lighting effect animation data without secondary coordinate transformation or manual alignment. The entire chain achieves high-fidelity, low-distortion, smooth and coherent pixelated lighting effects while maintaining low computing power requirements, which is significantly better than the traditional one-time hard decision or global color adjustment implementation method.
[0135] Based on any embodiment of the method in this application, the target image with updated color values is encapsulated into lighting effect animation data, including:
[0136] Step S5410: Perform color clustering based on the target image with updated color values to determine a predetermined number of color classes and the pixels that enter the color class;
[0137] Color clustering is performed again on the target image after the color update to divide the pixel set of the target image in the latest state into a predetermined number of color classes and record the color class identity of each pixel. The object of this clustering is no longer the original high-resolution image, but a low-resolution pixel matrix that has undergone parity threshold modulation and pixel-level color update. Its colors have been limited to a finite number of the aforementioned color palette, such as 9 reference colors. Therefore, the clustering process has the characteristics of limited input colors and low computational cost.
[0138] The clustering algorithm can use the same technology stack as revealed in step S5210, namely K-means, Mini-Batch K-means, K-means++ initialization or hierarchical clustering Ward method. Any algorithm can be reused here. The difference is that the number of cluster centers can be fixed to be less than the fixed number when the color palette was determined in the first clustering. For example, it can be set to 6 to match the length of the color table in the header of the lighting effect animation data, which is convenient for the lighting fixture to quickly index.
[0139] During execution, the pixel matrix corresponding to the target image is flattened into a two-dimensional floating-point matrix, with each row representing the RGB value of a pixel, ignoring transparent pixels. Clustering is then performed, with the convergence condition remaining that the centroid displacement is less than 1e-4 or the maximum number of iterations is 128. The output consists of six color class centers and a class index for each pixel. The class index is written to an integer mask of the same size as the pixel matrix, where each element takes a value from 0 to 5, directly indicating which color class the pixel belongs to. The color class centers are stored as RGB or RGBA floating-point vectors; subsequent steps only read their hue and brightness information. To ensure compatibility with lighting protocols, the floating-point centers are further quantized to integers from 0 to 255, ensuring that the lighting fixture can parse them without floating-point units. This clustering process yields a compact 6-color table and a pixel-by-pixel class mask.
[0140] Step S5420: When any of the color categories is determined to be black, the reference replacement color with the largest color distance from the color category other than black is determined from the preset reference replacement color set as the target replacement color.
[0141] Based on the generated 6-color table, it is possible to determine whether each color category belongs to black. Since low-brightness pixels such as black appear as off on planar lights, in order to ensure the vibrant and colorful lighting effects, the color values of pixels belonging to the black category need to be replaced to maintain the overall brightness and saturation of the lighting effects.
[0142] The luminance threshold method can be used to determine the black category. In practice, the centers of the six color categories obtained from clustering are first converted from RGB to HSV or HSL space, and the V or L component is taken as the luminance index. If the luminance value of a certain color category is lower than the preset lower limit, such as V<30 or L<40, it is marked as the black category.
[0143] Subsequently, the color with the largest average color distance from all color classes except black is selected from the preset benchmark replacement color set as the target replacement color. This benchmark replacement color set can use colors from the rainbow spectrum, such as red, orange, yellow, green, cyan, blue, and violet, for a total of 6 candidate colors; the color distance calculation can use CIE76 ΔE, CIE94 ΔE, or Euclidean distance to ensure monotonic values and low computational cost.
[0144] To avoid color conflicts after replacement, first calculate the ΔE between the black center and the remaining 5 non-black centers. Then calculate the average ΔE between each candidate color in the baseline replacement color set and these 5 non-black centers. Select the candidate color with the largest average ΔE as the target replacement color. If multiple candidate colors have the same ΔE, choose the first one in the rainbow order.
[0145] Step S5430: Replace all pixel color values in the black class with the target replacement color, and encapsulate the replaced target image into lighting effect animation data in frame order and output it.
[0146] After determining the black class and the target replacement color, the color replacement and data encapsulation phase can begin immediately. First, a pixel-by-pixel category mask is read. This mask is an integer matrix of the same size as the pixel matrix, where each element records the color class index of the pixel. For the index value marked as black, the mask is traversed, and all pixels at the corresponding positions are covered by the target replacement color. The replacement process is performed directly in the frame buffer, maintaining the RGBA format. The alpha channel retains its original value to ensure that transparent areas are not destroyed. The target replacement color has been pre-quantized into an integer from 0 to 255. During replacement, only the RGB channels are written, allowing the operation to be completed in parallel with a single instruction and multiple data, with a latency of less than one frame cycle. After replacement, the frame buffer becomes the final pixelated image, which does not contain black pixels, and all color values fall within the integer range that the lighting fixture can parse. The above process can be completed in milliseconds using only table lookups and index rewriting, ensuring that the lighting fixture can parse without floating-point operations, ultimately achieving a lighting effect with no black dead zones and rich, saturated colors.
[0147] After all the images required for constructing the lighting effect animation data have been prepared according to the above process, the pixel matrix of each target image after black replacement can be encapsulated into lighting effect animation data in frame order according to the preset encapsulation format, and can be stored as a file. Generally, the encapsulation format can be GIF format. In another embodiment, the encapsulation format uses a custom binary container, with a fixed-length 6-color table written in the header, each color stored in 3-byte RGB or 4-byte RGBA order; the following frame data area is expanded in row-major order, with pixel values pointing to the color table with a 1-byte index, ensuring that the file size matches the storage capacity of the lamp. The frame interval field can reuse the millisecond-level delay calculated in step S5113 and be directly written to the frame header without recalculation. If the lamp protocol supports compression, the frame data can be instantly compressed using RLE or LZ4 lossless compression, and the compression level is adjustable.
[0148] After encapsulation, the lighting effect animation data can be transmitted in batches to the ambient lighting controller via Bluetooth, Wi-Fi or USB. After receiving the complete data, the controller parses the color table and frame data, drives the LED beads to emit light according to the index, and realizes flicker-free, low-latency pixelated lighting effect playback.
[0149] Through the above embodiments, this application performs clustering again after completing pixel-level color updates, compressing the color set into a compact color table containing only six colors, and immediately identifying and removing the black class with extremely low brightness. Subsequently, the replacement color with the rainbow spectrum reference with the largest color distance from the remaining color classes completely covers the black pixels, completely eliminating the dead zone of the planar light at low brightness pixels, and achieving high-saturation output with no dark spots and no distortion in the entire image. This link completes clustering, judgment, replacement and encapsulation in a single pipeline. The color table length is fixed and the index length is the shortest, so the lamp end can be directly parsed without floating-point units. The frame data points to the six-color table with a 1-byte index, and with the help of lossless compression, the file size is extremely small and the transmission and decoding latency is extremely low. Finally, the lighting effect animation data presents continuous, uniform and colorful pixelated light spots when played, and the overall brightness and saturation are significantly improved, ensuring that users get a beautiful, coherent and high-quality visual experience in any scenario.
[0150] Based on any embodiment of the method in this application, after encapsulating the target image with updated color values into lighting effect animation data, the method includes:
[0151] Step S6100: In response to the lighting effect command, the lighting effect animation data is sent to the ambient lighting fixtures;
[0152] Once the lighting effect animation data is generated locally on a computer device such as a mobile terminal, the user can trigger the lighting effect application command through a mobile application or lighting control panel. The command carries the file handle or path identifier of the lighting effect animation data.
[0153] In response to user-triggered lighting effect commands, a communication session is immediately established with the ambient lighting fixture. The session channel can be Bluetooth Low Energy, Wi-Fi LAN, or USB wired link, depending on the lighting fixture model and user configuration. After the session is established, the lighting effect animation data is broken down into fixed-length data blocks, each with a verification field. These blocks are then sent packet by packet to the ambient lighting fixture's controller via the established channel. The controller verifies and caches the data in real time at the receiving end until the complete data is written to its local flash memory. If packet loss occurs in the network environment, the controller automatically requests retransmission of the corresponding block without user intervention.
[0154] After the transmission is complete, the controller returns a confirmation code to the application, prompting the user that "the lighting effect is ready." At this point, the entire distribution process ends, and the lighting effect animation data awaits parsing and playback.
[0155] Step S6200: After the ambient light fixture parses the lighting effect animation data, it reads the target image frame by frame and converts it into lighting effect control data, driving the lighting unit to play the corresponding lighting effect.
[0156] Upon receiving the complete lighting effect animation data, the ambient lighting controller immediately parses the data according to the corresponding encapsulation format protocol. Taking the encapsulation format from one embodiment disclosed in step S5430 as an example, its header is a 6-color table, with each color arranged in 3-byte RGB or 4-byte RGBA order. The subsequent frame data area expands in row-major order, with each pixel occupying a 1-byte index pointing to a color table entry. The frame header also carries a delay field in milliseconds to control the inter-frame interval. The controller first reads the fixed-length color table and stores it in a contiguous area of the on-chip SRAM. The number of color table entries is directly given by the header bytes, requiring no additional parsing. Subsequently, the controller locates each frame frame by frame according to the frame header length: the starting address of each frame is obtained by accumulating the length of the previous frame, ensuring that random access does not require traversing the entire lighting effect animation data. The frame delay field is extracted and stored in a timer register. The timer decrements internally within the controller at a resolution of 1 kHz, triggering the next frame refresh when it reaches zero.
[0157] During the frame data parsing phase, the controller maps a 1-byte index to the RGB values required for driving the LEDs. This mapping is done via a lookup table: the index value is used as an offset to directly read the color table entry in SRAM, obtaining either a 24-bit or 32-bit color. If the lamp uses PWM driving, the controller immediately splits the RGB values into three channel duty cycles and writes them to the corresponding PWM register. If the lamp uses a single-bus protocol such as the WS2812, the controller packs the 24-bit data in GRB order and outputs it continuously via the DMA channel. To improve efficiency, the controller can pre-store the color values of the next frame in the frame buffer, implementing a double-buffering mechanism: while the current frame is driving the LEDs, the next frame has already been parsed in the background, preventing screen tearing.
[0158] The number of rows and columns in the LED array and pixel matrix are pre-matched, so the parsed color values can be directly written to the driver register in row and column order without additional coordinate transformation. For transparent pixels with edge filling, the controller identifies whether the index value corresponds to the target replacement color after black-class replacement during parsing; if the replacement color has been marked as transparent, the corresponding LED remains off, and the remaining LEDs emit light according to the parsed value. After the frame playback is complete, the controller reloads the timer according to the delay field and executes it in a loop until the end of the lighting effect animation data. If loop playback is supported, the controller automatically resets the playback pointer to the first frame after the last frame ends, achieving seamless looping; if the user selects single playback, the playback pointer remains at the end, the lighting effect stops, and the system returns to the standby screen.
[0159] Based on the above process, the lighting effect animation data can be fully presented in the lighting unit of the ambient lighting fixture, thus completing the entire process from a given target image to displaying the corresponding pixelated image in the ambient lighting fixture.
[0160] Through the above embodiments, the entire link from the generation to playback of lighting effect animation data achieves a seamless closed loop between the mobile terminal and the ambient lighting fixtures: the transmission stage uses a block verification mechanism to ensure data integrity; the parsing stage uses a fixed format header and index lookup table to map the lighting effect animation data into RGB duty cycle or single-bus data that can be directly driven by the lighting fixtures; and the playback stage uses a timer and double buffering mechanism to ensure accurate inter-frame synchronization. This allows the pixelated image, after foreground segmentation, super-resolution reconstruction, Bayesian color adjustment, parity threshold modulation, and black replacement, to be projected onto the LED array completely and without loss. This link does not require secondary coordinate transformation or floating-point operations, significantly compressing end-to-end latency and storage overhead. It enables high-fidelity pixelated lighting effects with a limited color palette to be presented in real time, stably, and flicker-free on discrete LED arrays, fully demonstrating the comprehensive advantages of the technical solution of this application in terms of fidelity, real-time performance, and resource efficiency throughout the entire process from target image to lighting effect playback.
[0161] Please see Figure 3 This invention provides a lighting effect animation data generation device to meet one of the purposes of this application. It is a functional embodiment of the lighting effect animation data generation method of this application. The device includes an image acquisition module 5100, a distribution determination module 5200, a color selection update module 5300, and a data encapsulation module 5400. The image acquisition module 5100 is configured to acquire a target image for constructing lighting effect animation data. The distribution determination module 5200 is configured to construct a color palette containing a fixed number of reference colors based on the color values of pixels in the target image, and determine the probability distribution corresponding to each reference color in the color palette for each pixel. The color selection update module 5300 is configured to update the color value of a pixel by selecting a reference color based on the parity of its planar spatial position in the target image and according to the probability distribution. The data encapsulation module 5400 is configured to encapsulate the target image with updated color values into the lighting effect animation data.
[0162] Based on any embodiment of the device in this application, the image acquisition module 5100 includes: an image conversion module, configured to acquire an image sequence of animation data and convert each image in the image sequence into a standardized format; an image segmentation module, configured to perform image segmentation on each image in the image sequence to determine its image mask, remove the background image from the image based on the image mask, and retain its foreground image; and a super-resolution processing module, configured to perform super-resolution processing on each image in the image sequence and use each image as a target image for constructing lighting effect animation data.
[0163] Based on any embodiment of the device in this application, the image conversion module includes: an animation calling module, configured to acquire animation data and parse the animation data to obtain a corresponding image sequence; a frame extraction processing module, configured to extract frames from the image sequence according to a preset rule and control the number of the image sequence within a preset range; a time slot processing module, configured to scale the interval time between each image in the image sequence to a preset range proportionally to the original frame interval; and a specification processing module, configured to scale each image in the image sequence to a preset canvas to convert it to a standardized specification.
[0164] Based on any embodiment of the device in this application, the distribution determination module 5200 includes: a clustering driving module, configured to extract color samples from all pixels of the target image, cluster the color samples using a clustering algorithm to obtain a fixed number of initial color centers; and a color mapping module, configured to start from the initial color centers, run a Bayesian Gaussian mixture model, and use Dirichlet distribution as the weight prior, iteratively correct the multiple initial color centers to obtain the reference colors of the final color palette, and synchronously output the probability distribution of each pixel corresponding to each reference color.
[0165] Based on any embodiment of the device in this application, the color selection update module 5300 includes: a scaling processing module, configured to scale the target image to a preset physical resolution to obtain a pixel matrix that corresponds one-to-one with the LEDs in an ambient light fixture having the physical resolution; a threshold setting module, configured to set different decision thresholds based on the parity of the sum of the row and column coordinates of each pixel in the pixel matrix; a candidate preparation module, configured to determine the highest probability value and the second highest probability value of each pixel in the pixel matrix in the attribution probability distribution; and a color decision module, configured to update the color value of the pixel with the reference color corresponding to the second highest probability value when the second highest probability value exceeds the decision threshold set by the corresponding parity, otherwise update the color value of the pixel with the reference color corresponding to the highest probability value.
[0166] Based on any embodiment of the device in this application, the data encapsulation module 5400 includes: a color clustering module, configured to perform color clustering based on a target image with updated color values, and determine a predetermined number of multiple color classes and pixels entering the color class; a black area color selection module, configured to, when any of the color classes is determined to be black, determine the reference replacement color with the largest color distance from the color classes other than black from a preset reference replacement color set as the target replacement color; and a color replacement output module, configured to replace all pixel color values in the black class with the target replacement color, and encapsulate the replaced target image into lighting effect animation data in frame order and output it.
[0167] Based on any embodiment of the device in this application, following the data encapsulation module 5400, the device further includes: a file distribution module, configured to respond to lighting effect application instructions and distribute the lighting effect animation data to the ambient lighting fixtures; and a lighting effect playback module, configured to have the ambient lighting fixtures parse the lighting effect animation data, read the target image frame by frame and convert it into lighting effect control data, and drive the lighting unit to play the corresponding lighting effect.
[0168] To address the aforementioned technical problems, embodiments of this application also provide computer equipment. For example... Figure 4 The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, they enable the processor to implement a method for generating lighting effect animation data. The processor of the computer device provides computing and control capabilities, supporting the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When these computer-readable instructions are executed by the processor, they enable the processor to execute the lighting effect animation data generation method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0169] In this embodiment, the processor is used to execute... Figure 3 The system contains the specific functions of each module and its sub-modules, and the memory stores the program code and various data required to execute the aforementioned modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules / sub-modules in the lighting animation data generation device of this application, and the server can call the server's program code and data to execute the functions of all sub-modules.
[0170] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the lighting animation data generation method of any embodiment of this application.
[0171] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application 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 methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0172] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those in the open-source operations, methods, and processes of this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.
[0173] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
[0174] In summary, this application transforms continuous-tone images into lighting effect animation data that can be played on discrete LED arrays. By first constructing a fixed number of reference color palettes, then calculating the assignment probability for each pixel, and combining the parity of the pixel position for spatial probability modulation, color banding is significantly reduced and step breaks are eliminated under limited color conditions, achieving smooth and delicate pixelated lighting effects and meeting the needs of ambient lighting fixtures for a high-quality visual experience.
Claims
1. A method of generating lamp effect animation data, characterized by, The method comprises the following steps: obtaining a target image used for constructing light effect animation data; constructing a color palette containing a fixed number of reference colors according to color values of pixels in the target image, and determining a belonging probability distribution of each pixel mapping to each reference color of the color palette; updating a color value of each pixel according to parity of a position of the pixel in a plane space of the target image and a reference color selected according to the belonging probability distribution, comprising: scaling the target image to a preset physical resolution to obtain a pixel matrix corresponding to lamp beads of an ambient lamp having the physical resolution; setting different decision thresholds according to parity of a sum of row and column coordinates of each pixel in the pixel matrix; determining a highest probability value and a second highest probability value of each pixel in the belonging probability distribution; when the second highest probability value exceeds the decision threshold set according to the parity, updating the color value of the pixel with a reference color corresponding to the second highest probability value, otherwise, updating the color value of the pixel with a reference color corresponding to the highest probability value; encapsulating the target image with the updated color value into the light effect animation data.
2. The lamp effect animation data generation method according to claim 1, characterized by, The method comprises the following steps: obtaining a target image used for constructing light effect animation data, comprising: obtaining an image sequence of animation data, and converting each image in the image sequence into a standardized specification; performing image segmentation on each image in the image sequence to determine an image mask of the image, removing a background image in the image according to the image mask, and retaining a foreground image of the image; 3. The lamp effect animation data generation method according to claim 2, characterized by, performing super-resolution processing on each image in the image sequence, and taking each image as a target image used for constructing light effect animation data. The method comprises the following steps: obtaining an image sequence of animation data, and converting each image in the image sequence into a standardized specification, comprising: obtaining animation data, and parsing the animation data to obtain a corresponding image sequence; performing frame extraction on the image sequence according to a preset rule, and controlling a number of the image sequence within a preset number range; 4. The lamp effect animation data generation method according to claim 1, characterized by, scaling interval time between each image in the image sequence to a preset interval according to an original frame interval; scaling each image in the image sequence to a preset canvas to convert to a standardized specification. The method comprises the following steps:
5. The lamp effect animation data generation method according to claim 1, characterized by, extracting color samples from all pixels of the target image, clustering the color samples by using a clustering algorithm to obtain a fixed number of initial color centers; taking the initial color centers as a starting point, running a Bayesian Gaussian mixture model, and iteratively correcting the initial color centers to obtain reference colors of a final color palette according to a Dirichlet distribution as a weight prior, and synchronously outputting a belonging probability distribution of each pixel corresponding to each reference color. The method comprises the following steps: performing color clustering based on the target image with the updated color value, determining a predetermined number of color classes and pixels entering the color classes. When any of the color classes is determined as the black color class, a reference replacement color with the largest color distance from the color class other than the black color class is determined as a target replacement color from a preset reference replacement color set; The target replacement color is used to replace all pixel color values in the black color class, and the replaced target image is encapsulated into lamp effect animation data in frame order and outputted.
6. The method according to any one of claims 1 to 5, wherein After the target image with updated color values is encapsulated into the lamp effect animation data, the following steps are included: In response to a lamp effect application instruction, the lamp effect animation data is sent to the atmosphere lamp; After the lamp effect animation data is parsed by the atmosphere lamp, the target image is read in frame and converted into lamp effect control data to drive the lamp unit to play the corresponding lamp effect.
7. A lamp effect animation data generation apparatus characterized by comprising: The method includes the following steps: An image acquisition module is configured to acquire a target image used to construct lamp effect animation data; A distribution determination module is configured to construct a color wheel including a fixed number of reference colors according to color values of pixels in the target image, and determine a belonging probability distribution of each pixel to each reference color of the color wheel; A color selection update module is configured to update the color value of each pixel according to the belonging probability distribution and the parity of the spatial position of the pixel in the target image, including: scaling the target image to a preset physical resolution to obtain a pixel matrix corresponding to each lamp bead of an atmosphere lamp with the physical resolution; setting different decision thresholds according to the parity of the sum of the row and column coordinates of each pixel in the pixel matrix; determining the highest probability value and the second highest probability value of each pixel in the belonging probability distribution; when the second highest probability value exceeds the decision threshold set according to the parity, updating the color value of the pixel with the reference color corresponding to the second highest probability value, otherwise updating the color value of the pixel with the reference color corresponding to the highest probability value; A data encapsulation module is configured to encapsulate the target image with updated color values into lamp effect animation data.
8. The apparatus according to claim 7, wherein The distribution determination module includes: A clustering driving module is configured to extract color samples from all pixels of the target image, and use a clustering algorithm to cluster the color samples to obtain a fixed number of initial color centers; A color mapping module is configured to take the initial color centers as the starting point, run a Bayesian Gaussian mixture model, and iteratively correct the initial color centers to obtain the reference colors of the final color wheel with Dirichlet distribution as the weight prior, and synchronously output the belonging probability distribution of each pixel to each reference color. 9.A computer device, comprising a processor and a memory, and characterized in that, The processor calls and runs the computer program in the memory to execute the steps of the lamp effect animation data generation method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, The computer program implemented according to the method of any one of claims 1 to 6 is stored in the form of computer readable instructions, and when the computer program is called and run by the computer, the steps included in the corresponding method are executed.
Citation Information
Patent Citations
Atmosphere lamp control method and device, equipment and storage medium
CN115426748A
Atmosphere lamp equipment, color matching method thereof, corresponding device and medium
CN117412452A