I like to arrange the pixels intensity based on the sequence in the matrix

1 回表示 (過去 30 日間)
fathi
fathi 2017 年 3 月 22 日
コメント済み: fathi 2017 年 4 月 6 日
Good evening.
I'd like to arrange the pixels intensity based on the sequence in the matrix EX:
Y = [ 5 4 4 2 ;
6 3 3 1 ;
2 4 2 2;
5 5 6 1]
The answer is supposed to be like :
YY = [5 5 5 4 ;
4 4 2 2 ;
2 2 6 6 ;
3 3 1 1]
Thanks
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 22 日
What is the rule about the order to be used?
Image Analyst
Image Analyst 2017 年 3 月 22 日
Looks like something that might involve histcounts() and repelem()? But I can't make out the rule either. If it was most frequen first, then it should start out with 2, not 5 since there are four 2's but only three 5's.

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

採用された回答

Guillaume
Guillaume 2017 年 3 月 22 日
This is probably the logic:
Y = [ 5 4 4 2 ;
6 3 3 1 ;
2 4 2 2;
5 5 6 1]
[values, ~, loc] = unique(Y.', 'stable');
YY = reshape(values(sort(loc)), fliplr(size(Y))).'

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by