Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions MATLAB/Demos/d10_QualityMeasurements.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,24 @@

%% Plot the changes of image quality measures over iterations

%%RMSE plot
figure
plot([qualitySIRT(1,:);[qualitySART(1,:) nan(1,length(qualityOSSART)-length(qualitySART))];qualityOSSART(1,:)]');
title('Evolution of RMSE per iteration')
legend('SIRT','SART','OS-SART')

%%CC plot
figure
plot([qualitySIRT(2,:);[qualitySART(2,:) nan(1,length(qualityOSSART)-length(qualitySART))];qualityOSSART(2,:)]');
title('Evolution of correlation coefficient (CC) per iteration')
legend('SIRT','SART','OS-SART')

%%MSSIM plot
figure
plot([qualitySIRT(3,:);[qualitySART(3,:) nan(1,length(qualityOSSART)-length(qualitySART))];qualityOSSART(3,:)]');
title('Evolution of mean structural similarity index per iteration')
legend('SIRT','SART','OS-SART')

%%UQI plot
figure
plot([qualitySIRT(4,:);[qualitySART(4,:) nan(1,length(qualityOSSART)-length(qualitySART))];qualityOSSART(4,:)]');
title('Evolution of universal quality index per iteration')
legend('SIRT','SART','OS-SART')
%%RMSE plot (and the other requested metrics)
% Each algorithm may stop at a different iteration. Plot its own history
% directly, preserving legitimate zeros and avoiding assumptions about length.
histories={qualitySIRT,qualitySART,qualityOSSART};
algorithmNames={'SIRT','SART','OS-SART'};
metricNames={'RMSE','CC','MSSIM','UQI'};
for metric=1:numel(metricNames)
figure;
hold on;
for algorithm=1:numel(histories)
values=histories{algorithm}(metric,:);
plot(1:numel(values),values,'DisplayName',algorithmNames{algorithm});
end
title(['Evolution of ' metricNames{metric} ' per iteration']);
xlabel('Iteration');
ylabel(metricNames{metric});
legend('show');
end

%% Compute the parameters for the target image
% Knowing change of the parameters per iteration can be interesting, but
Expand Down
43 changes: 43 additions & 0 deletions MATLAB/Tests/test_qualityDemoHistories.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function test_qualityDemoHistories()
% Execute only demo plotting with histories of unequal lengths in any order.
root=fileparts(fileparts(mfilename('fullpath')));
source=fileread(fullfile(root,'Demos','d10_QualityMeasurements.m'));
first=strfind(source,'%%RMSE plot');
last=strfind(source,'%% Compute the parameters for the target image');
plotting=source(first(1):last(1)-1);
previousVisibility=get(groot,'DefaultFigureVisible');
cleanup=onCleanup(@() restoreFigures(previousVisibility));
set(groot,'DefaultFigureVisible','off');
names={'SIRT','SART','OS-SART'};
metrics={'RMSE','CC','MSSIM','UQI'};
for lengths={[8 3 11],[11 8 3],[3 11 8],[0 3 1]}
close('all');
n=lengths{1};
qualitySIRT=reshape(1:4*n(1),4,n(1));
qualitySART=reshape(1:4*n(2),4,n(2))+100;
qualityOSSART=reshape(1:4*n(3),4,n(3))+200;
histories={qualitySIRT,qualitySART,qualityOSSART};
eval(plotting);
figures=findall(groot,'Type','figure');
assert(numel(figures)==4,'Expected one plot per metric');
for figureHandle=figures'
ax=findobj(figureHandle,'Type','axes');
row=find(cellfun(@(name) ~isempty(strfind(ax.Title.String,name)),metrics));
assert(isscalar(row),'Expected a unique metric title');
lines=findobj(ax,'Type','line');
assert(numel(lines)==nnz(n),'Expected one line per nonempty history');
for line=lines'
index=find(strcmp(line.DisplayName,names));
assert(isscalar(index),'Expected the correct algorithm label');
assert(isequal(line.XData,1:n(index)));
assert(isequal(line.YData,histories{index}(row,:)));
end
end
end
fprintf('PASS quality demo: unequal and empty histories retain metric rows and iteration counts\n');
end

function restoreFigures(visibility)
close('all');
set(groot,'DefaultFigureVisible',visibility);
end
Loading