Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

two picture pixels

조회 수: 3 (최근 30일)
Pan
Pan 2012년 5월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to calculate the corresponding pixels of the two pictures. How can I do? This is my code. clear all; load watch
[m,n,c,f]=size(xw);
fd=zeros(1,324);
a=1; for i=1:325
fd(:,:,:,a)=mean(abs((xw(:,:,:,i+1))-(xw(:,:,:,i))));
a=a+1;
end
but have a error ??? Subscripted assignment dimension mismatch.
Error in ==> detectiontest at 12 fd(:,:,:,a)=mean(abs((xw(:,:,:,i+1))-(xw(:,:,:,i))));

답변 (2개)

Geoff
Geoff 2012년 5월 23일
You are addressing fd(:,:,:,a) as a 4-dimensional array, but it is declared as a 1-dimensional array.
You need to make sure that the shape of the matrix you are assigning to on the left is the same as the shape of the matrix on the right. So you need to look at that call to mean and examine the dimensions of the result (using size). Most easily checked by doing this:
size( mean(abs(xw(:,:,:,1))) )

Image Analyst
Image Analyst 2012년 5월 23일
fd(:,:,:,a) is a 3D array, while the mean of a 3D array (which is what xw(:,:,:,i+1) is) is a 2D array. For example the mean of a 2D array returns the means of the columns so the mean is always one dimension less than what you took the mean of. So you're trying to assign a 2D array to a 3D array. You need to look up the definition of mean and figure out what you need to pass it to do whatever it is that you want to take the mean of.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by