필터 지우기
필터 지우기

After PCA, the reconstructed image is darker than the original.

조회 수: 4 (최근 30일)
예림
예림 2024년 5월 20일
댓글: Image Analyst 2024년 5월 21일
original iris image
pca iris image
After PCA of the iris image, I reconstructed the image and it became dark. And when I analyzed the original image and PCA image with SSIM, the result was 0.09333. Other than that, I tried MSE and PSNR, and all the results showed low structural similarity between images. What part of the code should I modify to solve this problem?
clc; clear;
% Importing an iris image
i_image = '홍채 이미지 예시2.jpg';
i = imread(i_image);
figure(1);
imshow(i);
title('Original Image');
% Image RGB Channel Extraction
red = double(i(:, :, 1));
green = double(i(:, :, 2));
blue = double(i(:, :, 3));
% Specifying the number of principal components
num_components = 200;
% Red Channel PCA
[coeff_r, score_r, ~] = pca(red);
reduced_score_r = score_r(:, 1:num_components);
reconstructed_R = reduced_score_r * coeff_r(:, 1:num_components)';
% Green Channel PCA
[coeff_g, score_g, ~] = pca(green);
reduced_score_g = score_g(:, 1:num_components);
reconstructed_G = reduced_score_g * coeff_g(:, 1:num_components)';
% Blue Channel PCA
[coeff_b, score_b, ~] = pca(blue);
reduced_score_b = score_b(:, 1:num_components);
reconstructed_B = reduced_score_b * coeff_b(:, 1:num_components)';
% Reconfiguring the image
reconstructed_red = reshape(reconstructed_R, size(red));
reconstructed_green = reshape(reconstructed_G, size(green));
reconstructed_blue = reshape(reconstructed_B, size(blue));
reconstructed_image = cat(3, uint8(reconstructed_red), uint8(reconstructed_green), uint8(reconstructed_blue));
% Show Reconfigured Images
figure(4);
imshow(uint8(reconstructed_image));
title('PCA Image');
% SSIM
ssimval=ssim(i, reconstructed_image);
% MSE
err=immse(i, reconstructed_image);
% PSNR
peaksnr=psnr(i, reconstructed_image);

답변 (1개)

Angelo Yeo
Angelo Yeo 2024년 5월 20일
The reconstructed image is darker because you did not compensate the mean which is substracted when calculating covariance matrix. See pca for more information.
clc; clear;
% Importing an iris image
i_image = '홍채 이미지 예시2.jpg';
i = imread(i_image);
figure(1);
imshow(i);
title('Original Image');
% Image RGB Channel Extraction
red = double(i(:, :, 1));
green = double(i(:, :, 2));
blue = double(i(:, :, 3));
% Specifying the number of principal components
num_components = 200;
% Red Channel PCA
[coeff_r, score_r, ~,~,~,mu_red] = pca(red);
reduced_score_r = score_r(:, 1:num_components);
reconstructed_R = reduced_score_r * coeff_r(:, 1:num_components)';
% Green Channel PCA
[coeff_g, score_g, ~,~,~,mu_green] = pca(green);
reduced_score_g = score_g(:, 1:num_components);
reconstructed_G = reduced_score_g * coeff_g(:, 1:num_components)';
% Blue Channel PCA
[coeff_b, score_b, ~,~,~,mu_blue] = pca(blue);
reduced_score_b = score_b(:, 1:num_components);
reconstructed_B = reduced_score_b * coeff_b(:, 1:num_components)';
% Reconfiguring the image
reconstructed_red = reshape(reconstructed_R, size(red)) + mu_red;
reconstructed_green = reshape(reconstructed_G, size(green)) + mu_green;
reconstructed_blue = reshape(reconstructed_B, size(blue)) + mu_blue;
reconstructed_image = cat(3, uint8(reconstructed_red), uint8(reconstructed_green), uint8(reconstructed_blue));
% Show Reconfigured Images
figure(4);
imshow(uint8(reconstructed_image));
title('PCA Image');
% SSIM
ssimval=ssim(i, reconstructed_image);
% MSE
err=immse(i, reconstructed_image);
% PSNR
peaksnr=psnr(i, reconstructed_image);
  댓글 수: 3
Angelo Yeo
Angelo Yeo 2024년 5월 20일
You can accept the answer if the query is resolved, @예림 :D
Image Analyst
Image Analyst 2024년 5월 21일
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by