Question about finding mean in a matrix

2 ビュー (過去 30 日間)
Edward Baker
Edward Baker 2022 年 11 月 14 日
コメント済み: DGM 2022 年 11 月 14 日
I am currently trying to figure out how to take a mean of an NxMxKxW matrix. I would like the resulting matrix to be a matrix of means of size NxMxK. The idea is, I have a collection of images and I would like to take the average of each pixel in each color channel and come up with a new color channel that contains those averages.
I tried doing something like this...
average = mean(image_collection,4);
Although I don't think this is quite right.
I included an image to show the idea I am trying to do.
  2 件のコメント
Matt J
Matt J 2022 年 11 月 14 日
Although I don't think this is quite right.
It is.
Edward Baker
Edward Baker 2022 年 11 月 14 日
Alrighty then, I guess that solves it. I just wasn't sure if I was interpreting the documentation correctly. Thank you!

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2022 年 11 月 14 日
Is this a video? If so do you want to average the different color channels together, or have one average image for each separate color channel?
See attached demo to see how to compute the average movie frame. The result is a color image where each color channel is the mean of all corresponding color channels in the video.
  8 件のコメント
Image Analyst
Image Analyst 2022 年 11 月 14 日
Another way, that I always use to show floating point images is to use [] in imshow():
imshow(framemean, []) % now it will work
If you do that you don't need to call cast and the variable remains of type double.
DGM
DGM 2022 年 11 月 14 日
The displayrange parameter (i.e. []) controls the map scaling, so it only applies if the image is 2D.
Either way, one needs to maintain awareness of the class, range, and depth of the images they're working with and handle them accordingly.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by