MATLAB Answers

Error while averaging multiple images

조회 수: 1(최근 30일)
FVC Aaqsw
FVC Aaqsw 2021년 8월 9일
댓글: FVC Aaqsw 2021년 8월 9일
I am averaging a set of tif images and here is a code for the same-
files = dir('D:\SMM\SLIPI\Images\*.tif');
numberOfImages = size(files);
for k = 1:numberOfImages
thisImage = double(imread(files(k).name)); % Or whatever...
[rows, columns, numberOfColorBands] = size(thisImage);
% First do a check for matching rows, columns, and number of color channels. Then
if k == 1
sumImage = thisImage;
sumImage = sumImage + thisImage;
sumImage = sumImage./ numberOfImages;
But I am getting following error-
>> low_energy_sequ
Matrix dimensions must agree.
Error in low_energy_sequ (line 14)
sumImage = sumImage./ numberOfImages;
Can somebody please help with this?
Thanks in advance..

채택된 답변

Rik 2021년 8월 9일
The size function returns a vector of at least two elements
numberOfImages = size(files);
%replace this by:
numberOfImages = numel(files);
  댓글 수: 1
FVC Aaqsw
FVC Aaqsw 2021년 8월 9일
Worked. Thanks very much

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by