how to convert a 2D matrix to a column vector?

7 ビュー (過去 30 日間)
jimy george
jimy george 2014 年 1 月 1 日
コメント済み: Tulio 2014 年 1 月 2 日
I have to compare two images of same/different alphabets using euclidean distance method. The function 'euclidean' requires the column vectors corresponding to both the images. How could I obtain the column vectors?

回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 1 日
編集済み: Azzi Abdelmalek 2014 年 1 月 1 日
out=A(:) % A is your image

Image Analyst
Image Analyst 2014 年 1 月 1 日
You need to build up a feature vector from each image. Surely you're not just comparing two images with different alphabets on them - for that you could just subtract them, but that's no good to tell if they are from the same alphabet or not. Sounds like you're going to need to do OCR on the images first, and then compare feature vectors.

Tulio
Tulio 2014 年 1 月 1 日
編集済み: Tulio 2014 年 1 月 1 日
For example a 7x7 matrix;
Ncols=7; Nrows=7; c=0; ColVec=zeros(Ncols*Nrows,1);
for i=1:Nrows for j=1:Ncols
c=c+1;
ColVec(c,1)=x(Nrows*(j-1)+i);
end
end
  2 件のコメント
Image Analyst
Image Analyst 2014 年 1 月 1 日
編集済み: Image Analyst 2014 年 1 月 1 日
Or, much, much more simply in one single line of code
ColVec = x(:);
as Azzi said. Though it won't be what jimy wants. It's not going to help him to turn his images of alphabets into a single column, despite the fact that he asked for that. He just doesn't realize it yet.
Tulio
Tulio 2014 年 1 月 2 日
Oh yes, it is much simpler indeed. it wasn't quite clear to me what he asked so I just tried to go by the title.

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by