How can I get the difference between two region triangle wise?
이전 댓글 표시
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
Rik
2020년 4월 29일
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
2020년 4월 29일
Rik
2020년 4월 29일
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
2020년 4월 30일
Rik
2020년 4월 30일
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
2020년 4월 30일
편집: joynob ahmed
2020년 4월 30일
Rik
2020년 4월 30일
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
2020년 4월 30일
편집: Image Analyst
2020년 4월 30일
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
2020년 5월 1일
편집: joynob ahmed
2020년 5월 1일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!









