PCQI code doesn't showing any output neither any error

조회 수: 3 (최근 30일)
rakib mostafiz
rakib mostafiz 2021년 8월 1일
답변: lone hameem 2025년 1월 16일
I need to take output from a "PCQI: A Patch-Structure Representation Method for Quality Assessment of Contrast Changed Images" code. But whenever i run this, it doesnt show anything at all. Not even an error. How can i solve this?
Demo.m
clc;
clear;
im1=imread('ref.png');
im2=imread('contrast_changed.png');
im1=double(rgb2gray(im1));
im2=double(rgb2gray(im2));
[mpcqi, pcqi_map] = PCQI(im1, im2);
PCQI.m (default value for window = fspecial('gaussian', 11, 1.5); L = 256)
function [mpcqi, pcqi_map]= PCQI(img1, img2, window, L)
if (nargin < 2 || nargin > 4)
mpcqi = -Inf;
pcqi_map = -Inf;
return;
end
if (size(img1) ~= size(img2))
mpcqi = -Inf;
pcqi_map = -Inf;
return;
end
[M N] = size(img1);
if (nargin == 2)
if ((M < 11) || (N < 11))
mpcqi = -Inf;
pcqi_map = -Inf;
return
end
window = fspecial('gaussian', 11, 1.5);
L = 256;
end
if (nargin == 3)
[H W] = size(window);
if ((H*W) < 4 || (H > M) || (W > N))
mpcqi = -Inf;
pcqi_map = -Inf;
return
end
L = 255;
end
if (nargin == 4)
[H W] = size(window);
if ((H*W) < 4 || (H > M) || (W > N))
mpcqi = -Inf;
pcqi_map = -Inf;
return
end
end
window = window/sum(sum(window));
mu1 = filter2(window, img1, 'valid');
mu2 = filter2(window, img2, 'valid');
mu1_sq = mu1.*mu1;
mu2_sq = mu2.*mu2;
mu1_mu2 = mu1.*mu2;
sigma1_sq = filter2(window, img1.*img1, 'valid') - mu1_sq;
sigma2_sq = filter2(window, img2.*img2, 'valid') - mu2_sq;
sigma12 = filter2(window, img1.*img2, 'valid') - mu1_mu2;
sigma1_sq = max(0, sigma1_sq);
sigma2_sq = max(0, sigma2_sq);
C=3;
pcqi_map = (4/pi) *atan((sigma12 + C )./(sigma1_sq + C ));
pcqi_map = pcqi_map .*((sigma12 + C) ./(sqrt(sigma1_sq).*sqrt(sigma2_sq) + C));
pcqi_map = pcqi_map .*exp(-abs(mu1-mu2)/L);
mpcqi = mean2(pcqi_map);
return

답변 (1개)

lone hameem
lone hameem 2025년 1월 16일
im1=imread('ref.png');
im2=imread('contrast_changed.png');
im1=double(rgb2gray(im1));
im2=double(rgb2gray(im2));
[mpcqi, pcqi_map] = PCQI(im1, im2);
dear friend code is correct just add one line after this code, then it will show u value in command window
mpcqi

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by