Reputation: 3195
I try describe my problem. Here google maps https://www.google.ru/maps/@9.1424367,78.5355178,114652m/data=!3m1!1e3 (India district Pudukkotan) Suppose i need work with this area
What should i do! The First zoom in on the satellite image
the main task get coordinates of green fields(sowing field ) and brown fields(non-sowing field )
Is there any way to get coordinates green and brown fields to data.frame(1-green,0-brown)? Or maybe is there any CV way to recognize green and brown fields in selected District?
Upvotes: 1
Views: 178
Reputation: 27732
Not sure if this solves tyour problem... But here is a first approach; seaching a specific color (wth tolerance) in your image..
library(raster)
#load inmage you posted in question
myimage.jpg <- tempfile()
download.file("https://i.sstatic.net/4WCt2.jpg",
myimage.jpg,
mode = "wb")
#load image to raster
myimage.raster <- raster::stack(myimage.jpg)
names(myimage.raster) <- c("r","g","b")
#what it looks like
plotRGB(myimage.raster)
#select some forest
myimage.forest <- myimage.raster
myimage.forest$forest <- 0
#values of greenish stuff, play around here
red <- 100
green <- 90
blue <- 60
tolerance <- 50 #this is your firs vairiable to tamper with...
#let's find some forest
myimage.forest$forest[ myimage.forest$r > (red * (100 - tolerance) / 100) &
myimage.forest$r < (red * (100 + tolerance) / 100) &
myimage.forest$g > (green * (100 - tolerance) / 100) &
myimage.forest$g < (green * (100 + tolerance) / 100) &
myimage.forest$b > (blue * (100 - tolerance) / 100) &
myimage.forest$b < (blue * (100 + tolerance) / 100)] <- 1
#what does this look like?
plot(myimage.forest$forest)
Upvotes: 3