hexagon logo

A little code to filter the outliers on 3D features

This part of code allows filtering outliers (3 standard deviations, in the code, but can be change by 2 - red value in the code)
You need to align on the feature that you want filtering (only origin for the sphere, origin and level for cone and cylinder).
The case in this code is a sphere filtered from a measured auto sphere.
Hope it's usefull...Confused

REF2       =ALIGNMENT/START,RECALL:REF1,LIST=YES
              ALIGNMENT/TRANS,XAXIS,SPH2
              ALIGNMENT/TRANS,YAXIS,SPH2
              ALIGNMENT/TRANS,ZAXIS,SPH2
            ALIGNMENT/END
            DISPLAYPRECISION/6
            ASSIGN/V1=SPH2.NUMHITS
            ASSIGN/V2=DOT(SPH2.HIT[1..V1].XYZ-SPH2.HIT[1..V1].TXYZ,SPH2.HIT[1..V1].TIJK)
            ASSIGN/V3=SUM(V2)/V1
            ASSIGN/V4=SQRT(SUM((V2-V3)^2)/(V1-1))
            ASSIGN/V5=V2-V3
            ASSIGN/V6=0
V7         =LOOP/START,ID=YES,NUMBER=V1,START=1,SKIP=,
              OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
              IF/ABS(V5[V7])<[COLOR=#FF0000]3[/COLOR]*V4
                ASSIGN/V6=V6+1
F1             =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<SPH2.HIT[V7].TX,SPH2.HIT[V7].TY,SPH2.HIT[V7].TZ>,$
                MEAS/XYZ,<SPH2.HIT[V7].X,SPH2.HIT[V7].Y,SPH2.HIT[V7].Z>,$
                NOM/IJK,<SPH2.HIT[V7].TI,SPH2.HIT[V7].TJ,SPH2.HIT[V7].TK>,$
                MEAS/IJK,<SPH2.HIT[V7].I,SPH2.HIT[V7].J,SPH2.HIT[V7].K>
              END_IF/
            LOOP/END
SPH3       =FEAT/SPHERE,CARTESIAN,OUT,LEAST_SQR,NO
            THEO/<0,0,0>,<0,0,1>,0
            ACTL/<-0.018452,0.000041,0.000159>,<0,0,1>,60.046132
            CONSTR/SPHERE,BF,F1[1..V6],,

V2 is the T values array
V3 is the average of t values
V4 is the standard dev of t values
V5 is the re-centered t_values array (each value minus the average)
V6 count the number of hits after filtering
If statement selects tvalue (if abs of t value is lower than n std dev, hit is selected, else it's rejected)
Display precision is setted to 6 because the standard dev can be very few, so it avoids resulting zero !!!!!
Parents
  • Honest question - how is this different than the method I've been using?

    SPH1 =FEAT/CONTACT/SPHERE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<0,0,0>,<0,0,1>,10
    ACTL/<0,0,0>,<0,0,1>,10
    TARG/<0,0,0>,<0,0,1>
    START ANGLE 1=0,END ANG 1=360
    START ANGLE 2=0,END ANG 2=90
    ANGLE VEC=<1,0,0>
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=24,NUMROWS=3
    SAMPLE HITS=0
    AVOIDANCE MOVE=NO,DISTANCE=0.3937
    SHOW HITS=NO
    SCN1 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.6815>,<0,0,1>
    ACTL/<0,0,1.6815>,<0,0,1>
    CONSTR/SET,BASIC,SPH1.HIT[1..SPH1.NUMHITS],,
    SCN3 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.5372>,<0,0,1>
    ACTL/<0,0,1.5372>,<0,0,1>
    CONSTR/SET,FILTER,GAUSSIAN,POLAR,SCN1,
    FILTER/OFF,OUTLIER_REMOVAL/ON,3


    Honest answer : Because it doesn't work... !
    I tried with a sphere which has a defect, the constructed filter doesn't reject the outlier, this code does the job...
Reply
  • Honest question - how is this different than the method I've been using?

    SPH1 =FEAT/CONTACT/SPHERE/DEFAULT,CARTESIAN,IN,LEAST_SQR
    THEO/<0,0,0>,<0,0,1>,10
    ACTL/<0,0,0>,<0,0,1>,10
    TARG/<0,0,0>,<0,0,1>
    START ANGLE 1=0,END ANG 1=360
    START ANGLE 2=0,END ANG 2=90
    ANGLE VEC=<1,0,0>
    SHOW FEATURE PARAMETERS=NO
    SHOW CONTACT PARAMETERS=YES
    NUMHITS=24,NUMROWS=3
    SAMPLE HITS=0
    AVOIDANCE MOVE=NO,DISTANCE=0.3937
    SHOW HITS=NO
    SCN1 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.6815>,<0,0,1>
    ACTL/<0,0,1.6815>,<0,0,1>
    CONSTR/SET,BASIC,SPH1.HIT[1..SPH1.NUMHITS],,
    SCN3 =FEAT/SET,CARTESIAN
    THEO/<0,0,1.5372>,<0,0,1>
    ACTL/<0,0,1.5372>,<0,0,1>
    CONSTR/SET,FILTER,GAUSSIAN,POLAR,SCN1,
    FILTER/OFF,OUTLIER_REMOVAL/ON,3


    Honest answer : Because it doesn't work... !
    I tried with a sphere which has a defect, the constructed filter doesn't reject the outlier, this code does the job...
Children
No Data