|
|
Re: ROC curve of target and source images
Posted:
Feb 26, 2013 6:50 AM
|
|
"Carl S." wrote in message <kggdfd$51j$1@newscl01ah.mathworks.com>... > "Carl S." wrote in message <kgfk3g$9i5$1@newscl01ah.mathworks.com>... > > Hi, > > > > I need matlab codes to plot a roc curve of target and source images > > > > (I have searched but the files in FileExchange are not clear (not get image files as input to give the plotted curve) for my purpose) > > Hi, > I have seen the following function; > [tpr,fpr,thresholds] = roc(Targets, Outputs) > > I think this function gives the parameters to draw ROC curves, such as true positive, false negative... But, how to obtain the input parameters from png file images ?
I have performed the following process: 1) I have applied Dice similarity measurement for automatically segmented images and obtained the following similarity coefficients image1 0.8313 image2 0.9157 image3 0.9328 image4 0.7790 image5 0.8547 image6 0.7026
2) I have chosen 0.7 as the threshold value, and wrote the following codes scores = [0.8313 0.9157 0.9328 0.7790 0.8547 0.7026] labels = [1 1 1 0 1 0] % <= Here, ones corresponds to positive (acceptable coefficient, zero corresponds to negative (not acceptable) ROC(scores,labels); The ROC function gives the TP and FP values and also draw the ROC curve. But the result is not good, although there is only two image that have zero label. So, the ROC curve is not correct. I still need a help, and it is urgent please :( function [Tps, Fps] = ROC(scores, labels) %% Sort Labels and Scores by Scores sl = [scores; labels]; [d1 d2] = sort(sl(1,:)); sorted_sl = sl(:,d2); s_scores = sorted_sl(1,:); s_labels = round(sorted_sl(2,:)); %% Constants counts = histc(s_labels, unique(s_labels)); Tps = zeros(1, size(s_labels,2) + 1); Fps = zeros(1, size(s_labels,2) + 1); negCount = counts(1); posCount = counts(2); %% Shift threshold to find the ROC for thresIdx = 1:(size(s_scores,2)+1) % for each Threshold Index tpCount = 0; fpCount = 0; for i = [1:size(s_scores,2)] if (i >= thresIdx) % We think it is positive if (s_labels(i) == 1) % Right! tpCount = tpCount + 1; else % Wrong! fpCount = fpCount + 1; end end end Tps(thresIdx) = tpCount/posCount; Fps(thresIdx) = fpCount/negCount; end %% Draw the Curve % Sort [Tps;Fps] x = Tps; y = Fps; % Interplotion to draw spline line count = 100; dist = (x(1) - x(size(x,2)))/100; xx = [x(1):-dist:x(size(x,2))]; % In order to get the interpolations, we remove all the unique numbers [d1 d2] = unique(x); uni_x = x(1,d2); uni_y = y(1,d2); yy = spline(uni_x,uni_y,xx); % No value should exceed 1 yy = min(yy, 1); plot(x,y,'x',xx,yy);
|
|