Dynamic dimming method and system based on ambient light adaptation
By adopting technologies such as two-dimensional maximum Shannon entropy adaptive calculation threshold and multi-scale feature fusion layer in the dynamic dimming method, the problem of environmental illumination image noise and feature extraction is solved, the detection accuracy and adaptability are improved, and the model parameter search is solved The problem of low efficiency is eliminated and more efficient environmental lighting detection is achieved.
Patent Information
- Application Number
- CN202410902952.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing dynamic dimming methods, the collected ambient lighting images contain a lot of noise, the image quality is low, and it is difficult to use for ambient lighting detection. The model does not fully and accurately extract the ambient lighting features, and the model parameter search efficiency is low. And it is easy to fall into the problem of local optimal solution.
The two-dimensional maximum Shannon entropy adaptive calculation threshold is used to determine noise points. The initial small filter window and the filter window are adjusted according to the situation for denoising. A multi-scale feature fusion layer and a hybrid attention layer are designed to improve the accuracy of feature extraction. Update strategies such as linear uniform initialization strategy and random scale mutation factor find the optimal parameters of the model.
It significantly improves the quality of environmental lighting images, improves the detection accuracy and adaptability of the model, reduces the time cost of model training and optimization, can more accurately judge and output lighting conditions, and adapts to different lighting conditions and data distribution.
Smart Images

