I am trying to classify agricultural fields with randomForest model. I will conduct an object-based classification. To do so, in the code by Ned Horning, I provide the boundaries in a shapefile. The code extracts pixels from this area and calculates the measures such as mean of the included pixel values and std of those values. In this case the followings are my predictors:
- mean_Red_Band of an object (such as a field)
- mean_NDVI_Band of an object
- std_Red_Band of an object
- and etc.
My observations in this case are the polygons that I provided as shapefile, i.e. 3600 fields.
I have no problem with the code but the concept. My question is: can I include a unique GLCM measure of an object as a predictor in the model?
Here is a detailed explaination of my problem:
Suppose that I have an object image as this: https://imgur.com/a/OlfAzLR
When I calculated the GLCM measures for the object here is different GLCM images for different measures: https://imgur.com/a/GIKuONU
Specifically, a GLCM contrast image is as this: https://imgur.com/a/4i8aWUs
It calculates it with the following code in R:
glcm <- glcm(rasterobject, window = c(9,9), ## window matrix size ## shift = list(c(0,1), c(1,1), c(1,0), c(1,-1)), ## matrix direction ## statistics = c("mean", "variance", "homogeneity", "contrast", "dissimilarity", "entropy", "second_moment") ##statistics## )
What is told about using GLCM measures is that you can use it to understand texture differences in an image. In my example, you can check the glcm_contrast image and understand the texture of the object.
However, I have multiple objects. For example, my second object and its glcm measures as follows:
As you can see GLCM measures are calculated for different objects. If we wanted like to see this objects as a matrix, we would see a matrix like this: (It is the a part of the matrix of object2_glcm_contrast https://imgur.com/a/qG0QyKC):
A part of the matrix: https://imgur.com/a/2tzmt81
The GLCM measures are calculated and written to mid-pixel of the matrix by nrow=9 and ncol=9, thus there are multiple glcm values of an object.
My question is can I calculate a unique GLCM measure for an object? If I can so, I would be able to put it as a predictor variable of an observation, which is an object.
A unique GLCM measure could be this, for example:
glcm_contrast_mean <- sum(as.matrix(glcm$glcm_contrast), na.rm = TRUE)/(length(as.matrix(glcm$glcm_contrast)) - sum(is.na(as.matrix(glcm$glcm_contrast))))
And it is:
> glcm_contrast_mean  2.759012
This value is only for an object whereas, on above, there are multiple values for different parts of an object.
Could this measure (or any other) represent the object's texture?