![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/614475/image.jpeg)
How to detecct specific circle and set values inside to 0
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey everyone,
I have a set of ultra-sound images. Each image have a circle which can be in different positions (this circle is actually the transducer which take those images).
I would like to remove non-zero pixels inside those circles (set the whole circle area to 0). I've tried to use imfindcircles but the radius range of the circles is dynamic.
How can I find those circles and set the whole area inside them to 0?
here are some examples to the images.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/614165/image.bmp)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/614170/image.bmp)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/614320/image.bmp)
댓글 수: 0
채택된 답변
DGM
2021년 5월 11일
편집: DGM
2021년 5월 11일
There are probably other ways to do this, but this is what I rolled:
inpict = rgb2gray(imread('us2.bmp'));
% generate a mask
bb = inpict>5; % some threshold
bb = despeckle(bb,100); % remove small spots/holes
bb = bwpropfilt(~bb,'solidity',1); % find most solid circle
% apply the mask
inpict(bb) = 0;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/614475/image.jpeg)
If you need the mask to trim off some of the very inner content, you can dilate it after the bwpropfilt() call. This example uses despeckle() from MIMT, but you can do the same with bwareaopen()
bb = ~bwareaopen(~bwareaopen(bb,100),100);
댓글 수: 3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!