Error in code: while trying to plot average histogram
Afficher commentaires plus anciens
I have a folder in that folder I have some images and I want to plot a average histogram of that images. My code is given below:
myFolder = 'folder path';
filePattern = fullfile(myFolder, '*.jpg') ;
theFiles = dir(filePattern);
S=0;
for k = 1 : length(theFiles)
% Get the input filename.
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
% Read in the image
I = imread(fullFileName);
raw = im2double(I(:,:,1));
maxv=max(max(raw));
minv=min(min(raw));
theImage= (raw-minv)./(maxv-minv);
[N,edges]=histcounts(theImage,nbins); %nbins= 512
for i=1:length(N)
S(i,:)=S(i,:)+N; % the accumlator
S(i,:)=S(i,:)/length(theFiles);
S1=S(i,:);
end
end
in=linspace(0,1,512);
plot(in,S1,'linewidth',2);
But I am getting a error :
"Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-512.
S(i,:)=S(i,:)+N; % the accumlator "
How to solve this error can anyone help? what modification do I need to make in the code to get rid of this error?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
