Plot binary image with all coordinates of points

13 ビュー (過去 30 日間)
Nguyen Hung
Nguyen Hung 2017 年 10 月 12 日
コメント済み: Walter Roberson 2019 年 5 月 31 日
I have a matrix with 2 rows:
First is x-coordinate
Second is y-coordinate
How can i plot a binary image with all coordinates of points in that matrix
  3 件のコメント
Guillaume
Guillaume 2017 年 10 月 12 日
編集済み: Guillaume 2017 年 10 月 12 日
Nguyen Hung comment moved here (Please use comments, not answers):
Actually, I plot a contour from a blood sample and receive a contour matrix. So, my coordinates don't have natural spacing; I want to count cell by counting closed loop in contour image. Is there any way to do so?
Walter Roberson
Walter Roberson 2017 年 10 月 12 日
I would recommend a different approach for that.
  1. quantize the readings according to the contour levels you want.
  2. replace each array entry by the bin number of the quantized level
  3. now use regionprops to figure out all of the distinct regions. If you only need to know how many there are, then ask for any simple property, but then look at the size of the returned structure to see how many regions there were.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 12 日
If the coordinates are positive integers, then
binary_image = full( sparse( YourMatrix(1, :), YourMatrix(2, :), true ) );
  8 件のコメント
Hélène MACHER
Hélène MACHER 2019 年 5 月 31 日
編集済み: Hélène MACHER 2019 年 5 月 31 日
Hello,
Thank you very much for your answer, it's much more faster than whith for loops.
I'm working on a filtering algorithm for point clouds. I create a binary image from a point cloud and I clean this image thanks to several functions available in Matlab.
Then, I would like to go back to the point cloud in other words I would like to find the points corresponding to the white pixels. I manage to do this with for loops but it's quite long. Any idea to do it faster?
Hélène
Walter Roberson
Walter Roberson 2019 年 5 月 31 日
Along with your binary image create a 2d array in which each value is 0 if the binary is unoccupied, and is the linear index of the original in the point cloud for occupied. Do the processing on the binary image. Then multiply the result binary image by the coordinate array. The nonzero values left are the indices of the original point cloud.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by