Is it possible to make a bar graph depiction of SSIM values? How?
1 次查看(过去 30 天)
显示 更早的评论
I have ran my code for SSIM and I now want to depict the results in a bar graph format. How would I do that please?
0 个评论
采纳的回答
Image Analyst
2022-11-16
Try this:
% Demo by Image Analyst
% Initialization Steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
% Specify the folder where the files live.
myFolder = pwd; % 'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
uiwait(warndlg(errorMessage));
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
return;
end
end
% Read in reference image.
ref = imread("ssim_RHIT.tif");
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.tif'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Read in image array with imread().
thisImage = imread(fullFileName);
imshow(thisImage); % Display image.
drawnow; % Force display to update immediately.
% If sizes don't match, skip it.
if ~isequal(size(ref), size(thisImage))
message = sprintf('Size of %s does not match that of the reference image.', baseFileName);
uiwait(warndlg(message));
continue; % Skip to bottom of loop.
end
% Now do whatever you want with this file name, such as calling ssim()
montage({ref,thisImage})
title("RHIT Image (Left) vs. NONE (Right)")
[ssimval(k), ssimmap] = ssim(thisImage, ref); %returns the local SSIM value for each pixel or voxel in A.
imshow(ssimmap,[])
title("Local SSIM Map with Global SSIM Value: "+num2str(ssimval))
end
% Show bar chart of SSIM values.
figure
bar(ssimval);
grid on;
title('SSIM Values')
xlabel('Image #')
ylabel('SSIM value')
0 个评论
更多回答(1 个)
DGM
2022-11-16
ssimvec = [0.964 0.97 0.839 0.901 0.955 0.875 0.911 0.872 0.977 0.878];
hb = bar(ssimvec);
ylabel('SSIM')
xlabel('image number')
4 个评论
DGM
2022-11-16
What exactly are you trying to plot in the bar chart?
Are you trying to plot the global SSIM for multiple images?
Are you trying to plot the local SSIM map for one image?
If the latter, how exactly would you represent a 2D map in a bar chart? Maybe a 3D bar chart? A surf plot?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!