2
$\begingroup$

I want to find repeating structures from the image .But I have no idea how to do it.Please help me.Actually i want to find how many lines and oval shapes look like similar and mark these by separate color.

enter image description here

$\endgroup$
  • $\begingroup$ Do you want to distinguish the wavy lines from the straight ones? Can they be interleaved; or are they always oriented as depicted? $\endgroup$ – Emre Jan 22 '16 at 23:04
2
$\begingroup$

You want to detect two things: lines/curves and circles. There are well-known algorithms to do both, so let's find them separately. I will present a solution in Mathematica. You can translate to your language.

  1. The first step is to eliminate the background. We do this by finding the background: img = Import["http://i.stack.imgur.com/Olczj.jpg"] bimg = ColorConvert[img, "Grayscale"] Blur[Closing[bimg, 20], 15]

background

Then dividing by it:

evenImg = Image[ImageData@bimg/ImageData@Blur[Closing[bimg, 20], 10]]

even image

  1. Detect the edges:

binImg = EdgeDetect[evenImg, 1, .1]

Edges

Now we just need to fill in the strokes:

smImg = ImageResize[Dilation[binImg, 2], {500}]

dilated

  1. We are finally ready for some detection. Let's start with the lines/curves:

Show[smImg, Graphics[{Yellow, Thick, Line /@ ImageLines[smImg, 0.25]}]]

Line detection

  1. What about the circles? Let's start by looking at all the connected components:

morph = MorphologicalComponents@smImg; Colorize@morph

Components

The circles are there, all right. We just need to filter out the objects that are not circular. We can do this by looking at the circularity, elongation, eccentricity, or Euler characteristic. Circles are easy to distinguish from other shapes by these properties.

noncircles = #[[1]] & /@ ComponentMeasurements[morph, "Elongation", # > 0.3 &]
circles = morph /. x_ :> 0 /; MemberQ[noncircles, x] // 
  Colorize // RemoveBackground

Circles

$\endgroup$
  • $\begingroup$ How can I do that command by using matlab? Show[smImg, Graphics[{Yellow, Thick, Line /@ ImageLines[smImg, 0.25]}]],Please help me $\endgroup$ – rossy Jan 23 '16 at 17:39
  • $\begingroup$ It's just for superposing the lines on the original images, so you'd probably use imfuse $\endgroup$ – Emre Jan 23 '16 at 18:22
  • $\begingroup$ Thanks.I am trying to implement the algorithm in matlab. Still struggling..Thank you. $\endgroup$ – rossy Jan 23 '16 at 18:42
  • $\begingroup$ The path to enlightenment is not without struggle :) Here are the relevant MATLAB functions. $\endgroup$ – Emre Jan 23 '16 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.