Why do I get such different values for R, G and B for very similar photos?
2 views (last 30 days)
Show older comments
I previously asked this question here. .Since then I have been finding answers little by little to the doubts that have arisen.
In short, I am applying a mask to a series of photos of a sample which is changing color over time. From each of these photos I am measuring the mean R, G and B values within the mask and then transforming them to L, a and b, and finally obtaining the Delta E values between each photo and the first one.
At first, with small samples, everything worked well, and I was able to obtain graphs like the following:
these from samples such as the following:
However, then, using larger samples, I am getting values like the following:
As I said, the only thing I did was to increase the sample size (plus change the time between each photo from about three per second to one per second, and increase the total number of photos by almost 2000).
The origin of the problem seems to be in the measurement of the values of R, G and B, because from these I did the rest of the calculations. For the large sample, where the error occurs, the values of R, G and B go up and down drastically in a strange way from photo 100 to 1800, more or less.
I checked photo 98, 99, 100 and 101 and at first sight they are identical, so the error is not born (apparently) from the analyzed photos.
These are the photos when all start to fail.
I use two codes, the first one (made by Data Analyst, shared by himself in one of the links I put in my first question) to make the mask and verify that it has a correct shape and size. And the second one to apply this mask to each of the photos of the sample and obtain from this process the values of R, G, B, L, a, b and Delta E. Finally, I also use another one to make the graphs. I share them in case you need to see them.
So, what could be going on, why from two very similar photos do you get values for R, G and B that do not make sense, why with the other sample does this error not occur?
It is worth to say that analyzing the photos 100 and 101 (where the delivered data go crazy) in the first code (the one that creates the mask) i get similar values for R, G and B, nothing like the ones delivered by the second code. So it is likely that the error has to do with the precision used for the numbers (and not with the code itself, as it was used for the small sample correctly) in addition to the fact that as the color change is more gradual in this large sample, the values from photo to photo are more similar. If the error arises from here, could you help me to correct it? I tried to make some changes but the error persisted, and I'm not very good at programming without the help of AI (my bad).
Thanks in advance!
5 Comments
DGM
on 2 Jul 2024
Oof yeah. I normally try to write numbered files using zero padding to avoid that. At least it's sorted now.
Answers (1)
Image Analyst
on 30 Jun 2024
It looks like your data for the latter plots is oscillating on an alternating element basis between two curves, hence the "solid" looking plot. Something is happening starting around image #100. It's like every other image is changing brightness.
Presumably the delta E is with respect to the very first image (not between adjacent frames), so upload that first image, plus some images between 1 and 100, and some right around the transition at the end, like around image #1900.
I don't think you're doing calibrated color measurement so the LAB values are just arbitrary (would not agree with spectrophotometer) and if there is a sudden change in illumination, then that would cause a sudden change in the LAB values, even though your sample did not change. I think you should also monitor the mean intensity of the left 30% of the image. Also plot that to make sure there is no change in it.
3 Comments
Image Analyst
on 2 Jul 2024
@Vicente if you don't see an abrupt change in brightness in the image then there should be no substantial change in the average intensity. It's probably due to incorrect (alphanumeric) sorting of your list of filenames. For example alphanumerically sorted names would go like 1.txt, 10.txt, 11.txt...2.txt, 20.txt, 21.txt and so on. You might like to read this:
or else just use dir() to get the time stamps and sort your filename list by the time stamp.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!