Figure CN118761925A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of ambient light adjustment, and specifically refers to a dynamic light adjustment method and system based on ambient light adaptation. Background Art
[0002] The dynamic dimming method is to analyze the ambient light conditions, generate a dimming control strategy, control the lighting system, realize dynamic dimming, provide a suitable lighting environment, and provide a comfortable environment. However, the existing dynamic dimming methods have the problem that the collected ambient light images contain a lot of noise, the image quality is low, and it is difficult to detect ambient light; the existing dynamic dimming methods have the problem that the model extracts the ambient light features incompletely and inaccurately and pays insufficient attention to key features; the existing dynamic dimming methods have the problem that the model parameter search is inefficient, inaccurate, and falls into the local optimal solution. Summary of the invention
[0003] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a dynamic dimming method and system based on ambient light adaptation. In view of the problem that the collected ambient light images contain more noise, the image quality is low, and it is difficult to detect ambient light in the existing dynamic dimming methods, this scheme is based on the two-dimensional maximum Shannon entropy adaptive calculation threshold, which can more accurately judge the noise point; adopt an initial smaller filter window and adjust it to a larger filter window according to the situation to adapt to the noise characteristics of different areas; perform denoising through median replacement to ensure more effective noise removal, while retaining image details to the greatest extent and improving the quality of ambient light images; in view of the problem that the model extracts ambient light features incompletely and accurately and pays insufficient attention to key features in the existing dynamic dimming methods, this scheme captures incomplete and inaccurate ambient light features through a multi-scale feature fusion layer. Features of the same scale improve the richness and accuracy of feature extraction, use the mixed attention layer to strengthen the focus on the key features of the ambient lighting image, improve the performance and pertinence of the model, improve the precision and accuracy of the ambient lighting detection model, and can more accurately judge and output lighting conditions. At the same time, the model has better adaptability and generalization capabilities; in view of the problems of low efficiency, low accuracy and falling into local optimal solutions in the existing dynamic dimming methods, this scheme designs the initial individual position of the diagonal linear uniform initialization strategy, designs the first update strategy based on the random scale mutation factor, designs the second update strategy based on the adaptive weight, selects the individual update strategy based on the selection threshold, finds the optimal parameters of the model, and significantly improves the performance and accuracy of the ambient lighting detection model, which can better adapt to different lighting conditions and data distributions.
[0004] The technical solution adopted by the present invention is as follows: The dynamic dimming method based on ambient light adaptation provided by the present invention comprises the following steps:
[0005] Step S1: data collection;
[0006] Step S2: denoising the ambient light image;
[0007] Step S3: construct an ambient light detection model;
[0008] Step S4: Control strategy generation.
[0009] Furthermore, in step S1, the data collection is to collect historical environmental lighting image data and lighting conditions, and use the lighting conditions as data labels.
[0010] Furthermore, in step S2, the ambient light image denoising specifically includes the following steps:
[0011] Step S21: image preprocessing, grayscale processing is performed on the ambient light image to obtain a grayscale image and a two-dimensional grayscale histogram;
[0012] Step S22: Initialize the filter window, set the initial size of the filter window to 3×3, cover the filter window on the grayscale image, and make the center of the filter window located on the central pixel of the 3×3 area at the upper left of the grayscale image;
[0013] Step S23: Calculate the threshold value, adaptively calculate the threshold value within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy, including the following steps:
[0014] Step S231: Calculate the posterior probability. Based on the two-dimensional grayscale histogram, at each pixel point in the coverage area of the filter window, calculate the average grayscale value b of its neighborhood. A binary group (a, b) is obtained from the grayscale value a of the current pixel point itself and the average grayscale value b of the neighborhood. The neighborhood refers to the pixel points in the coverage area of the filter window except the current pixel point. Then, the posterior probability of the foreground and background is calculated based on the joint probability density of the binary group (a, b). The formula used is as follows:
[0015] ;
[0016] ;
[0017] Where G0(a, b) and G1(a, b) are the posterior probabilities of the foreground and background, respectively, L is the grayscale level in the area covered by the filter window, i and j are the grayscale value indices, and g is the grayscale value of the filter window. ij is the joint probability density of the pair (a, b);
[0018] Step S232: Calculate the Shannon entropy, calculate the Shannon entropy of the foreground and background on the two-dimensional grayscale histogram, and the formula used is as follows:
[0019] ;
[0020] ;
[0021] Where X0(a, b) and X1(a, b) are the Shannon entropy of the foreground and the Shannon entropy of the background respectively;
[0022] Step S233: Calculate the threshold within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy. The formula used is as follows:
[0023] ;
[0024] Where Y is the threshold;
[0025] Step S24: Noise point determination, calculate the sum of the pixel differences between the pixel point f1 at the center of the filter window and the pixels in its neighborhood N(f1) , f o is the oth pixel in the neighborhood N(f1), if If it is less than the threshold, f1 has no noise, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S25;
[0026] Step S25: Adjust the filter window, adjust the size of the filter window to 5×5, and calculate the threshold within the coverage area of the adjusted filter window based on step S23, as well as the sum of the pixel differences between the pixel point f2 at the center of the adjusted filter window and the pixel points in its neighborhood N (f2) , f h is the hth pixel in the neighborhood N(f2), if If f2 is less than the threshold, there is no noise in f2, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S26;
[0027] Step S26: median replacement, extracting the grayscale values of all pixels in the area covered by the filter window, sorting the grayscale values, taking the sorted middle value as the grayscale value of the pixel f2 at the center of the filter window, completing the filtering of the pixel, moving the filter window to the next pixel, and returning to step S23, performing noise point judgment again based on the threshold value in the area covered by the moved filter window;
[0028] Step S27: Output the denoised image. The filtering window traverses the entire grayscale image to complete the filtering, and outputs the denoised ambient light image.
[0029] Furthermore, in step S3, the construction of the ambient light detection model specifically includes the following steps:
[0030] Step S31: Design the model structure. The ambient light detection model uses AlexNet as the basic framework. AlexNet contains 5 convolutional layers, 3 global maximum pooling layers and a fully connected layer. A multi-scale feature fusion layer is designed to replace the first convolutional layer. A mixed attention layer and a global average pooling layer are added after the last convolutional layer. The convolutional layer extracts image features. The global maximum pooling layer obtains the maximum element value in the entire feature map. The multi-scale feature fusion layer captures and fuses features of different scales. The mixed attention layer enhances the model's attention to the key features of the ambient light image by fusing spatial attention and channel attention. The global average pooling layer calculates the average value of the entire feature map and converts each feature map into a value. The fully connected layer outputs the lighting conditions of the ambient light image.
[0031] Step S32: Design a multi-scale feature fusion layer, which consists of two branches; the first branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 5×5 and a stride of 1; the second branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 3×3 and a stride of 1; the weights of the two branches are and , the feature maps obtained by the two branches are weighted and then added element by element to obtain a multi-scale feature fusion map;
[0032] Step S33: Design a hybrid attention layer. The hybrid attention layer connects the channel attention branch and the spatial attention branch in parallel. The feature matrix output by the fourth convolutional layer is processed by the two attention branches to learn channel attention and spatial attention respectively. The hybrid attention layer includes the following steps:
[0033] Step S331: channel attention branch, the formula used is as follows:
[0034] ;
[0035] ;
[0036] ;
[0037] Where A is the feature matrix output by the fourth convolutional layer, A1 and A2 are the average pooling results and the maximum pooling results, AvgPool and MaxPool are the average pooling operations and the maximum pooling operations, respectively. and They are element-wise multiplication and addition operators, δ is the sigmoid function, σ is the ReLU function, β is the BN function, and Conv 1×1 is a 1×1 convolution operation, is the channel weight matrix;
[0038] Step S332: spatial attention branch, the formula used is as follows:
[0039] ;
[0040] In the formula, Conv 5×5 is a 5×5 convolution operation, is the channel weight matrix;
[0041] Step S333: Calculate the multi-scale feature fusion layer output, the formula used is as follows:
[0042] ;
[0043] Where B is the output of the multi-scale feature fusion layer;
[0044] Step S34: Calculate the loss function, using the cross entropy between the predicted label and the true label output by the model as the loss function;
[0045] Step S35: searching for optimal model parameters, including the following steps:
[0046] Step S351: Initialize the individual position, establish a search space based on the convolution layer parameters, the fully connected layer parameters and the weights of the two branches in the multi-scale feature fusion layer, use the individual position as a representative of the ambient light detection model parameters, and use the loss function of the ambient light detection model established based on the model parameters as the individual fitness value. Design a diagonal linear uniform initialization strategy for the initial individual position, specifically: divide each dimension of the search space into M-1 equal parts, select some vertices in the diagonal subspace as the initial position of the individual, the initial position of the first individual is the minimum value of each dimension, the initial position of the Mth individual is the maximum value of each dimension, and the initial value of each dimension of the 2nd to M-1 individuals is , and are the lower and upper limits of the qth dimension of the search space, p and q are the individual index and dimension index, M is the number of individuals, and D p,q is the initialization position of the pth individual in the qth dimension;
[0047] Step S352: Individual location update strategy selection, pre-set selection threshold, randomly generate a random number for each individual before each location update, if the random number is less than the selection threshold, the individual selects the first update strategy to update the individual location; otherwise, the individual selects the second update strategy to update the individual location, including the following steps:
[0048] Step S3521: The first update strategy is designed based on the random scale mutation factor. The formula used is as follows:
[0049] ;
[0050] ;
[0051] Where D p (t) is the position of the pth individual at the tth iteration, is the position of the pth individual after using the first update strategy, D r1 (t) and D r2 (t) are the positions of two different random individuals at the tth iteration, D best (t) is the global optimal position at the tth iteration. The global optimal position is the individual position with the minimum fitness value. t is the iteration index, T is the maximum number of iterations, and ε t is the random scale mutation factor at the tth iteration, and rand is a random real number uniformly distributed between 0 and 1;
[0052] Step S3522: The second update strategy is designed based on the adaptive weight. The formula used is as follows:
[0053] ;
[0054] ;
[0055] In the formula, is the position of the pth individual after using the second update strategy, qz min and qz max are the minimum and maximum values of the adaptive weight, qz t is the adaptive weight at the tth iteration;
[0056] Step S353: Determine the optimal parameters of the model, pre-set the fitness value threshold, update the individual fitness value and the global optimal position, when the fitness value of the global optimal position is lower than the fitness value threshold, the model parameters corresponding to the global optimal position are the optimal parameters, and build the ambient light detection model based on the optimal parameters; otherwise, if the maximum number of iterations is reached, go to step S351 to reinitialize the individual position; otherwise, go to step S352 to continue iterating.
[0057] Furthermore, in step S4, the control strategy is generated by collecting real-time ambient light image data, denoising it, and inputting it into an ambient light detection model constructed based on optimal parameters to obtain the lighting conditions of the real-time ambient light image, generate a dimming control strategy based on the lighting conditions, control the lighting system, and achieve dynamic dimming.
[0058] The dynamic dimming system based on ambient light adaptation provided by the present invention comprises a data acquisition module, an ambient light image denoising module, an ambient light detection model building module and a control strategy generation module;
[0059] The data acquisition module collects historical ambient lighting image data and lighting conditions, uses the lighting conditions as data labels, and sends the data to the ambient lighting image denoising module;
[0060] The ambient light image denoising module adaptively calculates the threshold value based on the two-dimensional maximum Shannon entropy for noise point discrimination, first uses a smaller initial filtering window, then switches to a larger window as needed, completes two filterings, and denoises the noise points by median replacement, and sends the data to the ambient light detection model building module;
[0061] The ambient light detection model building module captures features of different scales through a multi-scale feature fusion layer, uses a mixed attention layer to strengthen the focus on key features of the ambient light image, designs the initial individual position of the diagonal linear uniform initialization strategy, designs two update strategies based on random scale mutation factors and adaptive weights, selects the individual update strategy based on the selection threshold, finds the optimal parameters of the model, and sends the data to the control strategy generation module;
[0062] The control strategy generation module generates a dimming control strategy based on the lighting conditions of the real-time ambient lighting image output by the ambient lighting detection model, controls the lighting system, and realizes dynamic dimming.
[0063] The beneficial effects achieved by the present invention using the above scheme are as follows:
[0064] (1) In view of the problem that the ambient light images collected in the existing dynamic dimming methods contain a lot of noise and have low image quality, making them difficult to detect for ambient light, this scheme adaptively calculates the threshold based on the two-dimensional maximum Shannon entropy, which can more accurately determine the noise points and avoid misjudging some pixels that are not noise as noise or missing the real noise; it adopts an initial small filter window and adjusts it to a larger filter window according to the situation to adapt to the noise characteristics of different regions, overcoming the problem of intricate or excessive processing caused by a single window size; denoising is performed through median replacement, ensuring more effective noise removal while retaining image details to the greatest extent; the adaptive characteristics of the overall process enable this method to have better processing capabilities for ambient light images of different types and characteristics, thereby improving the quality of ambient light images.
[0065] (2) In view of the problems in existing dynamic dimming methods, the model extracts ambient lighting features incompletely and inaccurately and pays insufficient attention to key features. This solution captures features of different scales through a multi-scale feature fusion layer, improves the richness and accuracy of feature extraction, and uses a mixed attention layer to strengthen the focus on key features of ambient lighting images, thereby improving the performance and pertinence of the model, and improving the precision and accuracy of the ambient lighting detection model. It can more accurately judge and output lighting conditions, and at the same time make the model have better adaptability and generalization capabilities, and can handle complex and diverse ambient lighting scenes.
[0066] (3) In view of the problems of low efficiency, low accuracy and falling into local optimal solutions in the existing dynamic dimming methods, this scheme designs a diagonal linear uniform initialization strategy to initialize the individual position, effectively explores a wide range of parameter space, designs the first update strategy based on random scale mutation factors, designs the second update strategy based on adaptive weights, and selects the individual update strategy based on the selection threshold to find the optimal model parameters. It significantly improves the performance and accuracy of the ambient light detection model, reduces the time cost of model training and optimization, and can better adapt to different lighting conditions and data distributions. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 A schematic diagram of the flow of the dynamic dimming method based on ambient light adaptation provided by the present invention;
[0068] Figure 2 A schematic diagram of a dynamic dimming system based on ambient light adaptation provided by the present invention;
[0069] Figure 3 is a schematic flow chart of step S2;
[0070] Figure 4 It is a schematic diagram of the process of step S3.
[0071] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention. DETAILED DESCRIPTION
[0072] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0073] In the description of the present invention, it should be understood that terms such as “upper”, “lower”, “front”, “back”, “left”, “right”, “top”, “bottom”, “inside” and “outside” indicating directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as limiting the present invention.
[0074] Example 1, see Figure 1 The present invention provides a dynamic dimming method based on ambient light adaptation, which comprises the following steps:
[0075] Step S1: data collection, collecting historical environmental lighting image data and lighting conditions, and using the lighting conditions as data labels;
[0076] Step S2: denoising the ambient light image, adaptively calculating the threshold based on the two-dimensional maximum Shannon entropy for noise point discrimination, using two scales of filtering windows to complete two filterings, and denoising the noise points by median replacement;
[0077] Step S3: Construct an ambient light detection model, capture features of different scales through a multi-scale feature fusion layer, use a mixed attention layer to strengthen the focus on key features of ambient light images, design a diagonal linear uniform initialization strategy for initial individual positions, design two update strategies based on random scale mutation factors and adaptive weights, select an individual update strategy based on a selection threshold, and find the optimal model parameters;
[0078] Step S4: generating a control strategy, based on the lighting conditions of the real-time ambient lighting image output by the ambient lighting detection model, generating a dimming control strategy to control the lighting system and realize dynamic dimming.
[0079] Example 2, see Figure 1 and Figure 3 This embodiment is based on the above embodiment. In step S2, the ambient light image denoising specifically includes the following steps:
[0080] Step S21: image preprocessing, grayscale processing is performed on the ambient light image to obtain a grayscale image and a two-dimensional grayscale histogram;
[0081] Step S22: Initialize the filter window, set the initial size of the filter window to 3×3, cover the filter window on the grayscale image, and make the center of the filter window located on the central pixel of the 3×3 area at the upper left of the grayscale image;
[0082] Step S23: Calculate the threshold value, adaptively calculate the threshold value within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy, including the following steps:
[0083] Step S231: Calculate the posterior probability. Based on the two-dimensional grayscale histogram, at each pixel point in the coverage area of the filter window, calculate the average grayscale value b of its neighborhood. A binary group (a, b) is obtained from the grayscale value a of the current pixel point itself and the average grayscale value b of the neighborhood. The neighborhood refers to the pixel points in the coverage area of the filter window except the current pixel point. Then, the posterior probability of the foreground and background is calculated based on the joint probability density of the binary group (a, b). The formula used is as follows:
[0084] ;
[0085] ;
[0086] Where G0(a, b) and G1(a, b) are the posterior probabilities of the foreground and background, respectively, L is the grayscale level in the area covered by the filter window, i and j are the grayscale value indices, and g is the grayscale value of the filter window. ij is the joint probability density of the pair (a, b);
[0087] Step S232: Calculate the Shannon entropy, calculate the Shannon entropy of the foreground and background on the two-dimensional grayscale histogram, and the formula used is as follows:
[0088] ;
[0089] ;
[0090] Where X0(a, b) and X1(a, b) are the Shannon entropy of the foreground and the Shannon entropy of the background respectively;
[0091] Step S233: Calculate the threshold within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy. The formula used is as follows:
[0092] ;
[0093] Where Y is the threshold;
[0094] Step S24: Noise point determination, calculate the sum of the pixel differences between the pixel point f1 at the center of the filter window and the pixels in its neighborhood N(f1) , f o is the oth pixel in the neighborhood N(f1), if If it is less than the threshold, f1 has no noise, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S25;
[0095] Step S25: Adjust the filter window, adjust the size of the filter window to 5×5, and calculate the threshold within the coverage area of the adjusted filter window based on step S23, as well as the sum of the pixel differences between the pixel point f2 at the center of the adjusted filter window and the pixel points in its neighborhood N (f2) , f h is the hth pixel in the neighborhood N(f2), if If f2 is less than the threshold, there is no noise in f2, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S26;
[0096] Step S26: median replacement, extracting the grayscale values of all pixels in the area covered by the filter window, sorting the grayscale values, taking the sorted middle value as the grayscale value of the pixel f2 at the center of the filter window, completing the filtering of the pixel, moving the filter window to the next pixel, and returning to step S23, performing noise point judgment again based on the threshold value in the area covered by the moved filter window;
[0097] Step S27: Output the denoised image. The filtering window traverses the entire grayscale image to complete the filtering, and outputs the denoised ambient light image.
[0098] By performing the above operations, in view of the problem that the collected ambient light images contain more noise and lower image quality in the existing dynamic dimming methods, which makes it difficult to detect ambient light, this scheme is based on the adaptive calculation threshold of the two-dimensional maximum Shannon entropy, which can more accurately judge the noise points and avoid misjudging some pixels that are not noise as noise or missing the real noise; adopt an initial smaller filter window and adjust it to a larger filter window according to the situation to adapt to the noise characteristics of different regions, and overcome the problem of indetailed or excessive processing that may be caused by a single window size; perform denoising through median replacement to ensure more effective noise removal while retaining image details to the greatest extent; the adaptive characteristics of the overall process enable this method to have better processing capabilities for ambient light images of different types and characteristics, thereby improving the quality of ambient light images.
[0099] Example 3, see Figure 1 and Figure 4 Based on the above embodiment, in step S3, building an ambient light detection model specifically includes the following steps:
[0100] Step S31: Design the model structure. The ambient light detection model uses AlexNet as the basic framework. AlexNet contains 5 convolutional layers, 3 global maximum pooling layers and a fully connected layer. A multi-scale feature fusion layer is designed to replace the first convolutional layer. A mixed attention layer and a global average pooling layer are added after the last convolutional layer. The convolutional layer extracts image features. The global maximum pooling layer obtains the maximum element value in the entire feature map. The multi-scale feature fusion layer captures and fuses features of different scales. The mixed attention layer enhances the model's attention to the key features of the ambient light image by fusing spatial attention and channel attention. The global average pooling layer calculates the average value of the entire feature map and converts each feature map into a value. The fully connected layer outputs the lighting conditions of the ambient light image.
[0101] Step S32: Design a multi-scale feature fusion layer, which consists of two branches; the first branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 5×5 and a stride of 1; the second branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 3×3 and a stride of 1; the weights of the two branches are and , the feature maps obtained by the two branches are weighted and then added element by element to obtain a multi-scale feature fusion map;
[0102] Step S33: Design a hybrid attention layer. The hybrid attention layer connects the channel attention branch and the spatial attention branch in parallel. The feature matrix output by the fourth convolutional layer is processed by the two attention branches to learn channel attention and spatial attention respectively. The hybrid attention layer includes the following steps:
[0103] Step S331: channel attention branch, the formula used is as follows:
[0104] ;
[0105] ;
[0106] ;
[0107] Where A is the feature matrix output by the fourth convolutional layer, A1 and A2 are the average pooling results and the maximum pooling results, AvgPool and MaxPool are the average pooling operations and the maximum pooling operations, respectively. and They are element-wise multiplication and addition operators, δ is the sigmoid function, σ is the ReLU function, β is the BN function, and Conv 1×1 is a 1×1 convolution operation, is the channel weight matrix;
[0108] Step S332: spatial attention branch, the formula used is as follows:
[0109] ;
[0110] In the formula, Conv 5×5 is a 5×5 convolution operation, is the channel weight matrix;
[0111] Step S333: Calculate the multi-scale feature fusion layer output, the formula used is as follows:
[0112] ;
[0113] Where B is the output of the multi-scale feature fusion layer;
[0114] Step S34: Calculate the loss function, using the cross entropy between the predicted label and the true label output by the model as the loss function;
[0115] Step S35: Search for optimal model parameters.
[0116] By performing the above operations, in view of the problems in the existing dynamic dimming methods, such as incomplete and inaccurate model extraction of ambient lighting features and insufficient attention to key features, this scheme captures features of different scales through a multi-scale feature fusion layer, improves the richness and accuracy of feature extraction, and uses a mixed attention layer to strengthen the attention to key features of ambient lighting images, thereby improving the performance and pertinence of the model, and improving the precision and accuracy of the ambient lighting detection model. It can more accurately judge and output lighting conditions, and at the same time make the model have better adaptability and generalization ability, and can handle complex and diverse ambient lighting scenes.
[0117] Example 4, see Figure 1 This embodiment is based on the above embodiment. In step S35, the model optimal parameter search specifically includes the following steps:
[0118] Step S351: Initialize the individual position, establish a search space based on the convolution layer parameters, the fully connected layer parameters and the weights of the two branches in the multi-scale feature fusion layer; the convolution layer parameters include the size, number and step size of the convolution kernel, and the fully connected layer parameters include the number of neurons; use the individual position as a representative of the ambient light detection model parameters, and use the loss function of the ambient light detection model established based on the model parameters as the individual fitness value, and design a diagonal linear uniform initialization strategy for the initial individual position, specifically: divide each dimension of the search space into M-1 equal parts, select some vertices of the diagonal subspace as the initial position of the individual, the initial position of the first individual is the minimum value of each dimension, the initial position of the Mth individual is the maximum value of each dimension, and the initial value of each dimension of the 2nd to M-1 individuals is , and are the lower and upper limits of the qth dimension of the search space, p and q are the individual index and dimension index, M is the number of individuals, and D p,q is the initialization position of the pth individual in the qth dimension;
[0119] Step S352: Individual location update strategy selection, pre-set selection threshold, randomly generate a random number for each individual before each location update, if the random number is less than the selection threshold, the individual selects the first update strategy to update the individual location; otherwise, the individual selects the second update strategy to update the individual location, including the following steps:
[0120] Step S3521: The first update strategy is designed based on the random scale mutation factor. The formula used is as follows:
[0121] ;
[0122] ;
[0123] Where D p (t) is the position of the pth individual at the tth iteration, is the position of the pth individual after using the first update strategy, D r1 (t) and D r2 (t) are the positions of two different random individuals at the tth iteration, D best (t) is the global optimal position at the tth iteration. The global optimal position is the individual position with the minimum fitness value. t is the iteration index, T is the maximum number of iterations, and ε t is the random scale mutation factor at the tth iteration, and rand is a random real number uniformly distributed between 0 and 1;
[0124] Step S3522: The second update strategy is designed based on the adaptive weight. The formula used is as follows:
[0125] ;
[0126] ;
[0127] In the formula, is the position of the pth individual after using the second update strategy, qz min and qz max are the minimum and maximum values of the adaptive weight, qz t is the adaptive weight at the tth iteration;
[0128] Step S353: Determine the optimal parameters of the model, pre-set the fitness value threshold, update the individual fitness value and the global optimal position, when the fitness value of the global optimal position is lower than the fitness value threshold, the model parameters corresponding to the global optimal position are the optimal parameters, and build the ambient light detection model based on the optimal parameters; otherwise, if the maximum number of iterations is reached, go to step S351 to reinitialize the individual position; otherwise, go to step S352 to continue iterating.
[0129] By performing the above operations, in view of the problems of low efficiency, low accuracy and falling into local optimal solutions in the existing dynamic dimming methods, this scheme designs a diagonal linear uniform initialization strategy for the initial individual position, effectively explores a wide range of parameter space, designs the first update strategy based on the random scale mutation factor, designs the second update strategy based on the adaptive weight, selects the individual update strategy based on the selection threshold, finds the optimal model parameters, significantly improves the performance and accuracy of the ambient light detection model, reduces the time cost of model training and optimization, and can better adapt to different lighting conditions and data distributions.
[0130] Example 5, see Figure 1 This embodiment is based on the above embodiment. In step S5, the control strategy generation is to collect real-time ambient light image data, denoise it, and input it into the ambient light detection model constructed based on the optimal parameters to obtain the lighting conditions of the real-time ambient light image, generate a dimming control strategy based on the lighting conditions, control the lighting system, and realize dynamic dimming.
[0131] Example 6, see Figure 2 , this embodiment is based on the above embodiment, and the dynamic dimming system based on ambient light adaptation provided by the present invention includes a data acquisition module, an ambient light image denoising module, an ambient light detection model building module and a control strategy generation module;
[0132] The data acquisition module collects historical ambient lighting image data and lighting conditions, uses the lighting conditions as data labels, and sends the data to the ambient lighting image denoising module;
[0133] The ambient light image denoising module adaptively calculates the threshold value based on the two-dimensional maximum Shannon entropy for noise point discrimination, first uses a smaller initial filtering window, then switches to a larger window as needed, completes two filterings, and denoises the noise points by median replacement, and sends the data to the ambient light detection model building module;
[0134] The ambient light detection model building module captures features of different scales through a multi-scale feature fusion layer, uses a mixed attention layer to strengthen the focus on key features of the ambient light image, designs the initial individual position of the diagonal linear uniform initialization strategy, designs two update strategies based on random scale mutation factors and adaptive weights, selects the individual update strategy based on the selection threshold, finds the optimal parameters of the model, and sends the data to the control strategy generation module;
[0135] The control strategy generation module generates a dimming control strategy based on the lighting conditions of the real-time ambient lighting image output by the ambient lighting detection model, controls the lighting system, and realizes dynamic dimming.
[0136] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0137] While the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that many changes, modifications, substitutions and variations can be made to the embodiments without departing from the principles and spirit of the invention.
[0138] The present invention and its embodiments are described above, and such description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.
Claims
1. A dynamic dimming method based on ambient light adaptation, characterized in that: The method comprises the following steps: Step S1: data collection; Step S2: denoising the ambient light image, adaptively calculating the threshold based on the two-dimensional maximum Shannon entropy for noise point discrimination, using two scales of filtering windows to complete two filterings, and denoising the noise points by median replacement; Step S3: Construct an ambient light detection model, capture features of different scales through a multi-scale feature fusion layer, use a mixed attention layer to strengthen the focus on key features of ambient light images, design a diagonal linear uniform initialization strategy for initial individual positions, design two update strategies based on random scale mutation factors and adaptive weights, select an individual update strategy based on a selection threshold, and find the optimal model parameters; Step S4: Control strategy generation.
2. The dynamic dimming method based on ambient light adaptation according to claim 1, characterized in that: In step S3, the ambient light image denoising specifically includes the following steps: Step S21: image preprocessing, grayscale processing is performed on the ambient light image to obtain a grayscale image and a two-dimensional grayscale histogram; Step S22: Initialize the filter window, set the initial size of the filter window to 3×3, cover the filter window on the grayscale image, and make the center of the filter window located on the central pixel of the 3×3 area at the upper left of the grayscale image; Step S23: calculating a threshold value, adaptively calculating a threshold value within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy; Step S24: Noise point determination, calculate the sum of the pixel differences between the pixel point f1 at the center of the filter window and the pixels in its neighborhood N(f1) , f o is the oth pixel in the neighborhood N(f1), if If it is less than the threshold, f1 has no noise, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S25; Step S25: Adjust the filter window and adjust the size of the filter window to 5×5. Based on step S23, calculate the threshold within the coverage area of the adjusted filter window and the sum of the pixel differences between the pixel point f2 at the center of the adjusted filter window and the pixel points in its neighborhood N (f2). , f h is the hth pixel in the neighborhood N(f2), if If f2 is less than the threshold, there is no noise in f2, the filter window is moved to the next pixel point, and the process returns to step S23, and the noise point is judged again based on the threshold value in the area covered by the moved filter window; otherwise, the process goes to step S26; Step S26: median replacement, extracting the grayscale values of all pixels in the area covered by the filter window, sorting the grayscale values, taking the sorted middle value as the grayscale value of the pixel f2 at the center of the filter window, completing the filtering of the pixel, moving the filter window to the next pixel, and returning to step S23, performing noise point judgment again based on the threshold value in the area covered by the moved filter window; Step S27: Output the denoised image. The filtering window traverses the entire grayscale image to complete the filtering, and outputs the denoised ambient light image.
3. The dynamic dimming method based on ambient light adaptation according to claim 2, characterized in that: In step S23, the calculation of the threshold value specifically includes the following steps: Step S231: Calculate the posterior probability. Based on the two-dimensional grayscale histogram, at each pixel point in the coverage area of the filter window, calculate the average grayscale value b of its neighborhood. A binary group (a, b) is obtained from the grayscale value a of the current pixel point itself and the average grayscale value b of the neighborhood. The neighborhood refers to the pixel points in the coverage area of the filter window except the current pixel point. Then, the posterior probability of the foreground and background is calculated based on the joint probability density of the binary group (a, b). The formula used is as follows: ; ; Where G0(a, b) and G1(a, b) are the posterior probabilities of the foreground and background, respectively, L is the grayscale level in the area covered by the filter window, i and j are the grayscale value indices, and g is the grayscale value of the filter window. ij is the joint probability density of the pair (a, b); Step S232: Calculate the Shannon entropy, calculate the Shannon entropy of the foreground and background on the two-dimensional grayscale histogram, and the formula used is as follows: ; ; Where X0(a, b) and X1(a, b) are the Shannon entropy of the foreground and the Shannon entropy of the background respectively; Step S233: Calculate the threshold within the coverage area of the filter window based on the two-dimensional maximum Shannon entropy. The formula used is as follows: ; Where Y is the threshold.
4. The dynamic dimming method based on ambient light adaptation according to claim 1, characterized in that: In step S3, the construction of the ambient light detection model specifically includes the following steps: Step S31: Design the model structure. The ambient light detection model uses AlexNet as the basic framework. AlexNet contains 5 convolutional layers, 3 global maximum pooling layers and a fully connected layer. A multi-scale feature fusion layer is designed to replace the first convolutional layer. A mixed attention layer and a global average pooling layer are added after the last convolutional layer. The convolutional layer extracts image features. The global maximum pooling layer obtains the maximum element value in the entire feature map. The multi-scale feature fusion layer captures and fuses features of different scales. The mixed attention layer enhances the model's attention to the key features of the ambient light image by fusing spatial attention and channel attention. The global average pooling layer calculates the average value of the entire feature map and converts each feature map into a value. The fully connected layer outputs the lighting conditions of the ambient light image. Step S32: Design a multi-scale feature fusion layer, which consists of two branches; the first branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 5×5 and a stride of 1; the second branch includes a channel convolution with a convolution kernel of 5×5 and a stride of 2 and a point convolution with a convolution kernel of 3×3 and a stride of 1; the weights of the two branches are and , the feature maps obtained by the two branches are weighted and then added element by element to obtain a multi-scale feature fusion map; Step S33: Design a hybrid attention layer. The hybrid attention layer connects the channel attention branch and the spatial attention branch in parallel. The feature matrix output by the fourth convolutional layer is processed by the two attention branches to learn channel attention and spatial attention respectively. The hybrid attention layer includes the following steps: Step S331: channel attention branch, the formula used is as follows: ; ; ; Where A is the feature matrix output by the fourth convolutional layer, A1 and A2 are the average pooling results and the maximum pooling results, AvgPool and MaxPool are the average pooling operations and the maximum pooling operations, respectively. and They are element-wise multiplication and addition operators, δ is the sigmoid function, σ is the ReLU function, β is the BN function, and Conv 1×1 is a 1×1 convolution operation, is the channel weight matrix; Step S332: spatial attention branch, the formula used is as follows: ; In the formula, Conv 5×5 is a 5×5 convolution operation, is the channel weight matrix; Step S333: Calculate the multi-scale feature fusion layer output, the formula used is as follows: ; Where B is the output of the multi-scale feature fusion layer; Step S34: Calculate the loss function, using the cross entropy between the predicted label and the true label output by the model as the loss function; Step S35: Search for optimal model parameters.
5. The dynamic dimming method based on ambient light adaptation according to claim 4, characterized in that: In step S35, the model optimal parameter search specifically includes the following steps: Step S351: Initialize the individual position, establish a search space based on the convolution layer parameters, the fully connected layer parameters and the weights of the two branches in the multi-scale feature fusion layer, use the individual position as a representative of the ambient light detection model parameters, and use the loss function of the ambient light detection model established based on the model parameters as the individual fitness value. Design a diagonal linear uniform initialization strategy for the initial individual position, specifically: divide each dimension of the search space into M-1 equal parts, select some vertices in the diagonal subspace as the initial position of the individual, the initial position of the first individual is the minimum value of each dimension, the initial position of the Mth individual is the maximum value of each dimension, and the initial value of each dimension of the 2nd to M-1 individuals is , and are the lower and upper limits of the qth dimension of the search space, p and q are the individual index and dimension index, M is the number of individuals, and D p,q is the initial position of the pth individual in the qth dimension; Step S352: Individual location update strategy selection, pre-set selection threshold, randomly generate a random number for each individual before each location update, if the random number is less than the selection threshold, the individual selects the first update strategy to update the individual location; otherwise, the individual selects the second update strategy to update the individual location, including the following steps: Step S3521: The first update strategy is designed based on the random scale mutation factor. The formula used is as follows: ; ; Where D p (t) is the position of the pth individual at the tth iteration, is the position of the pth individual after using the first update strategy, D r1 (t) and D r2 (t) are the positions of two different random individuals at the tth iteration, D best (t) is the global optimal position at the tth iteration. The global optimal position is the individual position with the minimum fitness value. t is the iteration index, T is the maximum number of iterations, and ε t is the random scale mutation factor at the tth iteration, and rand is a random real number uniformly distributed between 0 and 1; Step S3522: The second update strategy is designed based on the adaptive weight. The formula used is as follows: ; ; In the formula, is the position of the pth individual after using the second update strategy, qz min and qz max are the minimum and maximum values of the adaptive weight, qz t is the adaptive weight at the tth iteration; Step S353: Determine the optimal parameters of the model, pre-set the fitness value threshold, update the individual fitness value and the global optimal position, when the fitness value of the global optimal position is lower than the fitness value threshold, the model parameters corresponding to the global optimal position are the optimal parameters, and build the ambient light detection model based on the optimal parameters; otherwise, if the maximum number of iterations is reached, go to step S351 to reinitialize the individual position; otherwise, go to step S352 to continue iterating.
6. The dynamic dimming method based on ambient light adaptation according to claim 1, characterized in that: In step S4, the control strategy is generated by collecting real-time ambient lighting image data, denoising it, and inputting it into an ambient lighting detection model constructed based on optimal parameters to obtain the lighting conditions of the real-time ambient lighting image, generate a dimming control strategy based on the lighting conditions, control the lighting system, and achieve dynamic dimming.
7. The dynamic dimming method based on ambient light adaptation according to claim 1, characterized in that: In step S1, the data collection is to collect historical environmental lighting image data and lighting conditions, and use the lighting conditions as data labels.
8. A dynamic dimming system based on ambient light adaptation, used to implement the dynamic dimming method based on ambient light adaptation as claimed in any one of claims 1 to 7, characterized in that: It includes data acquisition module, ambient light image denoising module, ambient light detection model building module and control strategy generation module; The data acquisition module collects historical ambient lighting image data and lighting conditions, uses the lighting conditions as data labels, and sends the data to the ambient lighting image denoising module; The ambient light image denoising module adaptively calculates the threshold value based on the two-dimensional maximum Shannon entropy for noise point discrimination, first uses a smaller initial filtering window, then switches to a larger window as needed, completes two filterings, and denoises the noise points by median replacement, and sends the data to the ambient light detection model building module; The ambient light detection model building module captures features of different scales through a multi-scale feature fusion layer, uses a mixed attention layer to strengthen the focus on key features of the ambient light image, designs the initial individual position of the diagonal linear uniform initialization strategy, designs two update strategies based on random scale mutation factors and adaptive weights, selects the individual update strategy based on the selection threshold, finds the optimal parameters of the model, and sends the data to the control strategy generation module; The control strategy generation module generates a dimming control strategy based on the lighting conditions of the real-time ambient lighting image output by the ambient lighting detection model, controls the lighting system, and realizes dynamic dimming.
Citation Information
Cited By
Spiral chute ore belt boundary identification method capable of dynamically adjusting weight and threshold value
CN120411150A
A method for identifying the boundary of a spiral chute ore zone by dynamically adjusting weights and thresholds.
CN120411150B
