⛄一、简介
理论知识参考文献:图像印刷质量的客观评价——以报纸印刷为例
⛄二、部分源代码
function varargout = IQA(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @IQA_OpeningFcn, …
‘gui_OutputFcn’, @IQA_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% — Executes just before IQA is made visible.
function IQA_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
ResetButton_Callback(hObject, eventdata, handles)
% — Outputs from this function are returned to the command line.
function varargout = IQA_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% — Executes on button press in BrowseImage.
function BrowseImage_Callback(hObject, eventdata, handles)
ResetButton_Callback(hObject, eventdata, handles);
global image;
[filename pathname] = uigetfile({‘.jpg’;'.bmp’;‘.tif’;'.png’},‘File Selector’);
x = strcat(pathname, filename);
image=imread(x);
axes(handles.axes1);
imshow(image);
% — Executes on button press in AddNoise.
function AddNoise_Callback(hObject, eventdata, handles)
global image;
global addnoisyimage;
global mean;
global variance;
global AdditiveNoiseMenu;
if (strcmp(AdditiveNoiseMenu, ‘Gaussian’))
addnoisyimage = imnoise(image, ‘Gaussian’, mean, variance);
elseif (strcmp(AdditiveNoiseMenu, ‘Poisson’))
addnoisyimage = imnoise(image, ‘Poisson’);
elseif (strcmp(AdditiveNoiseMenu, ‘Select Additive Noise Type’))
addnoisyimage = image;
end
axes(handles.axes2);
imshow(addnoisyimage);
% — Executes on button press in MultiNoise.
function MultiNoise_Callback(hObject, eventdata, handles)
global noisedensity;
global variance_multi;
global image;
global multinoisyimage;
global MultiplicativeNoiseMenu;
if (strcmp(MultiplicativeNoiseMenu, ‘Salt & Pepper’))
multinoisyimage = imnoise(image, ‘salt & pepper’, noisedensity);
elseif (strcmp(MultiplicativeNoiseMenu, ‘Speckle’))
multinoisyimage = imnoise(image, ‘speckle’, variance_multi);
elseif (strcmp(MultiplicativeNoiseMenu, ‘Select Multiplicative Noise’))
multinoisyimage = image;
end
axes(handles.axes3);
imshow(multinoisyimage);
% — Executes on button press in CheckPSNR.
function CheckPSNR_Callback(hObject, eventdata, handles)
global addnoisyimage;
global multinoisyimage;
global image;
global s;
global u;
global justforcontrol;
if (get(hObject, ‘Value’) == get(hObject,‘Max’))
justforcontrol=1;
s=psnr(addnoisyimage, image);
u=psnr(multinoisyimage, image);
else
justforcontrol=0;
s=‘–’;
u=‘–’;
end
% Hint: get(hObject,‘Value’) returns toggle state of CheckPSNR
function s = psnr(addnoisyimage, image)
if(ndims(addnoisyimage)==3)
addnoisyimage = rgb2gray(addnoisyimage);
end
if(ndims(image)==3)
image = rgb2gray(image);
end
addnoisyimage=double(addnoisyimage);
image=double(image);
[m,n] = size(addnoisyimage);
peak=255255m*n;
noise = addnoisyimage - image;
nostotal = sum(sum(noise.*noise));
if nostotal == 0
s = ‘INF’; %% INF. clean image
else
s = 10 * log10(peak./nostotal);
end
% — Executes on button press in CheckSSIM.
function CheckSSIM_Callback(hObject, eventdata, handles)
global addnoisyimage;
global multinoisyimage;
global image;
global t;
global v;
global justforcontrol2;
K = [0.05 0.05];
window = ones(8);
L = 100;
Z = [0.01 0.03];
if (get(hObject, ‘Value’) == get(hObject,‘Max’))
justforcontrol2=1;
t=ssim(addnoisyimage, image, Z, window, L);
v=ssim(multinoisyimage, image, Z, window, L);
else
justforcontrol2=0;
t=‘–’;
v=‘–’;
end
% Hint: get(hObject,‘Value’) returns toggle state of CheckSSIM
function [mssim] = ssim(img1, img2, Z, window, L)
if(ndims(img1)==3)
img1=rgb2gray(img1);
end
if(ndims(img2)==3)
img2=rgb2gray(img2);
end
[rows,cols]=size(img2);
img1=imresize(img1,[rows cols]);
if (nargin < 2 || nargin > 5)
mssim = -Inf;
ssim_map = -Inf;
return;
end
if (size(img1) ~= size(img2))
mssim = -Inf;
ssim_map = -Inf;
return;
end
[M N] = size(img1);
if (nargin == 2)
if ((M < 11) || (N < 11))
mssim = -Inf;
ssim_map = -Inf;
return
end
window = fspecial(‘gaussian’, 11, 1.5); %
Z(1) = 0.01; % default settings
Z(2) = 0.03;
L = 255;
end
if (nargin == 3)
if ((M < 11) || (N < 11))
mssim = -Inf;
ssim_map = -Inf;
return
end
window = fspecial(‘gaussian’, 11, 1.5);
L = 255;
if (length(Z) == 2)
if (Z(1) < 0 || Z(2) < 0)
mssim = -Inf;
ssim_map = -Inf;
return;
end
else
mssim = -Inf;
ssim_map = -Inf;
return;
end
end
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1]张小利,李雄飞,李军.融合图像质量评价指标的相关性分析及性能评估[J].自动化学报. 2014,40(02)
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除