Borrar filtros
Borrar filtros

I am embedding text file but am getting very low ssim value using dct but am getting good PSNR Value How?

2 visualizaciones (últimos 30 días)
clear
clc
% Read the DICOM image from the specified file path
dicomImage = dicomread('ID_0000_AGE_0060_CONTRAST_1_CT.dcm');
Error using images.internal.dicom.getFileDetails
Unable to load file "ID_0000_AGE_0060_CONTRAST_1_CT.dcm".

Error in dicomread>newDicomread (line 119)
fileDetails = images.internal.dicom.getFileDetails(filename, verifyIsDICOM);

Error in dicomread (line 13)
[X, map, alpha, overlays] = newDicomread(msgname, frames, useVRHeuristic);
% Encode a secret message
fid = fopen('PatientInformation.txt', 'r');
text = fread(fid, inf)';
secretMessage = text;
binarySecretMessage = uint8(secretMessage);
% Check if the file size is greater than 10% of the DICOM image size DO CHANGE HERE 200,500….ETC INSTEAD OF 0.1 IF YOU WANT TO INSERT LARGER TEXT FILE
if numel(binarySecretMessage) > 0.1 * numel(dicomImage)
error('File size is too large to embed in the DICOM image.');
end
% Perform the 2D DCT on the DICOM image
tic;
dct_coeffs = dct2(dicomImage);
time_dct = toc;
% Embed the binary message into DCT coefficients
messageLength = length(binarySecretMessage);
coeff_idx = 1:messageLength;
dct_coeffs(coeff_idx) = double(binarySecretMessage);
% Perform inverse DCT to obtain the modified DICOM image with hidden text
tic;
modifiedImage = idct2(dct_coeffs);
time_idct = toc;
% Save the modified DICOM image as "stego.dcm"
dicomwrite(modifiedImage, 'stego.dcm');
% Extract the hidden text from the stego DICOM image
tic;
extractedMessage = dct_coeffs(coeff_idx);
time_extract = toc;
% Convert the extracted binary data back to text
extractedMessage = char(extractedMessage);
% Display the extracted message
disp('Extracted Message:');
disp(extractedMessage);
% Save the extracted message to a text file
extractedTextFilePath = 'ExtractedMessage.txt';
fid = fopen(extractedTextFilePath, 'w');
fprintf(fid, '%s', extractedMessage);
fclose(fid);
% Display the embedding time and extracting time in seconds
fprintf('Embedding Time: %.6f seconds\n', time_dct);
fprintf('Extraction Time: %.6f seconds\n', time_extract);
% Calculate the PSNR
Psnr_value = snr(modifiedImage, im2double(dicomImage));
Ssim_value = ssim(modifiedImage, im2double(dicomImage));
% Display the PSNR and SSIM values
fprintf('PSNR: %.2f dB\n', Psnr_value);
fprintf('SSIM: %.8f\n', Ssim_value);
disp(['Extracted text saved to: ' extractedTextFilePath]);

Respuestas (1)

Ayush
Ayush el 13 de Dic. de 2023
I understand that you are getting low SSIM (Structural Similarity Index) and good PSNR (Peak Signal-to-Noise Ratio) when embedding text file using DCT (Discrete Cosine Transform). The low SSIM value and good PSNR value could be due to the nature of these metrics:
  1. The DCT is a frequency transform that represents the image in terms of its frequency components. When embedding a text file using DCT, the frequency components of the image are altered, leading to a decrease in structural similarity between the original and modified images. This results in a lower SSIM value.
  2. Peak Signal-to-Noise Ratio measures the quality of the image by comparing the original and modified images in terms of their pixel values. The overall image quality in terms of pixel fidelity remains good.
Thank you

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by