How to plot the ROC curve
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello. I used this code for plotting the ROC curve:
% Ground truth
GT = imread('reference.tif');
GT = GT == 1; % convert to binary image
P = nnz(GT); % number of positive responses in ground truth
N = nnz(1-GT);
% responses
R = imread('data.tif');
% your thresholds
thresholds = [0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8];
% alternatively, use 100 thresholds between min(R) and max(R)
% thresholds = linspace(min(R(:)), max(R(:)));
% pre-allocate for speed
tp = nan(1, length(thresholds));
fp = nan(1, length(thresholds));
for i = 1:numel(thresholds)
t = thresholds(end-i+1); % thresholds from high to low as i increases
Rt = R > t; % thresholded response
tp(i) = nnz(Rt & GT);
fp(i) = nnz(Rt & ~GT);
end
% convert to rates
TPR = tp/P;
FPR = fp/N;
plot(FPR, TPR) % ROC
For the attached matlab.zip data it works, but for Results.zip it gave me an empty plot area.
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Detection dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!