-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P050_TCS34725 - RGB raw data and/or RGB normalization #3453
Comments
The number of values in ESPEasy is limited to 4, how would you want to select what to use? Currently the raw R/G/B value and Color temperature CCT are made available. What interesting improvements have been made to the Adafruit library that we should upgrade it? In general, newer libraries are larger than previous versions, and we sure don't need more bloated/unused code... Bug-fixes are, of course, nice to have 😄 |
Uppss ... In this case more than 5 instances on the same physical device will be required ... |
Big misunderstanding: The AMS sensor and the Adafruit library dealing mainly with RGB raw data, which is dependant on different device settings like Gain and Integration Time. This raw RGB data must be normalized to:
Normalized data should be independant on device settings (e.g. Gain and Integration Time, ...) Calibration for normalized data is potentially required due to the following:
Please let us discuss the calibration topic seperately to avoid the mixture of different topics.
https://www.letscontrolit.com/wiki/index.php/TCS34725_RGB_Color_Sensor There are interesting issues on Adafruit Git: adafruit/Adafruit_TCS34725#15 My conclusion:
Note:
|
An alternative could be to generate events for all measurements. The names of these events can be stored in the settings (but have to be specifically programmed). |
I took off on the initial post, but mistakenly used Calibrated where I should have used Normalized. I'll fix that.
That's why I merged the (minimal) changes from their master branch into the current library source. I haven't taken the time yet to investigate if there are bigger fixes still pending in PR's. I'll be able to do that the next couple of days, I expect.
Please describe this as accurate as possible, as I don't own this sensor (yet) so have no way to confirm, nor the knowledge and equipment to perform such calibration. |
About the need for getting lots of units of measure from a single sensor... Another way could be to implement new commands for that plugin. |
I've added the Normalized sRGB calculation, and other code improvements (as suggested in the PR comments). The options for the RGB Values: And for the 4th value: (Not pushed yet, will be patching the (partly untested?) library code, as indicated in the issues there, after this) |
Please wait with the final merge. I'm actually working on the transformation of RGB data into CIE Color standards. The final outcome can be used to simplify the plugin by providing only the basic data because other values can be easily calculated from the normalized RGB data (4 digit precision for RGB seems to be strong enough).
|
I now also applied the patches suggested in the PR's for the library. They are mostly related to the timings of reading the values. Had to do some minor modifications because the project compiler setting are more strict than that author was using. I can provide a .bin if you tell what configuration you'd like, I'm testing with a |
Note about the proper usage of gain and integration time:
|
I do understand the relation between noise and integration time very well, and also the importance of it. Factors to include:
For example, if the net frequency is 50 Hz, then the integration time should be a multiple of 5 msec. For dimmed light it may perhaps be better to use 1/2 of the net period => 10 msec steps. When speed is a priority, the iteration steps are:
When low noise is a priority:
N.B. this only can work if the light to measure is constant over some time. |
@heinemannj Are you working/starting on the documentation part? In that case I won't try to meddle with that, as I'm kind of 'the piano-player', not the 'composer' of this plugin, and am not anywhere nearly as informed about the functional stuff of this sensor as you are. |
Please wait - I beleave I've found additional bugs in RGB caculations ... The sensor without any kind of calibration is completely useless!!! |
The RGB values measured by the sensor are tristimulus values - NOT sRGB values! https://medium.com/hipster-color-science/a-beginners-guide-to-colorimetry-401f1830b65a
Mandatory: Transform all RGB values with your evaluated calibration factors (below "Formulars" can be used) |
I'll adjust that according to your code above, this means the
It might be less error-prone to provide the calibration values in the settings and apply that in the plugin, I'll add those. The description on how to calibrate I'll leave to you 😄 |
Settings of Gain and Integration Time
To adjust Gain and Integration Time settings:
Adjust sensor's values (precision)
Calibrate your sensorThe sensor without any kind of calibration is completely useless! General information
Reference Measurements Color charts/references such as the ColorChecker can be perfectly used for reference measurements.
Because of its wide availability and use, its careful design, its consistency and because comprehensive spectrophotometric measurements are available, the ColorChecker has also been used in academic research into topics such as spectral imaging. https://en.wikipedia.org/wiki/ColorChecker https://www.simpelfilter.de/en/colorman/monitorcalibration.html Conditions
After applying calibration factors do NOT change your settings of Gain and Integration Time! "White point" calibration - the most simple oneGood wikipedia article about color calibration ("Color balance") Illuminate a white paper with white/day light (please see above conditions) and measure sensor's RGB values:
Calculate calibration factors for "White Point" [RGB(255 255 255)]:
but these factors obviously are NOT fitting for below RGB primaries ... Mapping of sensor outputs for the three RGB primary colorsMeasurement of Red ColorChecker Patch [Index No 15, sRGB(175 54 60)]:
For Green ColorChecker Patch [Index No 14, sRGB(70 148 73)]:
For Blue ColorChecker Patch [Index No 13, RGB(56 61 150)]:
Transformation into sRGB color space
Correlation constant matrix
Find the inverse Matrix: https://comnuan.com/cmnn0100f/cmnn0100f.php
Additional Useful Color Equations |
At the end of the day I need at the minimum:
For optimum implementation plus:
To be calculated via:
In addition the actual Adafruit_TCS34725 lib 1.3.3 was continiously improved during the last years.
The text was updated successfully, but these errors were encountered: