Vegitation Index from RGB
Posted: 2019-05-19T04:17:05-07:00
I'm trying to process some photos into green -> red gradients to highlight plant crop health where healthy regions (greens) show as bright green, while unhealthy regions (brown) show as red, with a gradient in between.
There's a couple of examples on the sort of output I'm trying to achieve here:
https://blog.dronedeploy.com/identifyin ... c380381a33
I've found some mathematics for this here (e.g. VARI is "(green-red)/(green+red-blue)"):
https://rdrr.io/cran/uavRst/man/rgb_indices.html
I've been trying out VARI and NGRDI conversions but without success. I've been trying it like this:
convert test.png -channel RGB -fx "(g-r)/(g+r-b)" -normalize out.png
and this:
convert test.png -channel RGB -fx "(u.g-u.r)/(u.g+u.r-u.b)" -normalize out.png
and this:
convert test.png -channel RGB -fx "(green-red)/(green+red-blue)" -normalize out.png
But I either get divide by zero errors, a full green output, or the output is identical to the input. I'm obviously doing something wrong - I assumed that I'd be able to drop the calculations straight in but this does not seem to be the case. The reason for posting in this forum is that I found a post here which gives me the type of output that I'm looking for, except that this one seems to be turning whiter areas into red and darker areas blue/green:
viewtopic.php?t=24682
I've tried several variations but I've not even come close. Is there anybody that can help with being able to apply the mathematical conversions in that way to images?
Thank you very much for your assistance.
There's a couple of examples on the sort of output I'm trying to achieve here:
https://blog.dronedeploy.com/identifyin ... c380381a33
I've found some mathematics for this here (e.g. VARI is "(green-red)/(green+red-blue)"):
https://rdrr.io/cran/uavRst/man/rgb_indices.html
I've been trying out VARI and NGRDI conversions but without success. I've been trying it like this:
convert test.png -channel RGB -fx "(g-r)/(g+r-b)" -normalize out.png
and this:
convert test.png -channel RGB -fx "(u.g-u.r)/(u.g+u.r-u.b)" -normalize out.png
and this:
convert test.png -channel RGB -fx "(green-red)/(green+red-blue)" -normalize out.png
But I either get divide by zero errors, a full green output, or the output is identical to the input. I'm obviously doing something wrong - I assumed that I'd be able to drop the calculations straight in but this does not seem to be the case. The reason for posting in this forum is that I found a post here which gives me the type of output that I'm looking for, except that this one seems to be turning whiter areas into red and darker areas blue/green:
viewtopic.php?t=24682
I've tried several variations but I've not even come close. Is there anybody that can help with being able to apply the mathematical conversions in that way to images?
Thank you very much for your assistance.