# Taking average of pixel values across multiple frames

조회 수: 31 (최근 30일)
Kevin P Meyer 2021년 6월 17일
댓글: Kevin P Meyer 2021년 6월 17일
I have a 1x3 cell containing image data as a 5504 x 8256 double, each value in the matrix is a pixel grayscale intensity value. Each cell is a picture at a different time or frame. What I want to do is take the average pixel value across each frame. So say I have N number of frames or pictures, I want to average pixel at (row 1, column 1) across those N frames and so on for (row 1, column 2),(row 1, column 3).....and end up with a 5504 x 8256 matrix that has the average pixel value across the number of frames in my cell. Any ideas on how to do this? I was messing around with 3 4x3 double matrices in a 1x3 cell for ease but I was not able to find an efficient way in a for loop to do this for each pixel location.

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

### 답변 (1개)

Joseph Cheng 2021년 6월 17일
편집: Joseph Cheng 2021년 6월 17일
couldn't you just put it into a non cell matrix of 5504 x8256 x 3 then use mean(data,3) to take the mean in the 3rd dimension? or just add the cell index wise then divide by 3.
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Joseph Cheng 2021년 6월 17일
oh that can be accomplished by reshaping the concatenated matrix. see small example below
a = [1 2;3 4];
Acell = {a,a,a};
Acell2mat = cell2mat(Acell)
%looks to concatenate by column
[arow acol]=size(Acell{1})
Amatstack = reshape(Acell2mat,arow,acol,numel(Acell));
MeanA = mean(Amatstack,3)
Kevin P Meyer 2021년 6월 17일
awesome, that seems to be doing the trick, thank you so much!

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

### 카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by