Test Kits Using Phone RGB - Color Blind Testing Aid

https://www.triton.de/en/
Hi all. I've been a long time lurker getting lots of useful info off the forum to set up my first tank. I got some personal help last week with a fish diagnosis so I was looking for some way to give back to the community.

I am color blind which makes reading most test kits impossible. I have been using all Red Sea test kits. I can see the color change on the Alkalinity if I do 0.5 dkH increments but that is it. The rest I have are pink to blue color changes and I just can't see the red.

To get around this I use a phone app that takes the sensor color from a few pixels of the camera and outputs the RGB (Red, Green, Blue) values live on the screen. It will also do some translation of the RGB values and interpret them to a color name. My current phone is a Samsung Galaxy S8+ and the free App I have been using is called "Color Grab". The only issue I have had is that occasionally it seems like the colors on the phone will "shift" and aren't the values I expect for a given test. A phone reboot will usually fix this (and require a repeat test).

The screen grab of the app screen (with the large red circle in the top left) shows a target circle in the middle of the screen. It gives live value of the RGB (red, green, blue) values in the top left corner and a translated color name (Violet: Pink in this picture). For my tests I will watch the RGB values and wait for them to stabilize at each step.

For a testing location I have a Harbor Freight magnifying light angled towards a white piece of paper on my work area that I use for a backdrop (there is a picture of this with a circle around the backdrop). Distance from the phone to the test piece is around 6-8 inches. The distance between the vial and the camera can effect the color so I try to maintain the same distance throughout the test and keep the dot on the same location on the vial. Sometimes the camera will have difficulty getting a good focus but this doesn't seem to effect the color (blue is blue whether in focus or not).

Disclaimer: there are some very detailed testing procedures on the forum where individuals mix up a solutions to a known value, do repeat testing, determine testing error, etc. This is not one of those. In my tests I pick a standard color threshold that I use to end my test. I feel I can repeat this value test to test. This allows me to target my parameters at a stable value, however, what I am calling calcium of 400 may actually be higher or lower than 400 depending on when you call the testing "done". I just try to make sure I am in the ball park of target values and then keep it stable. I would have to mix up known concentrations to get a true correlation. It is the same issue that someone trying to judge the color change would have. The methods could definitely be used to produce a more accurate absolute value with some care and testing because the color change can be quantified to a number.

Test method: I follow the standard test protocol for the test kit and then use the app for the final titration step. For the pictures shown I used a 0.02ml increment of titrant with 10 seconds of stirring/shaking per dose. I then wait 10-20 seconds for the RGB values to stabilize. It is important to hold the camera to vial distance relatively constant and to target the same spot on the sample. I don't have a test rig to hold the distance fixed, I just eyeball the size of the vial on the screen and try to keep it the same.

The tests shown below are Red Sea Pro Calcium, Magnesium, and Potassium tests. For each of these tests they change from a pink to blue color. I focus only on the Red value of the RGB (the first number) and use this to determine when my testing is complete.

I use the following thresholds to call my test complete:
Calcium: Red < 50
Magnesium: Red < 50
Potassium: Red < 20

These values are towards the end of the steep part of the color change. Someone with more knowledge of the chemical reactions may be able to help me with what part of the curve to target for a more absolute value.

In the examples below for each test I have a plot of the amount of titrant added on the X-Axis with the Red value plotted on the Y-Axis. I also include a table of the values on the graph. For these three tests I would use a value of 0.9 for calcium (first test point with Red <50), 0.66 for Magnesium (first test point with Red <50), and 0.22 for Potassium (first test point with Red <20). From the test cards this gives me values of Calcium:450 , Magnesium:1320 , and Potassium:404.

Also included are select screen grabs of the vials during the tests. In these I have added the black box with the test (Ca for calcium, Mg for Magnesium, and K for Potassium) followed by the amount of titrant added for that picture.

Enjoy,

PapaElf

App.jpg Setup.jpg Calcium.jpg Magnesium.jpg Potassium.jpg Calcium1.JPG Calcium2.JPG Calcium3.JPG Magnesium1.JPG Magnesium2.JPG Magnesium3.JPG Potassium1.JPG Potassium2.JPG Potassium3.JPG
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
Calcium

For the first Red Sea Pro Calcium post I used a ~6 inch distance from the phone to the vial and used the Red from the RGB as the indicator for test completion.

