Hi i want to calculate the line starting point(x1,y1) and ending point(x2,y2) of a line the line is in circle. The Square image is (0,0) and (100,100), With in this image the line is drawn. I want that drawn line starting and ending points.. This code in C#

Recommended Answers

All 4 Replies

hi you want to calculate the distance between the point1(x1,y1) and point2(x2,y2) ?

You need to explain this better. Are you trying to calculate the coordinates where a line intersects a circle? And what inputs are you given (slope, y-intersect, etc.), or are trying to extract a line from a raw image?

@nmaillet I am trying to identify the end points of P1 and P2 the image will be here Click Here in those center is (17,25) and radius is 5 so i am try to get it by using pixels is it possible.

It's certainly possible, but image recognition is difficult. Although I have done a little research on the subject, I don't have any experience implementing. Are you using that type of image? Or is that just an example? I'm curious to know if you will be using real world images, or simple black and white (no greyscale) images. It would be much easier with a black and white image, as simple edge detection becomes incredibly difficult when colours or shades of grey are introduced (compressed image formats could introduce other shades).

Ok, so I don't know any algorithms off the top of my head, but this might work for you (again, not experienced in this field, so take it with heaping grains of salt):

  1. Create a cone with radius x.
  2. Count the number of pixels contained within the cone.
  3. Rotate x/2 degress around the origin.
  4. Repeat until the entire circle has been covered.
  5. Select the cone(s) with the largest number of pixels (take care not to select two adjacent cones).
  6. This will give us a range of degrees (or radians), now decrease x by more than a factor of two, and repeat (within the selected cone(s)) until you get an accurate enough answer.
  7. Do the math.

Note that this wouldn't work well if the lines get close enough together, but selections could be broken up after the first pass. Hopefully that's of some use to you. Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.