Replies: 2 comments
-
I dont know exact answer for your question, but maybe this will help you. Your masks are True/False arrays, so you can check how many True values you have in your masks, so it will be area of detections. And then you can calculate ratio of hole to eardrum. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Check the examples here
https://github.com/healthonrails/annolid/blob/main/docs/tutorials/Annolid_post_processinng_masks_ious_and_areas.ipynb
for how to calculate mask areas. Hope it helps.
…On Thu, Dec 22, 2022 at 2:32 PM obinwosu ***@***.***> wrote:
Hi,
I know this has been discussed in here in slightly different terms. Those
discussions were quite some time ago but I need help for a research project
i’m working on.
I’m a surgeon and cv/ml is very new to me. I’m working on developing a
model for identifying holes in the ear drum and the entire ear drum itself.
I have done this; it’s not perfect but it’s ok for now.
[image: image]
<https://user-images.githubusercontent.com/117573177/209210544-9ea2c51f-ca3d-4ef8-a340-89ff16bd5c05.png>
[image: image]
<https://user-images.githubusercontent.com/117573177/209210291-aa7a52f0-9a06-4fcd-83fa-f248201f3c98.png>
After identifying the hole, *I want to create a second function which
will calculate the area of the hole as a proportion of the area of the
entire eardrum (area_hole)/(area_hole)+(area_drum).*
I understand that detectron2 provides outputs according to model output.
pred_mask, a tensor, is the output which represents the instance
segmentation. I believe this is the output that will enable computations of
area.
I do not know whether pred_mask (a tensor) needs to be converted to a
numpy array, or a polygon, or a contour prior to calculating area.
from detectron2.utils.visualizer import ColorMode
dataset_dicts = DatasetCatalog.get("drumai_test")
for d in dataset_dicts:
im = cv2.imread(d["file_name"])
outputs = predictor(im)
masks=outputs['instances'].pred_masks
print(outputs)
for mask in masks:
mask.sum()
print(mask.sum())
v = Visualizer(im[:, :, ::-1],
metadata=drumai_metadata,
scale=0.8,
#instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels
)
v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
plt.figure(figsize = (14, 10))
plt.imshow(cv2.cvtColor(v.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
plt.show()
In the above example, I have utilized mask.sum() to try and estimate the
predicted mask area. However, as you can see, perforations are not
irregular shapes (not HxW) so I'm not sure if mask.sum() works.
In summary, for each image in the test dataset, I want to
1. segment the hole in eardrum and the entire eardrum
2. determine the area of the pred_mask of the hole
3. determine the area of the pred_mask of the entire eardrum
4. Calculate (area_hole) / ((area_hole)+(area_drum)).
Thanks for thoughts and help. Please let me know if something is unclear.
I know calculating areas is outside the scope of detectron2 so if this is
better addressed elsewhere, please contact me via email:
***@***.***
Any help is greatly appreciated.
—
Reply to this email directly, view it on GitHub
<#4719>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIG74PETGNWJJDU3AVJTTTWOSUELANCNFSM6AAAAAATHBUEX4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I know this has been discussed in here in slightly different terms. Those discussions were quite some time ago and the solutions do not seem to directly apply.
I’m a surgeon and cv/ml is very new to me. I’m working on developing a model which identifies holes in the ear drum and then calculates what proportion of the eardrum the hole constitutes. I have done the identification portion with image segmentation via detectron2; it’s not perfect but it’s ok for now.
After identifying the hole, I want to create a second function which will calculate the area of the hole as a proportion of the area of the entire eardrum (area_hole)/(area_hole)+(area_drum).
I understand that detectron2 provides outputs according to model output. pred_mask, a tensor, is the output which represents the instance segmentation. I believe this is the output that will enable computations of area.
I do not know whether pred_mask (a tensor) needs to be converted to a numpy array, or a polygon, or a contour prior to calculating area.
In the above example, I have utilized mask.sum() to try and estimate the predicted mask area. However, as you can see, perforations are not irregular shapes (not HxW) so I'm not sure if mask.sum() works.
In summary, for each image in the test dataset, I want to
Thanks for thoughts and help. Please let me know if something is unclear.
I know calculating areas is outside the scope of detectron2 so if this is better addressed elsewhere, please contact me via email: obinwosueras@gmail.com.
Any help is greatly appreciated.
@ppwwyyxx
Beta Was this translation helpful? Give feedback.
All reactions