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