如何计算True /表格,调用和精度?

时间:2019-01-16 10:39:48

标签: matlab image-processing precision-recall

我想创建一个程序,该程序读取3个不同的视频文件,从每个视频中提取2帧,我执行了阈值和直方图交点。 现在,我想创建一个表,其中包含扩展框架的True / False值并计算,调用,精确度和F1。

如何计算每个路口的真阳性,假阳性和假阴性?

如何将结果存储在表上?

要为每个路口计算精度,我们需要  精度=真阳性/真阳性+假阳性

计算每个路口的召回次数

Recall =真阳性//真阳性/ +假阴性

为每个路口计算F1 F1 = 2 * [((P * R)/ P + R]

有人可以告诉我如何找到真/假值以及如何将我的结果存储在表上。

谢谢。

function [output]= calculate_TruthTable(filename, 
    fimename01,fimename02)
    % the First Video

    filename='C:\Users\User\Videos\videos\TestSet\01_DevilsAdvocate_01.mp4'; 

    % From the first video we extract frame 40
    % Convert the frame to greyscale
    % Perform threshold
    % Compute histogrma
    % Normalize histogram
    vObj= VideoReader(filename);
    vFrame01 = read(vObj, 40);
    vFrame01grey = rgb2gray(vFrame01);
    binaryImage = vFrame01grey < 40;
    hist01=imhist(binaryImage);
    hist01=hist01 ./max(abs(hist01));

    % From the same video extract frame 135
    % Convert the frame to grayscale
    % Perform threshold
    % Compute Histogram
    % Normalize histogram
    vFrame02 = read(vObj, 135);
    vFrame02grey = rgb2gray(vFrame02);
    binaryImage02 = vFrame02grey < 40;
    hist02=imhist(binaryImage02);
    hist02=hist02 ./max(abs(hist02));

    % Find Histogram Intersection for the forst video
    histIntersect= sum(max(hist01-hist02));
    Intersect = find(histIntersect);

    %-------------------------------------------------------------------- 
    ------------------------------------------------------%
    % the Second Video

    fimename01= 
    'C:\Users\User\Videos\videos\TestSet\01_PulpFiction_01.mp4'; 


    % From the second videoextract frame 40
    % Convert the frame to greyscale
    % Perform threshold
    % Compute histogrma
    % Normalize histogram
    vObj= VideoReader(filename);
    vFrame03 = read(vObj, 40);
    vFrame03grey = rgb2gray(vFrame03);
    binaryImage03 = vFrame03grey < 40;
    hist03=imhist(binaryImage03);
    hist03=hist03 ./max(abs(hist03));

    % From the same video extract frame 135
    % Convert the frame to grayscale
    % Perform threshold
    % Compute Histogram
    % Normalize histogram
    vFrame04 = read(vObj, 135);
    vFrame04grey = rgb2gray(vFrame04);
    binaryImage04 = vFrame04grey < 40;
    hist04=imhist(binaryImage04);
    hist04=hist04 ./max(abs(hist04));

    % Compute histogram intersection
    mysec_histIntersect= sum(max(hist03-hist04));
    myInter02 = sort(mysec_histIntersect); 

    %------------------------------------------------------------------- 
    --------------------------------------------------------%
    % the Third Video

    fimename02= 
   'C:\Users\User\Videos\videos\TestSet\02_HowSheMove_01.mp4'; 

    % From the third video extract frame 40
    % Convert the frame to greyscale
    % Perform threshold
    % Compute histogrma
    % Normalize histogram
    vObj= VideoReader(filename);
    vFrame05 = read(vObj, 40);
    vFrame05grey = rgb2gray(vFrame05);
    binaryImage05 = vFrame05grey < 40;
    hist05=imhist(binaryImage05);
    hist05=hist05 ./max(abs(hist05));

    % From the same video extract frame 135
    % Convert the frame to grayscale
    % Perform threshold
    % Compute Histogram
    % Normalize histogram
    vFrame06 = read(vObj, 60);
    vFrame06grey = rgb2gray(vFrame06);
    binaryImage06 = vFrame06grey < 40;
    hist06=imhist(binaryImage06);
    hist06=hist06 ./max(abs(hist06));

    % Compute histogram intersection
    mythird_histIntersect= sum(max(hist05-hist06));

    MovieName = {'DevilsAdvocate';'PulpFiction';'HowSheMov'};

    MovieGenre= {'Thriller';'Thriller';'Dance'};

    True= {''; '';'';'';'' };
    False= {''; '';'';'';'' };
    Recall= {''; '';'';'';'' };
    Precision={'';'';'';'';''};
    F1={'';'';'';'';''};

    TruthTable = 
     table(MovieName,MovieGenre,True,False,Recall,Precision,F1);

    output= sortrows(TruthTable);

0 个答案:

没有答案