Modulo-8 problems
|
Original Message
|
Name: CringeHarder
Date: May 17, 2005 at 07:17:28 Pacific
Subject: Modulo-8 problemsOS: Win XPCPU/Ram: 3Ghz CPU / 1Gig Ram |
Comment: Hi, Background Description: I'm trying to implement a program using C++ that returns the most common angle in a picture using chaining. My program chains around objects recording the direction of the lines as numbers 0 - 7. 0 being North going clockwise round to 7 as North-West. In order to smooth this result for each point I add the 10 neighbouring points and then divide the result by 10 to give an average/smoothed direction for that point. Problem: The problem comes when averaging a corner or line which has points that include values such as 0 and 7 returning the wrong results. Does anyone know a way I can get around this? Any help would be greatly appreciated. Thank you
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: didorno
Date: May 26, 2005 at 11:00:38 Pacific
Subject: Modulo-8 problems |
Reply: (edit)If I understand you well, you can start with the statement that each point already has an uncertainty of +/- nx8. So, if you add val1 +/- n1x8 + val2 +/- n2x8 + ..... / 10, then you get a basic value plus an offset which is a function of all the integers n divided by 10. If I do this for 2 points : 1 and 7 I get as result 4 + 4x(n1 + n2). So possible values are 4, 0, 8 etc. This approach helps you ? Regards.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: didorno
Date: May 26, 2005 at 15:05:52 Pacific
Subject: Modulo-8 problems |
Reply: (edit)The above is true, but gives no easy solution. I think a better approach is to consider every value as a vector. Decompose every vector in a X and a Y part. For instance : 0 : rY 1 : (r/V2)X + (r/V2)Y 2 : rX 3 : (r/V2)X - (r/V2)Y etcetera. If you assume that these are unit vectors the r's vanishes. Sum all 10 X and all 10 Y values. The average angle can be found by arctan(Y/X). The signs of Y and X gives the final quadrant. I hope this will help you
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: