need the better algorithm kindly suggest.need to find good analysis
1 view (last 30 days)
Show older comments
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 Comment
Luca Ferro
on 23 May 2023
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
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!