need the better algorithm kindly suggest.need to find good analysis

8 次查看(过去 30 天)
clc;
clear;
close all;
% Parameters
N = 512; % Image size (N x N)
bits = 8; % Number of bits for photon counting
max_photon = 2^bits - 1; % Maximum photon count
% Load the input image
input_img = imread('cameraman.tif'); % Replace with your own image path
input_img = im2gray(input_img); % Convert to grayscale if necessary
input_img = imresize(input_img, [N, N]); % Resize to N x N
input_img = im2double(input_img); % Convert to double
% Generate random phase masks
phase_mask1 = exp(1i * rand(N, N) * 2 * pi); % Random phase mask 1
phase_mask2 = exp(1i * rand(N, N) * 2 * pi); % Random phase mask 2
% Encode the input image using DRPE
encoded_img = ifftshift(ifft2(fftshift(input_img))) .* phase_mask1 .* phase_mask2;
% Perform photon counting in the nonlinear domain
photon_counted_img = max_photon * abs(encoded_img).^2;
% Reconstruction
reconstructed_img = sqrt(photon_counted_img) .* exp(1i * angle(encoded_img));
reconstructed_img = fftshift(fft2(ifftshift(reconstructed_img)));
% Convert reconstructed image to the same class as the input image
if isa(input_img, 'integer') && isa(reconstructed_img, 'double')
reconstructed_img = cast(reconstructed_img, class(input_img));
end
% Calculate MSE using images of the same class
mse = immse(input_img, abs(reconstructed_img));
% Evaluation metrics
psnr = psnr(input_img, abs(reconstructed_img), 1); % Peak Signal-to-Noise Ratio
corr_coeff = corr2(input_img, abs(reconstructed_img)); % Correlation coefficient
% Photon Counting Efficiency (PCE)
pce = sum(photon_counted_img(:)) / (N * N * max_photon);
% Display results
figure;
subplot(2, 2, 1);
imshow(input_img);
title('Original Image');
subplot(2, 2, 2);
imshow(abs(encoded_img), []);
title('Encoded Image');
subplot(2, 2, 3);
imshow(abs(reconstructed_img), []);
title('Reconstructed Image');
subplot(2, 2, 4);
imhist(uint8(photon_counted_img));
title('Histogram');
fprintf('Mean Squared Error (MSE): %.4f\n', mse);
fprintf('Peak Signal-to-Noise Ratio (PSNR): %.2f dB\n', psnr);
fprintf('Correlation Coefficient: %.4f\n', corr_coeff);
fprintf('Photon Counting Efficiency (PCE): %.4f\n', pce);
output-
PSNR-(-18.04)-----not acceptable
MSE-63.66-------not acceptable
Corelational Coffiecient-(-0.248)-----not acceptable
photon counting---0
  1 个评论
Luca Ferro
Luca Ferro 2023-5-23
We need more informations, what is the goal? why is it not acceptable? ...? We cannot make this stuff up just by looking at random code

请先登录,再进行评论。

回答(1 个)

Drishti
Drishti about 8 hours 前
编辑:Drishti about 8 hours 前
Hi Anshika,
While reproducing the provided code on my end, I understand that you're attempting to compute the Peak Signal-to-Noise Ratio (PSNR) and Mean Squared Error (MSE) to assess the quality of a reconstructed image with the original one.
The negative PSNR, MSE, and correlation coefficient values as mentioned in your query, suggests that the reconstructed image does not align well with the original image. This can be due to incorrect scaling or incorrect domain transformations.
To resolve this issue, one possible work around is to normalize the reconstructed image before calculating the PSNR and MSE values. For better understanding, you can refer to the code snippet provided below:
% Normalize reconstructed image
reconstructed_img = abs(reconstructed_img);
% Normalize to [0, 1]
reconstructed_img = reconstructed_img / max(reconstructed_img(:));
For more information, you can refer to the MATLAB Documentation of 'abs' function:
I hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by