I want to understand the basic idea of TP, TN, FP and FN, with respect to following points:
(1) Actually, I am performing tamper detection in image watermarking. At first, some watermark bits are embedded inside the original image to produce the watermarked image. Then, watermarked image is tampered to produce the tampered image.
(2) Now, the watermark bits are extracted from both the watermarked image and the tempred image.
(3) Then, these bits are converted into two binary images and assgined to 2 variables, such as (1) reference and (2) toTest.
(4) Then I am following the below given code to find the TP, TN, FP and FN. The problem is, for any amount of tampering the results for FP and FN comes as 0 only. AM I missing any logic or trick, plz clarify me.
function [TP,FP,TN,FN] = compareBinaryImages( reference, toTest ) % reference = ground truth binary image
% toTest = binary image to be compared to the reference image
if(ndims(reference)~=2 && ndims(toTest)~=2) error('Inputs must be two 2-dimensional matrices'); end TP = nnz(reference==1 & toTest==1); % True positive
FP = nnz(reference==0 & toTest==1); % False positive
TN = nnz(reference==0 & toTest==0); % True negative
FN = nnz(reference==1 & toTest==0); % False negative
end
Best Answer