Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % JPEG error analysis and digital image forensic
- % Load the original image
- original_image = imread('original_image.jpg');
- % Apply JPEG compression with quality factor 75
- compressed_image = imresize(original_image, 0.5); % Resize the image to reduce its size
- imwrite(compressed_image, 'compressed_image.jpg', 'Quality', 75);
- % Load the compressed image
- compressed_image = imread('compressed_image.jpg');
- % Calculate the mean squared error (MSE) between the original and compressed images
- MSE = immse(original_image, compressed_image);
- % Display the MSE value
- fprintf('MSE: %f\n', MSE);
- % If the MSE value is higher than a threshold, the image may have been tampered with
- if MSE > 100
- fprintf('The image may have been tampered with.\n');
- else
- fprintf('The image is probably authentic.\n');
- end
- % Apply a digital forensic technique to detect traces of JPEG compression
- DCT = dct2(compressed_image); % Calculate the 2D discrete cosine transform (DCT)
- abs_DCT = abs(DCT); % Take the absolute value of the DCT coefficients
- mean_DCT = mean(abs_DCT(:)); % Calculate the mean of the absolute DCT coefficients
- % Display the mean value
- fprintf('Mean DCT value: %f\n', mean_DCT);
- % If the mean DCT value is higher than a threshold, the image may have been compressed with JPEG
- if mean_DCT > 10
- fprintf('The image was probably compressed with JPEG.\n');
- else
- fprintf('The image was probably not compressed with JPEG.\n');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement