How to find the x and y coordinates of points inside a binary image M?
9 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone! I need a help with a code. On one hand, I have a binary image M (logical); on the other hand, I have vrx (2x658) and vry (2x658) where the first row of vrx is the x coordinate of the initial point of a line, the second row of vrx is the x coordinate of the final point of a line. The same reasoning is valid for vry but it is the y_coordinate.
Starting from the initial points of a line (so the elements vrx(1,:) and vry(1,:)), the code has to check, in correspondence of every single point of coordinates vrx and vry, if the binary image M in that specific point has value 1 or 0. If the value of M is 1, then I have to remove that point from the total vector. If the value of M is 0, that point can stay in the total vector. The same procedure must be done for the final points of a line (so the elements vrx(2,:) and vry(2,:); at the end I have to plot the new vectors vrx and vry obtained, after this check.
My problem is that I don't know how to make this correspondence between the vrx and vry coordinates of the current point I am analyzing and the value that the binary Image M assumes at that specific point.
4 件のコメント
回答 (1 件)
Image Analyst
2022 年 6 月 9 日
Write all the endpoints to a binary image. Then use imreconstruct. I bet you can figure it out, but if you can't, write back for help.
2 件のコメント
Image Analyst
2022 年 6 月 10 日
- I did not say that. I said "Write all the endpoints".
- You can do binaryImage(round(y2(k)), round(x2(k))) = true; Iterate over all k and also do the x1 and y2 arrays.
- imreconstruct will tell you what regions/blobs in the mask image also contain any pixels from the marker image. So if your mask image is your M array, and your marker image is the one you created in #2 above, you'll know which blobs the xy points are in and then you can erase those from M.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!