Hi all,
I have a code that detects objects from an image using bwconncomp, this function detects more then 4000 objects in my original image.
I realized that i need to rotate the image in order for the object detection algorithm to work better.
When I use imrotate before the function bwconncomp it recognizes 380 objects (much less then the original):
-> differences marked in red
What do I need to add in order that i will be able to detect the same number of objects in both images (the original and the rotated)?.
I also realized that when im using the imrotate the size of the image is changing so im using it with crop:
tif_file=imrotate(tif_file,-4,'crop');
And then the size does not change, and when I use imshow the image looks the same.
Any help will be highly appreciated!!

댓글 수: 2

Image Analyst
Image Analyst 2022년 7월 31일
Not sure I understand. Why do you believe that it needs to be rotated to segment it better but then when you do that you say it segments it worse. Why do you believe your premise when you've shown it not to be true?
stav marzuk
stav marzuk 2022년 7월 31일
Hi, thanks for responding :)
Im doing the rotation for an algorithem that counts the objects and their index in each line. in my case its trees and for each tree I want to assign his row and the number in the row. The algorithem works only when the image is in the correct angle, more about it here.
Thank you.

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2022년 7월 31일
편집: Matt J 2022년 7월 31일

0 개 추천

The reason, I suspect, that the number of objects seems to decrease when you imrotate is that you have several objects that are very close together in the original image - less than 2 pixels apart. When you imrotate, the interpolation operations done by the rotation introduce new non-zero pixels that bridge the pixel-wide gaps between objects, thereby fusing what were separate objects together..
You need to assess whether these narrowly separated objects are truly supposed to be separate. If there is a minimum distance that is supposed to exist between distinct objects, then you can use imclose to seal false gaps in the original image. bwpropfilt or bwareafilt might help also to get rid of objects in the original image that are just a few pixels in size.

댓글 수: 3

stav marzuk
stav marzuk 2022년 8월 1일
Thanks for responding :)
in my case I know that there are a lot of objects, seen in the original image when i activite the function bwconncomp:
.
I tried to use imclose - in order to create the gap between the objects that connected, but unfortunatly it didnt help.
I tried diffrent value of se, and i didnt see any changes when i used imshow for the mask.
I tried to use bwconncomp after imclose, but the number of objects didnt change.
I can see a diffrence between the 3 situations but when I use bwconncomp function the results are the same (like u can see in the image i added).
Appriciate the help!
Matt J
Matt J 2022년 8월 1일
편집: Matt J 2022년 8월 1일
I can't see what you did, but SE isn't supposed to be a scalar.
stav marzuk
stav marzuk 2022년 8월 1일
Oops, my bad!
Thanks it was very helpful!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

릴리스

R2021a

질문:

2022년 7월 31일

댓글:

2022년 8월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by