Why my code calculates values for image statistics, which are far greater or less than the standard ones? Both for encrypted and decrypted images.
이전 댓글 표시
clc, clear all, close all
% Read image in different formats (JPG, PNG, TIFF)
%imageFormats = {'jpg', 'png', 'tif'};
imageFormats = {'jpg'};
for i = 1:numel(imageFormats)
format = imageFormats{i};
imageFileName = sprintf('image.%s', format);
image = imread(imageFileName);
% Convert image to grayscale if it has multiple channels
if size(image, 3) > 1
image = rgb2gray(image);
end
% Compute image statistics
entropyValue = entropy(image);
contrastValue = std2(image);
correlationValue = corr2(image, image);
energyValue = sum(sum(image.^2)) / numel(image);
homogeneityValue = sum(sum(1 ./ (1 + (image - image).^2))) / numel(image);
meanAbsDeviationValue = mad(double(image(:)));
% Display the results
fprintf('Image Format: %s\n', format);
fprintf('Entropy: %.4f\n', entropyValue);
fprintf('Contrast: %.4f\n', contrastValue);
fprintf('Correlation: %.4f\n', correlationValue);
fprintf('Energy: %.4f\n', energyValue);
fprintf('Homogeneity: %.4f\n', homogeneityValue);
fprintf('Mean of Absolute Deviation: %.4f\n', meanAbsDeviationValue);
fprintf('------------------------------\n');
% Display the image
figure;
imshow(image);
title(sprintf('Image Format: %s', format));
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
