Image averaging code needed
古いコメントを表示
I am trying to find the average of 2000 .bmp files(all greyscale). Kindly assist me in figuring out the right code. I have used the following code but it returned a pitch dark image and am unable to figure out the issue:
clear all
im = imread('V_cont_1.bmp');
for i = 200:2000
im = imadd(im,imread(sprintf('V_cont_%d.bmp',i)));
end
im = im/2000;
imshow(im,[]);
%imwrite(im,'V_cont_avg.bmp');
Thank you.
回答 (1 件)
Adam
2016 年 9 月 14 日
0 投票
From the help page for imadd (doc imadd):
'If X and Y are integer arrays, elements in the output that exceed the range of the integer type are truncated, and fractional values are rounded.'
You can't just keep adding together uint8 values (assuming they are unit8, but if not any integer) as they will just max out. You need to convert to single or double if you want to do that.
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!