Detecting snow on a pixel basis

I need to detect snow and my plan is to use a webcam:

step 1
Crop the relevant image are (in my case, where grass/snow is)

step 2
check all pixels if the blue channel is larger than the red channel and the values are similar (aka white).

step 3
If number is higher than x set sensor to on (snow)

It only has to work at daylight.

Is this possible within Home Assistant?