Is it possible to make a bar graph depiction of SSIM values? How?

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Image Analyst
Image Analyst il 16 Nov 2022
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')

Più risposte (1)

DGM
DGM il 16 Nov 2022
You should be able to use bar(). If you have a vector of SSIM values, you can just plot them.
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 Commenti
Neo
Neo il 16 Nov 2022
Modificato: Image Analyst il 16 Nov 2022
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;
ref = imread("ssim_RHIT.tif");
A = imread("ssim_NONE.tif");
montage({ref,A})
title("RHIT Image (Left) vs. NONE (Right)")
[ssimval,ssimmap] = ssim(A,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))
Where would I include a loop?
DGM
DGM il 16 Nov 2022
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?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by