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

조회 수: 2(최근 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?

채택된 답변

Image Analyst
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);
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
% 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);
continue; % Skip to bottom of loop.
% Now do whatever you want with this file name, such as calling ssim()
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.
title("Local SSIM Map with Global SSIM Value: "+num2str(ssimval))
% Show bar chart of SSIM values.
grid on;
title('SSIM Values')
xlabel('Image #')
ylabel('SSIM value')

추가 답변(1개)

DGM 2022년 11월 16일
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);
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!

Translated by