How can I load and plot the difference of a set of images to a reference image?
Hello,
my task is to create a graph showing how a set a of images change in relation to the reference image. For defining the difference I am using the Structural Similarity (SSIM) index. Now my problem is that my loop does not go through all image in the folder directory but only takes the first one. In order to make the graph I need to assign to each image the value of the SSIM index (ssimval) and plot it.
It would be very helpful if someone could show me what I am doing wrong in my code. Thank you!
Here is my code so far:
reference_img = imread('rock01b_noback.png'); %read reference img
folder = 'C:\Users\...';
morphimages = dir(fullfile(folder,'*.png')); %specify pattern of files in folderfor i = 1:length(morphimages)
imagename = morphimages(i).name;
fullimagename = fullfile(folder,imagename);
fprintf(1, 'Reading %s.\n', fullimagename);
imagearray = imread(fullimagename);
[ssimval,ssimmap] = ssim(imagearray,reference_img) %find ssim index for each img in folder
end
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Try this:
% Demo by Image Analyst.
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
folder = 'C:\Users\lea\documents\Matlab\work\Images'; % Change to wherever your images are.
baseFileName = 'rock01b_noback.png';
fullFileName = fullfile(folder, baseFileName);
reference_img = imread(fullFileName); % read reference img
subplot(2, 2, 1);
imshow(reference_img);
title(baseFileName);
morphimages = dir(fullfile(folder,'*.PNG')); %specify pattern of files in folder
numImages = length(morphimages)
ssimval = zeros(1, numImages);
for k = 1 : length(morphimages)
baseImageName = morphimages(k).name;
fullImageName = fullfile(folder,baseImageName);
fprintf(1, 'Reading %d of %d : %s.\n', k, numImages, fullImageName);
subplot(2, 2, 2);
imageArray = imread(fullImageName);
SEE COMPLETE ANSWER CLICK THE LINK