HOW CAN I BREAK A DIAGONAL PIXELS IN AN IMAGE??

I converted a gray scale image to binary image and i want to segment out the required parts from the binary image. Now the problem is sometimes due to the intensity variation, two parts in binary image are connected "Diagonally". I want to break those diagonally connected pixels. By Using the function "bwmorph", there is an option to connect diagonal pixels but i want it to work in reverse direction, i.e., i want the diagonally connected pixels to break or make the diagonal pixels to "black color" or "0"
Can any one Help me out in this??

 Accepted Answer

How about using watershed()?

2 Comments

Oh no. watershed() is changing the other pixel values. For example,
If A =
0 0 0 0
1 1 0 0
1 1 0 0
0 0 1 1
0 0 1 1
then a = watershed(A,4) gives
1 1 1 1
1 1 1 1
0 0 1 1
2 2 0 1
2 2 2 0
which should not be the case, because i want either the element (3,2) or the element (4,3) of the matrix A should become zero and the rest of the elements should remain same.
Like how the "bridge" works with "bwmorph" function, it detects the diagonal elements after "ones" and adds "ones". I want any function that works exactly in opposite way as bridge works.
In my case, in specific, i have "ones" in a diagonal form - the elements (2,1) (3,2) (4,3) (5,4). I want to break this diagonal in the middle. That means either (3,2) or (4,3) should become zero.
In my binary image, two regions (white color - "ones") are connected only because there is one diagonal line. Please help me out how can i break this diagonal ones so that i can separate those regions???
Then just call bwlabel() with 4-connectivity.

Sign in to comment.

More Answers (2)

Use makelut() to make a lookup table that identifies these diagonals and the unse applylut() to apply the lookup table to your data. This is the generic form of bwmorph() and essentially what it does under the hood for many of its operations.
Padma
Padma on 12 Feb 2013
Thank you for your solution. Will try it out this way

Categories

Community Treasure Hunt

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

Start Hunting!