Join dots in binary image.

I want to remove that one dot and join the curve points. tried medfilt2() but not getting the desired ouput.

回答 (1 件)

Alfonso
Alfonso 2018 年 5 月 3 日

0 投票

11 件のコメント

khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
already seen !! this image is after applying those functions.
Alfonso
Alfonso 2018 年 5 月 3 日
編集済み: Alfonso 2018 年 5 月 3 日
can you attach you original image? (not the mask)
khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
i want to detect the seam and want a single line
Alfonso
Alfonso 2018 年 5 月 3 日
編集済み: Alfonso 2018 年 5 月 3 日
In order to remove the upper blob you can use this function, In the first line change to the first image you posted (binary img). Save it as a .m
function removeBlob
I=imread('binary_img.png');
I = im2bw(I);
I = bwlabel(imfill(I>0,'holes'));
% I = bwlabel(imfill(imread('sc.png')>100,'holes'));
h = imshow(label2rgb(I,jet(numel(unique(I(:)))),[0 0 0]));
set(h,'buttondownfcn',{@removeIt,I})
end
function removeIt(src,~,I)
cp = round(get(get(src,'parent'),'currentpoint'));
val = I(cp(3),cp(1));
I(I==val) = 0;
set(src,'cdata',bsxfun(@times,uint8(logical(I)),get(src,'cdata')));
figure
imshow(I)
save new_I.mat I
end
Then execute this code:
removeBlob()
new_I=load('new_I.mat');
new_I=new_I.I;
imshow(new_I)
In order to close the steam blobs I have tried with imclose() but it does not seem to work very well as one space is left, I will take a deeper view on it.
khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
this code is also not working. I have tried a lot but the seam is not detected in a single line. It will be really helpful if u can do it. Thank you :)
khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
https://in.mathworks.com/matlabcentral/answers/317489-autonomous-seam-detection-on-matlab
this is what exactly i want to do.
Alfonso
Alfonso 2018 年 5 月 3 日
編集済み: Alfonso 2018 年 5 月 3 日
Download the attached image (sc.png), which is the binary image you posted on your question, and move it to the folder your working on, save this first chunk of code as removeBlob.m
function removeBlob
I=imread('sc.png');
I = im2bw(I);
I = bwlabel(imfill(I>0,'holes'));
% I = bwlabel(imfill(imread('sc.png')>100,'holes'));
h = imshow(label2rgb(I,jet(numel(unique(I(:)))),[0 0 0]));
set(h,'buttondownfcn',{@removeIt,I})
end
function removeIt(src,~,I)
cp = round(get(get(src,'parent'),'currentpoint'));
val = I(cp(3),cp(1));
I(I==val) = 0;
set(src,'cdata',bsxfun(@times,uint8(logical(I)),get(src,'cdata')));
figure
imshow(I)
save new_I.mat I
end
finally execute the last chunk of code
removeBlob()
new_I=load('new_I.mat');
new_I=new_I.I;
imshow(new_I)
You should select the blob you want to delete and get this output:
About joining the steam blobs I am not quite sure, as I have tried bwmorph and imclose functions but not getting the desired result as I got this result...
SE = strel('rectangle',[100 40])
closeBW = imclose(new_I,SE);
imshow(closeBW)
Maybe you could try with Image Analyst demo tu burn lines in the image in order to fill the blank spaces, see answer of this post:
khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
Alfonso
Alfonso 2018 年 5 月 3 日
編集済み: Alfonso 2018 年 5 月 3 日
Make sure in your removeBlob.m in the first line you are reading 'sc.png', also make sure you are working on a recent version of matlab. Then write in your command window
removeBlob()
See if it works and select the blob you want to delete. After execute
new_I=load('new_I.mat');
new_I=new_I.I;
imshow(new_I)
If this does not work I am not quite sure of what might be happening; works fine here.
In case it does not work, I have attached the binary image without the blob as new_I.mat
Guillaume
Guillaume 2018 年 5 月 3 日
編集済み: Guillaume 2018 年 5 月 3 日
getting this error!
And the error message explains clearly what the problem is:
Expected input number 2 to match one of these values:
'holes'
The input, 'holes ' did not match any of the valid values
Error in removeBlob
I = bwlabel(imfill(I>0, 'holes '));
The option is 'holes' not 'holes '. Get rid of that extra space and learn to read the error message.
khushboo chhikara
khushboo chhikara 2018 年 5 月 3 日
Can we do it without clicking on the blob ? Isn't there is any other way to do it without making a function. And yes kindly help me with this --

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

カテゴリ

ヘルプ センター および File ExchangeRead, Write, and Modify Image についてさらに検索

質問済み:

2018 年 5 月 3 日

コメント済み:

2018 年 5 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by