Hi All
I have multiple images and I want to remove the inner part the image but don't know how I can remove this.by using mask or any other approach ? Can anybody help me with this
these are some image . and I want a unique approach that work for all the images,some of the images are attached
1st one in input and second one is like output

回答 (3 件)

Oindri
Oindri 2018 年 7 月 4 日

0 投票

Hi, You may try, first detecting the edge of the inner circle because its abrupt change in intensity, which will be easily detectable. Once you have defined that boundary, replace all internal pixels with black pixels. Given the varied nature of boundary, apply automatic detection of boundary.

1 件のコメント

Alina tom
Alina tom 2018 年 7 月 4 日
can you please help me with some code

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

KSSV
KSSV 2018 年 7 月 4 日
編集済み: KSSV 2018 年 7 月 4 日

0 投票

files = dir('*JPG') ;
nx = 512 ; ny = 512 ;
N = length(files) ;
I = cell(N,1) ;
for i = 1:N
I{i} = imread(files(i).name);
I{i} = imresize(I{i},[nx ny]) ;
end
C = round([nx ny]/2) ; % center of the image
R = 60. ; % radius of circle
th = linspace(0,2*pi,500) ;
xc = C(1)+R*cos(th) ;
yc = C(1)+R*sin(th) ;
%
I2 = cell(N,1) ;
x = 1:ny ; y = 1:nx ;
[X,Y] = meshgrid(x,y) ;
idx = inpolygon(X(:),Y(:),xc,yc) ;
for i = 1:N
T = I{i}(:,:,1) ;
T(idx) = 10 ;
I2{i} = repmat(T,1,1,3) ;
imshow(I2{i})
end

3 件のコメント

Alina tom
Alina tom 2018 年 7 月 4 日
編集済み: Alina tom 2018 年 7 月 4 日
This is not working for my case, you are making a circle and replace it with original image , which destroy the shape of original image. it should be like this
KSSV
KSSV 2018 年 7 月 4 日
YOu play with the radius of circle.......R can be fixed to 35..check
Alina tom
Alina tom 2018 年 7 月 4 日
the output is wrong by changing radius . I have tried this approach but not working for my case

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

Image Analyst
Image Analyst 2018 年 7 月 4 日

0 投票

The attached algorithm seem to work with both your images. The function findcircles() didn't seem to work, so I thresholded followed by repeated erosions until the background and inner zone separated into two regions, then took the inner region and expanded it back out and used it as a mask to erase the inner zone of the gray scale image. You can adjust stepSize to erase a little closer to the inner boundary if you want.
Results for the first image:
And for the other image:

6 件のコメント

Alina tom
Alina tom 2018 年 7 月 5 日
Sir Thanks for you reply
it looks good but when the inner part is near the edge , it not working fine . I also want to remove this part , any suggestion how I can remove this part as shown in below figure
again thanks for your reply
Alina tom
Alina tom 2018 年 7 月 5 日
can we identify the both inner objects and replace them with zeros ? one is the circular object and second has a bright reflection and dark shadow behind this reflection . can we use this such information extract these objects from image ?
Alina tom
Alina tom 2018 年 7 月 5 日
can we use bwpropfilt() to identify this bright point ? or any other filtering technique ?
Image Analyst
Image Analyst 2018 年 7 月 5 日
Nothing is circular. They're all irregularly shaped. The bright blob is connected to the outer blob. What gave rise to it? Is it a specular reflection that you might be able to get rid of with crossed polarizers? If you want, you could call beconvhull to get the convex hull of the mask.
Alina tom
Alina tom 2018 年 7 月 5 日
yes they are irregular shapes , the bright blob changing its position randomly that's why its difficult to remove . I have used convex hull but results are same.
Image Analyst
Image Analyst 2018 年 7 月 6 日
You can use imfreehand() to lasoo the occasional photo that it didn't work for. See my attached demo. Otherwise it will take you quite a bit of work to make it more automatic. It will be tricky and could take a bit of time to develop the algorithm. You could consider hiring someone if you can't do it yourself. Or else contact the Mathworks and they'll do it for you.

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

質問済み:

2018 年 7 月 4 日

コメント済み:

2018 年 7 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by