how to get image average

26 ビュー (過去 30 日間)
mohammadali
mohammadali 2013 年 3 月 5 日
hello to all
i have an 4-D dimension Array that contain some RGB picture and i want to set an image that each pixel of it is average of other corresponding pixel in all picture.i wrote below code but doesn't work correctly.
if any one know the correct solution please help me
best regards
if true
clc;
obj=mmreader('street.avi');
Frames = obj.NumberOfFrames;
vidHeight = obj.Height;
vidWidth = obj.Width;
a=read(obj);
im = a(:,:,:,8);
sum = uint16(0);
imframe =(zeros(vidHeight,vidWidth,3));
imframe1=uint16(zeros(vidHeight,vidWidth,3,Frames));
imframe2=uint16(zeros(vidHeight,vidWidth,3));
for p = 1:250
imframe1(:,:,:,p)=(im2uint16(a(:,:,:,p))); %sum = sum + uint16(a(m,n,k,p));
end
for p = 1:250
imframe2=imadd(imframe1(:,:,:,p),imframe2);
end

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 5 日
Replace nearly all your code with
mean(a,4)
You might need
mean(double(a),4)

その他の回答 (1 件)

mohammadali
mohammadali 2013 年 3 月 5 日
編集済み: mohammadali 2013 年 3 月 5 日
thank you for response if it possible explain it briefly good luck

Community Treasure Hunt

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

Start Hunting!

Translated by