Here I have a back to back comparison with the vial at a distance (~6 inches away) and with the vial against the camera using the foam block.
The 6 inch distance results are compared using the RGB Red as the indicator and with the HSV Hue as a comparison. The foam block results with the vial against the camera only use the HSV Hue results.

The plot labeled "Calcium at Distance : Red" is the camera at ~6 inches using the RGB Red as the indicator. I have been using a value of Red < 50 as the test stop which would be 0.92ml. The curve passing through 50 has a slowly decreasing slope, so picking the 50 value was just a judgment call and I held it the same to be repeatable test to test.

The plot labeled "Calcium at Distance : Hue" is the camera at 6 inches using the HSV Hue as the indicator. The shape is very similar to the Red curve discussed above, and the slope at 0.92 ml is also a slow transition.

The color vial screen grabs are included. These have the vial visible in the picture. The HSV and RGV value are included in the top left and top right of the screen grabs and the tests are labeled with the amount of titrant added.

The plot labeled "Calcium in Foam Block:Hue" has the vial up against the camera in the foam block with the camera flashlight on and uses the HSV Hue as the indicator. Here the Hue curve makes a clear shift at 0.92ml which is a much clearer indicator that the previous plots. The 0.92ml give a Calcium value of 460.

The color screen grabs for the calcium show a very uniform color. The calcium test is very opaque which distributes the light uniformly with no glare spots or reflections and very little color variation. The RGB Red indicator in these plots also does a very clear transition dropping from 224 at 0.90ml to 5 at 0.92ml.

For future tests I will proceed with the foam block and HSV Hue as the indicator. I will use 240 as the Hue indicator with the test complete at the point where the Hue is less than 240. With the high slope this becomes a much more repeatable test with a very clear indicator. Switching to the foam block and using HUE made this test much easier to indicate the color change compared to what I was doing before. The uniform colors up close also make the test more repeatable.

calcium_far_red.jpg calcium_far_hue.jpg Calcium_far_1.JPG Calcium_far_2.JPG Calcium_far_3.JPG calcium_foam_hue.jpg Calcium_foam_1.JPG Calcium_foam_2.JPG Calcium_foam_3.JPG
 

taricha

2500 Club Member
View Badges
Joined
May 22, 2016
Messages
2,819
Reaction score
3,688
This continues to be great.
I was thinking myself about placing the color sample in a styrofoam box with most of the top covered with white paper towels to ensure super even diffused light.

I remember trying that app in the past but I couldn't remember why I went away from it. I took an overhead pictures today and then I remembered why. I attached one of my pictures. In that app you take an overhead picture, then pick a sample point on the vial, and then on the two closest colors on the card and it will interpolate your color to the neighboring colors on the card. With my lighting I get a lot of reflection from the light and a lot of shadows, light spots, and dark spots. I didn't know where to pick on my sample and if I picked different spots I could get different results
Agreed. The aquarium note app is super sensitive to light and shadows, compared to the app you are using. I was surprised when I saw how well the HSV colorspace handles shadows and bright spots.

I hope to try to use it to quantify color in Seachem Ammonia test that uses little sensitive color discs.
The issue is that the discs develop blotchy and uneven color, but I'm thinking the color selection area can be made to average over the whole area of the disc. We'll see if that helps with color interpretation.
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
Magnesium

Here is the back to back for Magnesium.
First graph Magnesium test from 6 inches using RGB Red indicator "Magnesium Far Red". This always made a nice sharp transition. My target for this was Red <50 which would be 0.66ml and a Mag level of 1320.

Second graph Magnesium test from 6 inches using HSV Hue indicator "Magnesium Far Red". Again a nice sharp transition using the Hue and a steep slope for the transition.

Color screen grabs with the amount of titrant added, HSV, and RGB values are included similar to my previous tests. These are the color pictures where the vial is visible.

Next graph is using my foam phone adapter with the vial against the camera and the camera flashlight on using the HSV Hue as the indicator "Magnesium Foam Hue". Here then end transition of the color change is extremely sharp and easy to read. Like the calcium test I am going to use an end Hue target of Hue < 240 which corresponds to 0.68ml (the first point that registers below a hue of 240) for a Mag reading of 1360. This reading is one notch higher than my previous method. Again, I'm shooting for consistency.

