How can I display the maximum 10 elements in an array?

8 ビュー (過去 30 日間)
onamaewa
onamaewa 2019 年 3 月 11 日
コメント済み: Star Strider 2019 年 3 月 11 日
The pixels in yellow are of the highest intensity, I would like to display 10 pixels of the highest intensity.
I've plotted the 41x41 array (shown below) using:
image(Rx, (Ry-40), pict, 'CDataMapping', 'scaled')
I wanted to display a set of maximum values at a predefined range in 0's and 1's and did so using:
rangedValues = pict >= 17.0;
image(Rx, (Ry-40), rangedValues, 'CDataMapping', 'scaled')
How can I append this script to display a predetermined number of maximum values instead of a range? (i.e. the 10 highest, 100 highest, etc.)

回答 (1 件)

Star Strider
Star Strider 2019 年 3 月 11 日
If you have R2017b or later, the maxk (link) funciton is an option. I’m not certain how compatible it is with with image data, since you didn’t specify what your image characteristics are.
  2 件のコメント
onamaewa
onamaewa 2019 年 3 月 11 日
What image characteristics would you like to know? In the 2nd image posted in my question, there is 1 pixel illuminated showing the maximum, but I'm wanting to show 10 pixels or whatever number necessary. I tried using maxk and ended up with this:
te3.jpg
Star Strider
Star Strider 2019 年 3 月 11 日
Images can have two or three dimensions, (R,G,B channels for example), or other formatting idiosyncracies, depending on the image format. If you are using the image (or imagesc) function to view a 2D matrix, it would be different than your original data being a 3D format.
That’s the reason I asked.
If you have a 2D matrix, the maxk function could do what you want. Note that the second output is a linear index into your matrix, so if you want row-column (or row-column-page) subscripts, you would need to use the ind2sub function to convert them.
Experiment to get the result you want.

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by