How to find the x and y coordinates of points inside a binary image M?

8 vues (au cours des 30 derniers jours)
Loren99
Loren99 le 9 Juin 2022
Modifié(e) : Loren99 le 15 Juin 2022
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 commentaires
Loren99
Loren99 le 9 Juin 2022
Modifié(e) : Loren99 le 10 Juin 2022
@Matt J yes, I was thinking about the fact that for example vrx and vry coordinates like (149.5 ; 158,5) could be rounded to the pixel coordinates (149;158)
Loren99
Loren99 le 9 Juin 2022
Modifié(e) : Loren99 le 9 Juin 2022
@Image Analyst I have to check first all the initial points x1,y1 ; then all the final points x2,y2

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 9 Juin 2022
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 commentaires
Loren99
Loren99 le 9 Juin 2022
@Image Analyst sorry but I don't understand how this answer is linked to my question. Then:
1) Why I have to consider only the endpoints (x2,y2) and not also (x1,y1)?
2) How can i write the endpoints to a binary image?
3) Why I have to use imreconstruct?
Image Analyst
Image Analyst le 10 Juin 2022
  1. I did not say that. I said "Write all the endpoints".
  2. You can do binaryImage(round(y2(k)), round(x2(k))) = true; Iterate over all k and also do the x1 and y2 arrays.
  3. 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by