Similarity check between two binary images

Az · Feb 21, 2022 · 1.9K views
Question
I want to apply a check if the two binary images are similar. I subtract a binary image 1 from the other to get a difference image. where Confidence = (sum(Image_1(:)) - Overlapping_Area)*100 /sum(Image_1 (:)) ;   It would not be reliable if the matching images have lot of shapes and rest borders lines in difference image. Any idea?
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Nov 20, 2025
Try the Dice Similarity Coefficient
 
 
% Find out where either mask is true.
unionMask = mask1 | mask2;
% Find the differences. Not used - just for fun/visualization.
%xorMask = xor(flippedMask, mask);
% Find the common/overlap area.
andMask = mask1 & mask2;
% Compute the Dice Coefficient
dice = nnz(andMask) / nnz(unionMask);

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!