-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_ImageClassifier.m
47 lines (30 loc) · 1.52 KB
/
demo_ImageClassifier.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%% This script will serve as a demo for the TileClassifier and
% ImageClassifier objects.
%% ImageClassifier
% How to setup an ImageClassifier object and examples of using it to
% classify an entire image and display the resulting heatmap / likelihood
% scene (for multiple classes).
ModelFilepath = 'models/model_NaiveBayes_TIS-CAN_HISTOGRAM.mat';
loaded = load(ModelFilepath);
model = loaded.model;
clear loaded;
%% TileClassifier
% How to setup a TileClassifier object and examples of using it to classify
% a single tile
% Setting up Feature Extractor
numlevels = [16 32 64];
distances = [1 2 4];
histogram_func_rgb = @(I) extract_histogram_features(I, 'NumLevels', numlevels);
histogram_labels_rgb = label_histogram_features('Channels', {'R', 'G', 'B'}, 'NumLevels', numlevels, 'Prefix', 'rgb', 'UseStrings', true);
haralick_func_rgb = @(I) extract_haralick_features(I, 'NumLevels', numlevels, 'Distances', distances);
haralick_labels_rgb = label_haralick_features('Channels', {'R', 'G', 'B'}, 'NumLevels', numlevels, 'Distances', distances, 'Prefix', 'rgb', 'UseStrings', true);
functions = { histogram_func_rgb haralick_func_rgb };
labels = [ histogram_labels_rgb haralick_labels_rgb ];
myfeatureextractor = FeatureExtractor(functions, labels);
% Setting up model
% Previously trained, saved to disk
ModelFilepath = 'tile.classifier/models/model.mat';
loaded = load(ModelFilepath);
mymodel = loaded.NB;
clear loaded;
TC = TileClassifier(mymodel, myfeatureextractor, 'Description', 'Uses histogram+haralick rgb features');