IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27342


Ignore:
Timestamp:
Mar 18, 2010, 3:57:43 PM (16 years ago)
Author:
bills
Message:

Fix incorrect masking of undiffed pixels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/diffedpixels.c

    r27223 r27342  
    240240ocur at pt0.y and pt2.y
    241241
    242 Example 1
     242Type 1
    243243
    244244                3
     
    250250                   1                                line 2_3  y >= pt.y
    251251**************************
    252 Example 2
     252
    253253                3
    254254              C
     
    260260
    261261**************************
    262 Example 3
     262If The left side corners have the same x we also have a Type 1
    263263
    264264        3       2
     
    282282nameCorners(psPlane pt[4])
    283283{
    284     psPlane   pt0, pt1, pt2, pt3;
    285 
    286284    // sort points top to bottom
    287285    int i;
     
    297295        }
    298296    }
     297    psPlane bl, br;
    299298    // sort bottom two points in x
    300299    if (pt[3].x < pt[2].x) {
    301         psPlane tmpPt = pt[3];
    302         pt[3] = pt[2];
    303         pt[2] = tmpPt;
    304     }
    305     // now we know that p[3] point is pt1 - the lower right corner
    306     pt1 = pt[3];
    307    
    308     // And pt[2] is left most of the bottom 2  (either pt0 or pt2)
    309 
    310     // find which of the top two is to the left
     300        bl = pt[3];
     301        br = pt[2];
     302    } else {
     303        bl = pt[2];
     304        br = pt[3];
     305    }
     306    // sort the top two points in x
     307    psPlane tl, tr;
    311308    if (pt[0].x < pt[1].x) {
    312         pt3 = pt[0];
    313         // now decide which of pt[1] and pt[2] is pt0 - on the left)
    314         if (pt[1].x < pt[2].x) {
    315             pt0 = pt[1];
    316             pt2 = pt[2];
    317         } else {
    318             pt0 = pt[2];
    319             pt2 = pt[1];
    320         }
    321     } else {
    322         pt3 = pt[1];
    323         // now decide which of pt[0] and pt[2] is pt0 - on the left)
    324         if (pt[0].x < pt[2].x) {
    325             pt0 = pt[0];
    326             pt2 = pt[2];
    327         } else {
    328             pt0 = pt[2];
    329             pt2 = pt[0];
    330         }
    331     }
    332 
    333     /* now write the outputs back to the input array*/
    334     pt[0] = pt0;
    335     pt[1] = pt1;
    336     pt[2] = pt2;
    337     pt[3] = pt3;
    338 
    339     // And Check the results
    340     // y3 > y0
    341     // y2 > y0
    342     // y3 > y1
    343     // x1 > x0
    344     // x2 > x0
    345     // x2 > x3
     309        tl = pt[0];
     310        tr = pt[1];
     311    } else {
     312        tl = pt[1];
     313        tr = pt[0];
     314    }
     315    if (tl.y >= tr.y) {
     316        // Type 1 (or 3 which is equivalent)
     317        pt[0] = bl;
     318        pt[1] = br;
     319        pt[2] = tr;
     320        pt[3] = tl;
     321    } else {
     322        pt[0] = tl;
     323        pt[1] = bl;
     324        pt[2] = br;
     325        pt[3] = tr;
     326    }
     327
     328    // Now check the results match our requirements
     329    // pt3 is above pt0
    346330    if (pt[3].y <= pt[0].y) {
    347331        fprintf(stderr, "ERROR calculating diff overlap\n");
     
    349333        streaksExit("", PS_EXIT_PROG_ERROR);
    350334    }
    351     if (pt[2].y <= pt[0].y) {
    352         fprintf(stderr, "ERROR calculating diff overlap\n");
    353         fprintf(stderr, "pt[2].y (%f) <= pt[0].y (%f)\n", pt[2].y, pt[0].y);
    354         streaksExit("", PS_EXIT_PROG_ERROR);
    355     }
     335    // pt3 is above pt1
    356336    if (pt[3].y <= pt[1].y) {
    357337        fprintf(stderr, "ERROR calculating diff overlap\n");
     
    359339        streaksExit("", PS_EXIT_PROG_ERROR);
    360340    }
     341    // pt2 is above pt1
     342    if (pt[2].y <= pt[1].y) {
     343        fprintf(stderr, "ERROR calculating diff overlap\n");
     344        fprintf(stderr, "pt[2].y (%f) <= pt[1].y (%f)\n", pt[2].x, pt[1].x);
     345        streaksExit("", PS_EXIT_PROG_ERROR);
     346    }
     347    // pt1 is to the right of pt0
    361348    if (pt[1].x <= pt[0].x) {
    362349        fprintf(stderr, "ERROR calculating diff overlap\n");
     
    364351        streaksExit("", PS_EXIT_PROG_ERROR);
    365352    }
     353    // pt2 is to the right of pt0
    366354    if (pt[2].x <= pt[0].x) {
    367355        fprintf(stderr, "ERROR calculating diff overlap\n");
     
    369357        streaksExit("", PS_EXIT_PROG_ERROR);
    370358    }
     359    // pt2 is to the right of pt3
    371360    if (pt[2].x <= pt[3].x) {
    372361        fprintf(stderr, "ERROR calculating diff overlap\n");
     
    374363        streaksExit("", PS_EXIT_PROG_ERROR);
    375364    }
    376 }
     365    // pt2 is below or at the same y as pt3
     366    if (pt[2].y > pt[3].y) {
     367        fprintf(stderr, "ERROR calculating diff overlap\n");
     368        fprintf(stderr, "pt[2].y (%f) > pt[3].y (%f)\n", pt[2].y, pt[3].y);
     369        streaksExit("", PS_EXIT_PROG_ERROR);
     370    }
     371}
Note: See TracChangeset for help on using the changeset viewer.