To calculate the mean vector, covariance matrix, and correlation coefficient matrix of a RGB image. I have trouble getting the mean, cannot use the mean for matlab.

조회 수: 3 (최근 30일)
img = imread('xxx.jpg')
for i = l :length (img(:,:,1))
A = sum(sum(img(:,:,2)))/ (size((img,1)*size(img,2));
  댓글 수: 1
Sargondjani
Sargondjani 2021년 9월 20일
what is the problem?
(note that 'mean' is a function in matlab, so you should change the name of the variable to something else)

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

답변 (1개)

Jan
Jan 2021년 9월 20일
What do you expect this line to do:
for i = l :length (img(:,:,1))
? The length() command replies the longer dimension of the matrix img(:, :, 1). So the loop runs either over the number of rows or columns of the matrix depending on what is longer.
The index i does not occur in your loop anywhere. So why do you use a loop at all?
You mention, that you have a problem, but not, what the problem is.
Why is using the command mean not possible?
What is the "mean vector" you want to calculate? You calculate the mean value of the green channel of an RGB image. But what is the problem?

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by