フィルターのクリア

How to crop the coin circular and neglect the rest area?

3 ビュー (過去 30 日間)
shubham kumar gupta
shubham kumar gupta 2023 年 4 月 4 日
コメント済み: Image Analyst 2023 年 4 月 5 日
I have a coin image and I want to crop the circular section of the coin, I tried below code but this doesn't worked well.
I want to crop out the coin with the outer boundary with a perfect circle. Any help would be appreciated. Thank you
Code which I tried:
%B1 is in coin.mat coin image
B2 = B1/max(B1(:));
k=B1*200;
k(k>-6000) = 1;
k(k<-6000) = 0;
bw2 = imfill(k,'holes');
figure,imshow(bw2)
bw3 = imopen(bw2, ones(3,3));
figure,imshow(bw3)
bw3 = imopen(bw2, ones(5,5));

採用された回答

Image Analyst
Image Analyst 2023 年 4 月 5 日
That's what I do in my popular tutorial.
It's a generic, general purpose demo of how to threshold an image to find blobs (coins), and then measure things about the blobs, and extract certain blobs based on their areas or diameters.

その他の回答 (1 件)

Cris LaPierre
Cris LaPierre 2023 年 4 月 4 日
I would use the Image Segmenter app. After loading the image, you can define a circuilar ROI, apply a mask, and export the result back to MATLAB.
Just be aware that the result is always going to be a square, as the image is stored in a matrix. There is no circle version of it. You can use the mask to adjust the background color if you want.
You can learn more in the Using the Image Segmenter App video, which is part of the Image Processing for Engineering and Science Specialization on Coursera. It is a self paced course created by MathWorks, and you can enroll for free.
  3 件のコメント
shubham kumar gupta
shubham kumar gupta 2023 年 4 月 5 日
編集済み: shubham kumar gupta 2023 年 4 月 5 日
I appreaciate the efforts!
This really helped me, but still this poses human error.
Thank you
Image Analyst
Image Analyst 2023 年 4 月 5 日
If extremely high precision is really a requirement then you'd do things to enable that. This includes
  1. Using as high a resolution camera as you can.
  2. Using a telecentric lens (instead of a regular lens).
  3. Using a uniform background of contrasting color (like black velvet).
  4. Using proper lighting.
Alternatively you can use a caliper micrometer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by