I want to classify the elements of an image in 2 classes : vegetation and non-vegetation. I first used watershed segmentation of “segmentation” tool. I let all other parameters by default (and did’nt calculate before statistics of my image). Then I used TrainVectorClassifier and finally I would like to use VectorClassifier. My problem is that I get the same layer as the result of the segmentation step.
I think I don’t understand how does VectorClassifier work. Can someone explain to me what is the input vector data we must use, and which field names must be calculted ?
Thank you very much
TrainVectorClassifier train a supervised classifier from an input layer. each element of the input layer needs to contain :
- An integer class field : in your case it could be 0 for vegetation or 1 for non vegetation. The name of the field is set in the application with the parameter
- Training features : The list of values that should be used for training the model. It can be set with the
If I understand correctly, you are trying to perform the classification on the result of a segmentation. You have to add the fields mentioned above to your layer before calling
For the training features an option is to use for each geometry the mean of the radiometry in the geometry (for each band of the input image). This can be done with the
ZonalStatistics application (since OTB 7.0).
For the class field you could use the mean of the class, if you have a ground truth image.
If you don’t have ground truth, you can perform unsupervised learning instead. There is only one unsupervised algorithm in
TrainVectorClassifier, a kmean clustering (sharkkm option).
The VectorClassifier will not filter its input, the processed layer will contain the same geometries as the input, with an additional class field containing the integer result.
Hope that helps.
@Cedric Thank you very much for your answer. I’m currently working again using OTB. I don’t understand all of your explanations. I’m currently doing a master thesis dealing with image processing and I’d like to ask you some other questions.
Could we get in touch by another mean please ? (I sent you an invitation on Linkedin).
Thank you very much