How can I get the difference between two region triangle wise?
Afficher commentaires plus anciens
I have found the boundary of the blob and the bounding box.Then I have added the centroid to the vertices of the box.Now I am trying to get the differences between the boundary and the box for each triangle.How can I do that?
I have added my code with the output:

9 commentaires
Rik
le 29 Avr 2020
So you want to find the fraction of black within each yellow triangle? You will have to attach the image as well, otherwise we can't reproduce your results in the first place.
joynob ahmed
le 29 Avr 2020
Rik
le 29 Avr 2020
Is that second image really the original image? It doesn't really look like it. And if you just want the distance to the edge, why not use bwdist?
But the first step is to find all border pixels. So you have some cleaning to do before you can easily use native Matlab functions.
joynob ahmed
le 30 Avr 2020
Rik
le 30 Avr 2020
You should provide the binary image, not a screenshot of the binary image, nor the original color image. The color image is fine if you also provide the code to convert it to the binary image.
What I meant by cleaning up is exactly what you have done in the image you posted in your question: make sure you only have a single binary object, without any holes in it.
Once you have the binary image, you can crop it to the bounding box. Then you can use bwdist to find the distance to the nearest line of your bounding box. That means you also need to include the diagonals for this part.
But I'll show what I mean in an answer when you have posted appropriate input data. You can also attach a mat file if that is easier for you.
joynob ahmed
le 30 Avr 2020
Modifié(e) : joynob ahmed
le 30 Avr 2020
Rik
le 30 Avr 2020
When I run your code I don't get your image. Which release are you using? And how do these white borders around the black appear?
Image Analyst
le 30 Avr 2020
Modifié(e) : Image Analyst
le 30 Avr 2020
I think you did give a screenshot. Just click and drag the above image in your browser and you'll see there is a white frame around it for some reason. Is that in your program? If so use imclearborder. Also fill holes.
mask = imclearborder(mask);
mask = imfill(mask, 'holes');
Each point on your yellow bounding box will have a distance to every point on your blob boundary. Do you want the closest? So that for each point on the bounding box, find the distance to the nearest boundary point of the blob? So now you'll have a distance for every point on the boundary. So then do you want the average of all the closest distances in the triangle? So you'll have one average distance for each side of the bounding box?
joynob ahmed
le 1 Mai 2020
Modifié(e) : joynob ahmed
le 1 Mai 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Region and Image Properties dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









