Error in code: while trying to plot average histogram
이전 댓글 표시
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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
