I am a beginner with geospatial analysis and Google Earth Engine. I am trying to classify only one class of Landsat 5 image (swimming pool). I got several training sites and applied the classifier. As a result my classified image appeared totally red (so the classification did not give me the expected results). Is that because I should classify several classes and not just one? And how to ask to classify my defined class by my training sites and create another class that gather all the pixels that does not belong to the class previously defined? Below the code I used:
var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7']
var image= ee.Image('LANDSAT/LT05/C01/T1_TOA/LT05_015036_20111025')
.select(bands)
// Train is the feature collection containing my training sites (points)
var training = image.sampleRegions({
collection: train,
properties: ['class'],
scale: 30
});
var trained = ee.Classifier.cart().train(training, 'class', bands);
// Classify the image with the same bands used for training.
var classified = image.select(bands).classify(trained);