Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How do you thicken the edge in a logical edge image?

Subject: How do you thicken the edge in a logical edge image?

From: Vivian Harvey

Date: 1 Jul, 2010 19:25:06

Message: 1 of 5

For example,

I=imread('Image.jpg');
I=rgb2gray(I);
I=im2bw(I,threshold);
I=edge(I);

The edges are broken, how do I continue something like a broken line or thicken the edges not working manually

Subject: How do you thicken the edge in a logical edge image?

From: Sean

Date: 1 Jul, 2010 19:41:04

Message: 2 of 5

"Vivian Harvey" <viv_harv@yahoo.co.uk> wrote in message <i0iq2i$f9u$1@fred.mathworks.com>...
> For example,
>
> I=imread('Image.jpg');
> I=rgb2gray(I);
> I=im2bw(I,threshold);
> I=edge(I);
>
> The edges are broken, how do I continue something like a broken line or thicken the edges not working manually

It's difficult to answer without seeing your image. However, I would guess a morphological dilation would be a good place to start.
>>help imdilate

Subject: How do you thicken the edge in a logical edge image?

From: ImageAnalyst

Date: 1 Jul, 2010 19:44:49

Message: 3 of 5

Vivian Harvey:
You could try using fspecial() and imfilter() and thresholding it on
your own to get thicker edges rather than rely on the built-in
automatic threshold of edge().

Or else just use imclose(), or imdilate() followed by
bwmorph(imageArray, 'skel') on your edge()-generated image.
-Image Analyst

Subject: How do you thicken the edge in a logical edge image?

From: David Young

Date: 1 Jul, 2010 22:01:04

Message: 4 of 5

Rather than post-processing the edges, it might be worth experimenting with a better edge detector in the first place. The default for the edge function is the simple Sobel operator. You could try other options, for example the Canny detector, and also experiment with its smoothing and threshold parameters. This may well give you more continuous edges.

Subject: How do you thicken the edge in a logical edge image?

From: Christopher

Date: 2 Jul, 2010 04:52:06

Message: 5 of 5

"Vivian Harvey" <viv_harv@yahoo.co.uk> wrote in message <i0iq2i$f9u$1@fred.mathworks.com>...
> For example,
>
> I=imread('Image.jpg');
> I=rgb2gray(I);
> I=im2bw(I,threshold);
> I=edge(I);
>
> The edges are broken, how do I continue something like a broken line or thicken the edges not working manually

It depends on how close your 'breaks' are. Lets say you have two edges that you want to be joined that are separated by 4 pixels of black (non-edges). You can 'join' them by using morphology, as previously suggested. Define a STREL and work on your image:

diskEnt = strel('disk',4); % radius of 4
joinedIm = imclose(unjoinedIm,diskEnt);

However, this has the habit of joining edges that you DON'T want to join. I've used a 'disk' structure because it's independent of the direction. Better yet, if you know that all of your 'breaks' have a particular geometry, you can structure your STREL according to this. That way, you'll minimise the 'false' joins. This kind of scenario is hard to find though - it all depends on the input image.

Passing a filter over it as previously suggested is a good way to thicken the edges but its a bit hit-and-miss with the joining part.

Chris

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us