2017-09-29 3 views
1

Ich habe ein Projekt, das sich mit Krankheitserkennung beschäftigt. Wir müssen C# verwenden. Wie soll ich feststellen, ob der Baum infiziert ist oder nicht? Ich benutze Accord. Abbildung meines Korrelationswertes sind zu hoch. Hier ist ein Beispielbild rechte Seite: infiziert; linke Seite: gesund/nicht infiziertImage Texture Recognition C#

Antwort

0

Da Sie erwähnt haben, dass Sie Accord.NET verwenden, glaube ich, dass Sie vielleicht einen Blick auf the examples for Bag-of-Visual-Words werfen möchten. Da Sie die Texturerkennung erwähnt haben, sollten Sie vielleicht das BoVW-Beispiel in Betracht ziehen, das den Haralick-Funktionsdeskriptor zum Extrahieren von Strukturmerkmalen aus Bildern verwendet. Dieses Beispiel wird im Folgenden wiedergegeben:

// Ensure results are reproducible 
Accord.Math.Random.Generator.Seed = 0; 

// The Bag-of-Visual-Words model converts images of arbitrary 
// size into fixed-length feature vectors. In this example, we 
// will be setting the codebook size to 3. This means all feature 
// vectors that will be generated will have the same length of 3. 

// By default, the BoW object will use the sparse SURF as the 
// feature extractor and K-means as the clustering algorithm. 
// In this example, we will use the Haralick feature extractor. 

// Create a new Bag-of-Visual-Words (BoW) model using Haralick features 
var bow = BagOfVisualWords.Create(new Haralick() 
{ 
    CellSize = 256, // divide images in cells of 256x256 pixels 
    Mode = HaralickMode.AverageWithRange, 
}, new KMeans(3)); 

// Generate some training images. Haralick is best for classifying 
// textures, so we will be generating examples of wood and clouds: 
var woodenGenerator = new WoodTexture(); 
var cloudsGenerator = new CloudsTexture(); 

Bitmap[] images = new[] 
{ 
    woodenGenerator.Generate(512, 512).ToBitmap(), 
    woodenGenerator.Generate(512, 512).ToBitmap(), 
    woodenGenerator.Generate(512, 512).ToBitmap(), 

    cloudsGenerator.Generate(512, 512).ToBitmap(), 
    cloudsGenerator.Generate(512, 512).ToBitmap(), 
    cloudsGenerator.Generate(512, 512).ToBitmap() 
}; 

// Compute the model 
bow.Learn(images); 

bow.ParallelOptions.MaxDegreeOfParallelism = 1; 

// After this point, we will be able to translate 
// images into double[] feature vectors using 
double[][] features = bow.Transform(images); 

Um dieses Beispiel, um Ihr Problem zu bewerben, anstatt die images Variable Schaffung der wood und cloud Textur Generatoren verwenden, können Sie sie von Ihrer eigenen Datenbank von Bildern abrufen. Später, nachdem Sie eine Feature-Darstellung für jedes der Bilder in ihrem Datensatz extrahiert haben, können Sie diese Darstellungen verwenden jedes maschinelles Lernen Klassifikator zu lernen, wie eine Support Vector Machine, Code wie:

// Now, the features can be used to train any classification 
// algorithm as if they were the images themselves. For example, 
// let's assume the first three images belong to a class and 
// the second three to another class. We can train an SVM using 

int[] labels = { -1, -1, -1, +1, +1, +1 }; 

// Create the SMO algorithm to learn a Linear kernel SVM 
var teacher = new SequentialMinimalOptimization<Linear>() 
{ 
    Complexity = 100 // make a hard margin SVM 
}; 

// Obtain a learned machine 
var svm = teacher.Learn(features, labels); 

// Use the machine to classify the features 
bool[] output = svm.Decide(features); 

// Compute the error between the expected and predicted labels 
double error = new ZeroOneLoss(labels).Loss(output); // should be 0 

PS : Es ist möglicherweise möglich, eine bessere Leistung in Ihrem Klassifikationsproblem zu erzielen, wenn Sie die Erstellung von SVMs mit ChiSquare kernel anstelle von Linear in Erwägung ziehen.