Work record: , 5 minute read

Green, at depth

In 2023 I found arrows by asking each pixel whether it was green. Then I took the question for a swim.

A filmstrip of the same test card sinking through water, with the mask each detector produced
A filmstrip of the same test card sinking through water, with the mask each detector producedOpen image to inspect at full size.

November 2023. I had just joined an underwater robotics team, and the vehicle had to follow green arrows. So I wrote forty lines of OpenCV that asked every pixel one question: is your hue between 50 and 70?

It worked beautifully. On my desk.

The 2023 script running on a desk: a hollow green arrow outlined, plus several green reflections
November 2023. The file was called arrow detection. It detected green, and also a few reflections that were feeling green that day.Open image to inspect at full size.

Three years later I went back to find out exactly how wrong it was, and when.

Water is a filter that thickens with distance

Light travelling through water loses red about twenty times faster than blue. The water also glows back at the camera with its own blue-green haze. A pixel underwater is two things added together:

I = J · e^(−k·d)  +  B · (1 − e^(−k·d))
    what's there     what the water adds

J is the object’s real colour, B the veiling light, d the metres of water between lens and object, k a per-channel attenuation. I used pure-water absorption from Pope & Fry (1997), scaled by four to stand in for a real pool. That scale is a knob, not a measurement, and the note says so wherever the number appears.

Sink it yourself. The card below goes through the same model, and the 2023 threshold judges it live. The dots on the curve are not the model: they’re real, the mean red-to-green ratio over 119 frames of the team’s own 2025 footage, per venue.

fig 1What water does to colourdrag the depth

Loading the diagram. It needs JavaScript; the text around it says the same thing in words.

Beer–Lambert per channel with veiling light, k = pure-water absorption ×4. Venue dots are measured (mongla_ws tools/studies/colour_loss.py, 119 frames); where a dot lands on the model curve is an inference, as if the camera had done nothing to the colour, and is labelled so.

Read the venues against the curve and something odd shows up: the final-run footage comes back almost colour-neutral. That doesn’t mean the water there was kinder. It means the camera, or its white balance, was set differently. Two venues, two answers, from the same pipeline, which is why a colour number has to be measured per venue instead of quoted once.

Sinking the card

A synthetic RoboSub-style card (green arrow, orange gate post, sandy floor) goes down in 0.5 m steps. Because the card is synthetic, the true mask is known to the pixel, so every strategy gets an honest score: intersection-over-union against ground truth.

Line chart of mask IoU against water depth for three strategies: as-is falls to zero by 5 m, gray-world follows it, inverting the water lasts to about 6 m
IoU against the true arrow mask. As-is and gray-world both drop below 0.5 at 3.5 m. Inverting the water holds until 6.0 m.Open image to inspect at full size.
water pathas-isgray-worldinvert the water
0 m1.0001.0001.000
2 m0.7770.9951.000
3 m0.5320.6050.987
5 m0.0000.0150.621
10 m0.0000.0000.421
below 0.5 at3.5 m3.5 m6.0 m

Three things I didn’t expect

The first failure is a hallucination, not blindness. At 2 m the orange gate post turns green enough to pass. The detector now reports two arrows. A detector that sees nothing at least tells you so. One that sees the wrong thing points the vehicle at a post with total confidence.

White balance fixes the hallucination but not the drowning. Gray-world removes the fake arrow, then loses the real one at the same depth as before. The haze flattens saturation below the threshold’s floor of 100, and no amount of rebalancing puts saturation back.

Knowing the physics buys depth until the noise collects the bill. If you know the range (a DVL or sonar gives you that on a real vehicle) you can divide the water back out. That works until the red channel is so dim that dividing by it mostly amplifies sensor noise. Then the gate post comes back as speckle.

Water decides when the threshold dies. Engineering only gets to move the depth.

Finishing the 2023 job

The repo now also contains the detector I meant to write: one that finds an arrow, not just green, and says which way it points.

  • Shape is a second opinion colour can’t fake. An arrow is solid but notched: its area is 55 to 92 % of its convex hull. The gate post is a rectangle at about 100 %. That single check removes the 2 m hallucination without any white balance.
  • The head is the wide end. My first attempt took the point farthest from the centroid as the tip, and got every arrow backwards. The head’s bulk drags the centroid forward, so the tail corners win. Version two looks along the long axis and picks the end that is wider across.

What it taught, later

The same lesson, learned for real in pools on the Duburi vehicles, is why the team’s vision moved from colour rules to learned detectors trained on underwater footage. It’s also why the paper we later wrote argued that colour is class evidence: the colour shift isn’t only noise to remove; sometimes it’s the signal.

The 2023 script is still in the repo, untouched, next to its original README. Nostalgia is allowed if it comes with a test suite.