The color screen grabs with the foam adapter show that like the calcium test the magnesium gives a nice uniform color. The color starts at pure red with an RGB of 255,0,0 and an HSV of 0,100,100. Note that in the HSV color spectrum the Hue wraps around in a circle from 0 to 360 degrees so 0 and 360 are the same value. For my graphs I used 360 as pure red rather than 0 to make the graph more continuous as the next data point has a hue of 358 then 352. Just a note on what I am dealing with being color blind the 0.66ml and 0.68ml colors look identical to me! My wife assures me they are different.

Mag_far_red.jpg Mag_far_hue.jpg Mag_far1.JPG Mag_far2.JPG Mag_foam_hue.jpg Mag_foam1.JPG Mag_foam2.JPG
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
Nitrates

So I played around with some Nitrate samples yesterday. Unlike the other titration tests where you are detecting a color change, for Nitrates you need to be able to get the absolute color correct and repeatable which is more difficult with the lighting and shadows. I took some pictures from different angles to try to get an idea of the color variation. From my previous post with Nitrates with the Red Sea kit the Hue value stays fairly constant while the Saturation values varies (the second number in HSV: Hue, Saturation, Value).

The first two photos are overhead shots. I have a hard time not getting glare light spots on the bottom of the vial and there are some shadows and light spots outside of the glare. In the spots I did pick I tried to get into a solid color patch and got saturation values of 19 and 23.

Next photo is labeled "Nitrate Far" with the vial held up against my paper back drop. Here the closer pic has decent uniformity in the color while the further picture shows a little more shadow. Saturation values are 24 and 28. You could probably make this work. By eye I would put this sample pretty close to a 5 nitrate on the card. In my previous post 5 nitrate on the card had a saturation of 25. In different light I can easily get the saturation of the card to move around by 5 but this may be close enough.

The "Nitrate Foam" picture uses my foam close up adapter with the phone flashlight on. This doesn't work well at all with the Nitrate samples. The fluid is much too transparent so there are multiple glare spots, reflections, and light and dark spots. I hunted around a little with the target and had Saturation values ranging from 38 to 54. A pretty big variation. These saturation values up close were all much higher as well, although you could calibrate around this if needed.

The poor performance of the Nitrate in the foam block got me thinking about why the calcium test is so good and uniform. In the calcium test the fluid turns very opaque and cloudy and this really helps to even out the color and dull any effects from the lighting. I did some internet searching and ended up on a Wikipedia page for "Clouding agent". It mentions some different fluid additions that will turn a fluid from clear to cloudy. It mentions fruit juices so I went in the refrigerator and grabbed some lemon juice. The final picture called lemon drops shows the same nitrate sample with 0, 12, and 24 drops of lemon juice added to it. At 24 drops everything is nice and uniform and all the glare is gone, but at the expense of some color change.

I also learned that when you forget to set your phone to HSV and leave it on RGB that there are online sites that will do the translation for you. The translated HSV values for the lemon drop samples are:
0 drops: (314, 52.5, 100)
12 drops: (337, 46.6, 96.9)
24 drops: (351, 39.6, 98)
So the lemon drops shifted the sample Hue towards Red and dropped the saturation.

So short term pictures from the top or side are probably adequate to use with the curve fit I provided previously off of the red sea card. There is some variability in the saturation depending on how you take the pictures but it isn't huge.

Long term a clouding agent used with it's own calibration curve could probably create a really repeatable nitrate calibration.

Overhead1.jpg Overhead2.jpg Foam2.JPG Foam1.JPG LemonJuice.jpg LemonDrops.JPG
 

taricha

2500 Club Member
View Badges
Joined
May 22, 2016
Messages
2,819
Reaction score
3,688
check out this as a light diffuser for sample / color card tests.
seachem ammonia test.
Seachem Ammonia.jpg

(left: samples and color card inside white styrofoam, center: cover styrofoam with paper towel with a small hole for photos, right: picture through the paper towel hole)

very even light. seems to have killed off shadows and glare.
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
check out this as a light diffuser for sample / color card tests.
seachem ammonia test.
Seachem Ammonia.jpg

(left: samples and color card inside white styrofoam, center: cover styrofoam with paper towel with a small hole for photos, right: picture through the paper towel hole)

very even light. seems to have killed off shadows and glare.

Thanks. Will give that a try.
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
Nitrate Test: Numerical Value

So I took taricha's advice and made a container to diffuse the light. I took an ice cream bucket and lined it with white paper and put a hole in the lid. I put a tissue paper with a hole over the lid to diffuse the light and it does a pretty good job. I took pictures of the Red Sea sample card in the bucket and have the Color Grab app screen grabs attached using the HSV spectrum. From my previous post on Nitrate I am using the saturation value from the HSV color map (Hue, Saturation, Value).

