how to connect disjoint pixels on image borders?

7 vues (au cours des 30 derniers jours)
sara
sara le 28 Nov 2014
Modifié(e) : sara le 30 Mai 2015
i have an image,i used open close by reconstruction,and then sobel edge detector,it detect edge ,but it has some disjoint parts,pixels are not connected in some parts,i want to use connected component labeling and watershed segmentation,so first i should make a connected border,then use imfill,to fill the area between borders,and watershed to segment them,is there any function i call to connect pixels which are close to each other?when i use sobel on original image,it detects border,but by too many dots,which are not connected,like some one draw borders by dots,when i use open close on image,the border is much better,but still has some disjoint parts,thank you so much

Réponse acceptée

Image Analyst
Image Analyst le 28 Nov 2014
What is "open close"? There is imopen() and imclose() but usually you do one or the other. I don't know exactly what operations you did (functions that you called) when you say you did "open close". That's not standard terminology.
You can use imclose() to connect nearby pixels.
How did you do Sobel? Did you use edge() or imgradient()? You should use imgradient() and then you can choose your own threshold. Choose a lower threshold to make the edges more connected.
  4 commentaires
Weng Keong Wong
Weng Keong Wong le 21 Avr 2015
Hi Image Analyst, i have used edge detector sobel to detect the edges of the image but the some of the edge are not really connected. and you have mentioned to use imgradient() and set the threshold lower... can you show some sample codes of how to do it. because I have tried and I could not get it right.
sara
sara le 30 Mai 2015
Modifié(e) : sara le 30 Mai 2015
you should first use imgradient,and its example is in matlab image processing toolbox,watershed segmentation,it has imgradient,then you should use edge detector on that imgradient ,it gives better results if you use edge detection on imgradient,than you use it directly on the image you also can use im2bw(imgradient,0.5) on the imgradient image,and then change the 0.5 to see which number gives the better results,.(instead of edge detection)

Connectez-vous pour commenter.

Plus de réponses (1)

sara
sara le 27 Jan 2015
hello,can i first segment my image in 3 or 4 sub images,like you segment a paper into 4 equal pieces,by horizontal lines,then for each part i choose a different segmentation and watershed factor?thank you
  4 commentaires
Image Analyst
Image Analyst le 28 Jan 2015
Yes - you can use imcrop(). Just specify the starting row and column and the width and height.
sara
sara le 30 Jan 2015
thank you for your answer,but i found i should use margine removing,like you scan pictures and there are some black areas around picture,except this link which you described about how to remove margines,isnt there another written code,to remove margines?when i use imclearborder,it wont work,it darkens all the image,or most of it,the link is this: http://uk.mathworks.com/matlabcentral/answers/128133-automatically-trim-remove-crop-black-borders-margins-from-images-volumes i didnt read it carefully though,but it didnt gave me good resultsi couldnt write the code of 2 line you described(Get the black pixels imageArray == 0. Then invert and call imclearborder and subtract or XOR the two to get only those black pixels touching the border. Then use that mask to set the pixels to the desired gray level imageArray(mask) = desiredGrayLevel.)thank you

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by