0

Im trying to calculate the number of intercepts a line makes with the boundaries(black edges). however all pixels, even those not part of the boundary are taken to account, and the many pixels that are part of any boundary are taken as individual values.

how can i make it that small group lower than a certain pixel number are not shown in the picture, and I get the correct number of intercepts the lines make with the boundaries.

All help appreciated

  • you could filter out the points that fall within the area (i.e. 0 < px < x_size, 0 < py < y_size ). Otherwise, if you know the equation of the line you can simply find the intersections with the four edges. Otherwise... make the edges red – Pynchia Dec 12 '15 at 21:46
  • Please add some clarification. I looked at the image and still don't understand what you mean. – Graham Asher Dec 12 '15 at 21:49
  • Basically, it is an image of grains, the black edges being the grain boundaries. I have to calculate how many interceptions the line makes with the grain boundaries. – Pythonator Dec 12 '15 at 21:52
  • What code do you have so far? How is it not doing what you want? – DilithiumMatrix Dec 12 '15 at 22:17
  • @DilithiumMatrix http://stackoverflow.com/questions/11253899/removing-the-background-noise-of-a-captcha-image-by-replicating-the-chopping-fil I used this code, but It didnt work for me – Pythonator Dec 13 '15 at 01:44

1 Answers1

0

Based on the text of your question I assume you made the naive implementation of boundaries detection.

I suggest to look on the edge detection libraries. Just search for this (even here on SO). E.g. http://scikit-image.org/docs/dev/auto_examples/plot_canny.html

As you can see you will need to adjust some filters for the noise you have in the image.

Radek
  • 1,530
  • 16
  • 20
  • `edges2 = feature.canny(grain_boundaries, sigma=3)` `io.imshow(edges2)` http://imgur.com/YLZN5ga) basically I tried to do it that way but it didnt seem to work for me – Pythonator Dec 13 '15 at 01:56
  • Well, your source image already looks like output from some processing. Do you have original images? (Ideally with colors.) – Radek Dec 13 '15 at 17:12
  • http://imgur.com/D3Ew7iu Here is a color image, however I converted it into a binary image so i could easily find the intercepts – Pythonator Dec 13 '15 at 17:44
  • By conversion to binary bitmap the edge detection does not have some info. I suggest you try the edge detection with the original image. You might need to play with params for the filter. – Radek Dec 14 '15 at 00:23