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!