Not able to get accurate true positive (TP), true negative (TN), false positive (FP) and false negative(FN) values in image watermarking

4 ビュー (過去 30 日間)
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

採用された回答

Image Analyst
Image Analyst 2020 年 3 月 23 日
Of course. It all depends on how you do your watermark extraction on the tampered image. For example if you merely subtracted the images and looked for the presence of non-zeros, then even the slightest amound of tampering would show it tampered with. For example if you merely changed the value of one pixel, your algorithm shows that as a true tamper, which it should. Of course comparing some totally different image would also show a difference and you'd say it was a tamper but it might not be. For example if you compared a picture of a beach with a photo of the Grand Canyon it would show it as being tampered with but it's probably not an alteration of your original - it's just a completely different photo. So you need to make sure that you're really comparing something that is likely to be an alteration of your original photo, like by adding noise, rotating it, cropping it, scaling it, changing brightness or colors (overall or just in regions), etc.
Since your False positives and False negatives are always both zero, then whatever you're doing to detect tamper is working fantastic, as long as you're comparing photos that should sensibly be compared. Ideally you would not want any false positives or false negatives. I'm not sure if a true positive is an indication of an original image or a tampered one, but regardless your algorithm is good enough to not make any mistakes since all your predictions are correct (true).
  7 件のコメント
Image Analyst
Image Analyst 2020 年 3 月 25 日
Well first read the wikipedia article on ROC curves. Then what you do is to basically pick a set of parameters for your algorithm, like window width, order, whatever, then run a bunch of images through your algorithm and get the true positive and false positive rates. Then plot that as one point. Now that's not a curve yet, it's just one point on a curve, so to build up the curve you need to change the parameters and run another (or the same) batch of images and note the TP and FP rates. Now you have two points in the curve. Now do it a bunch more times and get more and more points along the curve and you'll find something like the shape in the ROI image I showed you. Then you can make a decision as to what's most important to you and pick that set of parameters. It's not true that the point on the upper left of the curve is always the best set of parameters to use. For example if you were doing something where people might die if you got it wrong (cancer diagnosis) you might want a really high TP rate, even if the FP rate is so high. You'd be willing to have a few more diagnoses of cancer even though that was not true rather than risk telling someone that they don't have cancer when they really do.
Aditya Shau
Aditya Shau 2020 年 3 月 27 日
編集済み: Aditya Shau 2020 年 3 月 28 日
Dear sir, I read some articles on ROC. And understood the basic idea of ROC.
However, I have attached some sample results of my experiment. I request you to kindly hep to plot the ROC curve with these values. Once you suggest me the procedure for plotting, I will add some more experiment results on this and follow your procedure to build the plot. Actually, I have stored my results in excell sheet and facing some issues in bulding the plot in matlab. Thank you once again for your great help and support. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by