Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I convert this image in binary image such that region inside red curve is filled with white while rest with black?

1 回表示 (過去 30 日間)
Anurag Tripathi
Anurag Tripathi 2020 年 9 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
How can I convert this image in binary image such that region inside red curve is filled with white while rest with black? I have around 900 images like this so free hand drawing will be very lengthy. So is there any other way of doing it...maybe by setting some threshold?

回答 (1 件)

Adam Wyatt
Adam Wyatt 2020 年 9 月 9 日
Your question is quite vague and the methodology and results depend very much on how the images vary.
Remember that the computer will have no concept of how you decide where to draw that boundary, so you need to come up with some criterion on how to do that. If you have the image processing toolbox, that has many functions that can help you to create a mask from an image.
Assuming that using a threshold will suffice - i.e. all points within the enclosed region are above threshold and outside are below, you can create a mask in 1 line:
mask = (ImgArray>threshold_value);
However, you are likely going to be required to pre-process the data. The most likely is to perform smoothing using e.g. imfilter or filter2 You may then also need to refine the mask - for example by only taking connected points (image processing toolbox will be your friend). A little trick you can use is to smooth the mask and then threshold that - this can help get rid of any holes and create a little extra padding.
If you don't have the toolbox, it is still possible to find the continous region, but it will be slow (I do have a function to do that).

Community Treasure Hunt

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

Start Hunting!

Translated by