The first graph titled "Nitrate Fit to 50" shows the curve fit using the 2,5,10,20,50 values from the card taken in the ice cream bucket. They are plotted with a log scale on the X-axis and the log curve fit is shown on the graph. With this curve fit you would measure the saturation value of the sample and calculate the nitrate value using this equation:

Nitrate=exp( (Saturation + 4.9774)/19.186 )

I took the saturation values used to generate the curve fit and ran them through this curve fit. In the table in the bottom right of the graph these are the values in the "Curve Fit" column. The "Error" column is the difference between actual nitrate values from the card in the "Nitrate" column and the "Curve Fit" values. This shows that the curve fit is not very accurate at high Nitrate values up above 20. The error is 6.6 at a nitrate of 20 and 11.6 at a nitrate of 50. So if I had a nitrate value of 50 I would measure a saturation value of 65, my curve fit would tell me I have a nitrate value of 38.4 and I would be off by 11.4.

Since my nitrate values are usually in the 2 to 10 range and I wouldn't care much what the value is above 20 since I would be working hard to reduce it, I removed the 50 value from the nitrate card and re-did the curve fit.

The second graph titled "Nitrate Fit to 20" shows the curve fit using the 2,5,10,20 values from the sample card taken in the ice cream bucket. This produces a much better curve fit. Here is the translation from the measured saturation value to the calculated nitrate value using that fit:

Nitrate = exp ( (Saturation + 10.394)/22.705 )

Running the saturation values back through the curve fit the error values are now down to 0.3 or less.

I took pictures of my two samples with the vials in the ice cream bucket. The bucket with the tissue over the top does a good job of eliminating a lot of the glare spots and shadows in the picture. The two samples shown in the pictures have saturation values of 22% and 13%. If I run these through the curve fit I get Nitrate values of 4.2 and 2.8.

I ran one more check of the ice cream bucket by taking pictures at 5 different points in the sample vial for each of my two samples. These values are shown in the final tables. There is still a little variation in the color of the sample due to thickness variations in the bottom of the glass vial.

For the first test sample the saturation ranged from 21 to 24. Running these values through the curve fit gives nitrate values ranging from 3.8 to 4.5 which are within 0.4 of my center-point value of 4.2.

For the second test sample the saturation ranged from 12 to 14 which gives nitrate values ranging from 2.7 to 2.9. These nitrate values are within 0.1 of the 2.8 nitrate value at the center point.

so here is my final curve fit using the ice cream bucket:

Nitrate = exp ( (Saturation + 10.394)/22.705 )

It is valid in the nitrate range of 2 to 20. If it gets above 20 it is time for a water change. If it gets below 2 I will feed the corals and fish a little more to get it back to my target value of 5.

Bucket1.jpg Bucket2.jpg Card1.JPG Card2.JPG Fit50.jpg Fit20.jpg Sample1.jpg Sample2.jpg test.jpg
 

taricha

2500 Club Member
View Badges
Joined
May 22, 2016
Messages
2,819
Reaction score
3,688
Those are really tight results for aiming at different parts within the Red Sea glass vial.
using other apps or under normal light, that's really hard. the glare and shadows mean that some other color picker apps can give you answers off by more than a factor of 2 depending on where in the vial you aim.

This looks much better.

I agree that the 50 on the color card seems not applicable.

Question: have you looked at which function, or which color parameterization works best at the very low end of color formation?

Saturation doesn't work at such low deviations from white.
 
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
Those are really tight results for aiming at different parts within the Red Sea glass vial.
using other apps or under normal light, that's really hard. the glare and shadows mean that some other color picker apps can give you answers off by more than a factor of 2 depending on where in the vial you aim.

This looks much better.

I agree that the 50 on the color card seems not applicable.

Question: have you looked at which function, or which color parameterization works best at the very low end of color formation?

Saturation doesn't work at such low deviations from white.

I really need some samples below 2 to play with. Next week I will take some of my samples, measure them, and then dilute some samples down below 2 to see what happens.
 

WallyB

REEF Techno-Geek
View Badges
Joined
Jan 24, 2017
Messages
2,635
Reaction score
7,316
Location
GTA Toronto, CANADA
Really Cool.
A TON of creativity.

