How do i vectorize an image?
7 ビュー (過去 30 日間)
古いコメントを表示
I am trying to break a square matrix of an image and create another vector which contains its column vector sub-blocks. I used the following code for it and getting an error
for i=1:50 a(i)=A(:,i)
The error says 'In an assignment A(I) = B, the number of elements in B and I must be the same.'
Please help me how i can solve my problem.
9 件のコメント
Walter Roberson
2015 年 10 月 15 日
mean(Array) gives a vector of column means, you do not need to split it up. Likewise with std()
回答 (2 件)
Walter Roberson
2015 年 10 月 14 日
a = mat2cell(A, size(A,1), ones(1,size(A,2)));
Now a{K} will be the column vector corresponding to A(:,K)
2 件のコメント
Walter Roberson
2015 年 10 月 14 日
For RGB one solution would be
a = mat2cell(A, size(A,1), ones(1,size(A,2)), size(A,3));
This would create a{k} as being an N x 3 matrix, rather than creating the vectors that were asked for. Or you could use
a = mat2cell(A, size(A,1), ones(1,size(A,2)), ones(1,size(A,3)));
which would create a as an N x 3 cell array, each entry of which is a column vector.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!