originalImage = imread("cameraman.tif");
modifiedImage = imadd(originalImage, 20);
set(gcf, 'Position', [100, 100, 400, 200]);
subplot(1, 2, 1); imshow(originalImage); title('Original Image');
subplot(1, 2, 2); imshow(modifiedImage); title('Modified Image');
[ssimValue, ssimMap] = ssim(originalImage, modifiedImage);
fprintf("SSIM: %f\n", ssimValue);
title(['SSIM Map (SSIM Value: ', num2str(ssimValue), ')']);
set(gcf, 'Position', [100, 100, 400, 200]);
if ssimValue > ssimThreshold
disp('The images are similar based on SSIM.');
The images are similar based on SSIM.
disp('The images are different based on SSIM.');
surfPointsOriginal = detectSURFFeatures(originalImage);
surfPointsModified = detectSURFFeatures(modifiedImage);
subplot(1, 2, 1); imshow(originalImage); hold on; plot(surfPointsOriginal.selectStrongest(50));
title('SURF Features - Original Image');
subplot(1, 2, 2); imshow(modifiedImage); hold on; plot(surfPointsModified.selectStrongest(50));
set(gcf, 'Position', [100, 100, 500, 200]);
[surfFeaturesOriginal, validSurfPointsOriginal] = extractFeatures(originalImage, surfPointsOriginal);
[surfFeaturesModified, validSurfPointsModified] = extractFeatures(modifiedImage, surfPointsModified);
surfIndexPairs = matchFeatures(surfFeaturesOriginal, surfFeaturesModified);
matchedSurfPointsOriginal = validSurfPointsOriginal(surfIndexPairs(:, 1));
matchedSurfPointsModified = validSurfPointsModified(surfIndexPairs(:, 2));
showMatchedFeatures(originalImage, modifiedImage, matchedSurfPointsOriginal, matchedSurfPointsModified, 'montage');
title('Matched SURF Features');
set(gcf, 'Position', [100, 100, 500, 200]);
[hogFeaturesOriginal, ~] = extractHOGFeatures(originalImage);
[hogFeaturesModified, ~] = extractHOGFeatures(modifiedImage);
hogSimilarity = 1 - pdist2(hogFeaturesOriginal, hogFeaturesModified, 'cosine');
fprintf('HOG Similarity: %f\n', hogSimilarity);
if hogSimilarity > hogThreshold
disp('The images are similar based on HOG features.');
The images are similar based on HOG features.
disp('The images are different based on HOG features.');