I'm not color blind but was looking to automate various tests for the Color Transisition point. (Something like the Reef Bot Does, but manually do the drops, while camera scans).
Your efforts are up the same alley.

My thought is using a cheap Raspberry PI, with Camera.

Setup a testing chamber with consistant light.

Find a app or maybe Openvison Has the capability to decode colors and shades.
Watch the titration and alert the color transitions.
Same for measuring Shades/Colors.

Great work. Thanks.
 

WallyB

REEF Techno-Geek
View Badges
Joined
Jan 24, 2017
Messages
2,635
Reaction score
7,316
Location
GTA Toronto, CANADA
Sounds great. Let us know how it goes.
ACtually I just tried your Color Grab Apps method.
It's works great.
Using a Salifert ALk test. It picked up the Color Change (Transition Point), before my Eyes did (and I'm not color blind).
That was just one quick test. No special Diffuser, etc.

From all your testing, putting aside app to get RGB.
Lighting, difuser, reflection, transparency are factors to get accuracy, consistancy. You proved it with your various improvments.

I had a similar issue for an image processing algorythm. Reflections off shiny surface really threw a twist on things. Amazing what we take for granted that I eyes do autmatically (auto correct in our brains).

Have you played with zooming in really close on the sample, in a good uniform color spot? Maybe you are already doing that.

Maybe the App or another that can give you a the RGB value of a IDEAL PIXEL in the image that doesn't have the reflection, and is consitant in your LIght-Photo Chamber.
 
Last edited:
OP
PapaElf

PapaElf

Community Member
View Badges
Joined
Apr 7, 2020
Messages
26
Reaction score
78
ACtually I just tried your Color Grab Apps method.
It's works great.
Using a Salifert ALk test. It picked up the Color Change (Transition Point), before my Eyes did (and I'm not color blind).
That was just one quick test. No special Diffuser, etc.

From all your testing, putting aside app to get RGB.
Lighting, difuser, reflection, transparency are factors to get accuracy, consistancy. You proved it with your various improvments.

I had a similar issue for an image processing algorythm. Reflections off shiny surface really threw a twist on things. Amazing what we take for granted that I eyes do autmatically (auto correct in our brains).

Have you played with zooming in really close on the sample, in a good uniform color spot? Maybe you are already doing that.

Maybe the App or another that can give you a the RGB value of a IDEAL PIXEL in the image that doesn't have the reflection, and is consitant in your LIght-Photo Chamber.
Sorry WallyB, missed your post. Didn't mean to snub you. Have actually been pretty happy with the ice cream bucket after using it for months. As you suggested I gravitated towards always sampling the same area of the vial. I move around a little bit and the saturation only varies by 1 point. Good enough for my purpose.
 

Larry L

Valuable Member
View Badges
Joined
Nov 4, 2014
Messages
1,348
Reaction score
1,355
Location
x
This is pretty cool stuff. I know @JimWelsh has published info about color transitions in titration tests and how to pick off the correct transition point to call the test "done", just curious what he might have to add here...
 

taricha

2500 Club Member
View Badges
Joined
May 22, 2016
Messages
2,819
Reaction score
3,688
This is pretty cool stuff. I know @JimWelsh has published info about color transitions in titration tests and how to pick off the correct transition point to call the test "done", just curious what he might have to add here...

Jim did a different test kit with a different color indicator, but his pH work is universally applicable to other Alk tests. What's missing is for someone to correlate the color scale of the Red sea kit to the pH curve in the same way Jim did for the salifert.
This app and the methods here + quality pH data = done.
 

JimWelsh

Valuable Member
View Badges
Joined
Nov 5, 2011
Messages
1,431
Reaction score
1,422
Location
Angwin, CA
This is pretty cool stuff. I know @JimWelsh has published info about color transitions in titration tests and how to pick off the correct transition point to call the test "done", just curious what he might have to add here...
Sorry, just not enough bandwidth available on my end right now. "Real job" demands are quite high this time of year. Interesting stuff being discussed here, though!
 
https://www.triton.de/en/

Do you utilize the weekends for tank tasks?

  • Yes (please tell us what in the thread)

    Votes: 298 62.5%
  • NO

    Votes: 36 7.5%
  • Sometimes

    Votes: 135 28.3%
  • Other (please explain)

    Votes: 8 1.7%

Online statistics

Members online
2,452
Guests online
6,831
Total visitors
9,283

New Posts

FM
Top