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-
addpath('D:\SMM\SLIPI\Images');
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;
else
sumImage = sumImage + thisImage;
end
end
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
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