Diff of /adjust.c [0a87db] .. [8fbc76] Maximize Restore

  Switch to unified view

a/adjust.c b/adjust.c
...
...
63
void                    writeControlPoints( struct controlPoint *cp,char* cdesc );
63
void                    writeControlPoints( struct controlPoint *cp,char* cdesc );
64
int                     CheckParams( AlignInfo *g );
64
int                     CheckParams( AlignInfo *g );
65
static int              CheckMakeParams( aPrefs *aP);
65
static int              CheckMakeParams( aPrefs *aP);
66
//static int            GetOverlapRect( PTRect *OvRect, PTRect *r1, PTRect *r2 );
66
//static int            GetOverlapRect( PTRect *OvRect, PTRect *r1, PTRect *r2 );
67
int                     AddEdgePoints( AlignInfo *gl );
67
int                     AddEdgePoints( AlignInfo *gl );
68
int                     pt_average( UCHAR* pixel, int BytesPerLine, double rgb[3], int bytesPerChannel );
68
int                     pt_average( uint8_t* pixel, int BytesPerLine, double rgb[3], int bytesPerChannel );
69
double                  distsqLine(int N0, int N1);
69
double                  distsqLine(int N0, int N1);
70
70
71
71
72
72
73
void panoAdjustPrintMakeParams(char *msg, struct MakeParams *mp, Image *im)
73
void panoAdjustPrintMakeParams(char *msg, struct MakeParams *mp, Image *im)
...
...
1611
                                {
1611
                                {
1612
                                        for(y = 0; y < im->height; y++)
1612
                                        for(y = 0; y < im->height; y++)
1613
                                        {
1613
                                        {
1614
                                                c1 = y * im->bytesPerLine;
1614
                                                c1 = y * im->bytesPerLine;
1615
                                                for(x = 0; x < im->width; x++)
1615
                                                for(x = 0; x < im->width; x++)
1616
                                                        *((USHORT*)(src + c1 + 8 * x )) = 0;
1616
                                                        *((uint16_t*)(src + c1 + 8 * x )) = 0;
1617
                                        }
1617
                                        }
1618
                                }
1618
                                }
1619
                                for(y = framey; y < yend; y++)
1619
                                for(y = framey; y < yend; y++)
1620
                                {
1620
                                {
1621
                                        c1 = y * im->bytesPerLine;
1621
                                        c1 = y * im->bytesPerLine;
1622
                                        for(x = framex; x < xend; x++)
1622
                                        for(x = framex; x < xend; x++)
1623
                                                *((USHORT*)(src + c1 + 8 * x )) = USHRT_MAX;
1623
                                                *((uint16_t*)(src + c1 + 8 * x )) = USHRT_MAX;
1624
                                }
1624
                                }
1625
                        }
1625
                        }
1626
                }
1626
                }
1627
                else if( im->format == _fisheye_circ ) // Circle valid
1627
                else if( im->format == _fisheye_circ ) // Circle valid
1628
                {
1628
                {
...
...
1664
                                for(y = 0; y < im->height  ; y++) 
1664
                                for(y = 0; y < im->height  ; y++) 
1665
                                {
1665
                                {
1666
                                        if( (y < topCircle) || (y > botCircle) )  // Always invalid
1666
                                        if( (y < topCircle) || (y > botCircle) )  // Always invalid
1667
                                        {
1667
                                        {
1668
                                                for(x = 0; x < im->width; x++)
1668
                                                for(x = 0; x < im->width; x++)
1669
                                                        *((USHORT*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1669
                                                        *((uint16_t*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1670
                                        }
1670
                                        }
1671
                                        else
1671
                                        else
1672
                                        {
1672
                                        {
1673
                                                h       =       y - im->height/2;
1673
                                                h       =       y - im->height/2;
1674
                                                if( h*h > r*r ) h = r;
1674
                                                if( h*h > r*r ) h = r;
...
...
1677
                                                if( x1 < 0 ) x1 = 0;
1677
                                                if( x1 < 0 ) x1 = 0;
1678
                                                x2 = (int) (r + sqrt( r*r - h*h ));
1678
                                                x2 = (int) (r + sqrt( r*r - h*h ));
1679
                                                if( x2 > im->width ) x2 = im->width;
1679
                                                if( x2 > im->width ) x2 = im->width;
1680
                        
1680
                        
1681
                                                for(x = 0; x < x1; x++)
1681
                                                for(x = 0; x < x1; x++)
1682
                                                        *((USHORT*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1682
                                                        *((uint16_t*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1683
                                                for(x = x1; x < x2; x++)
1683
                                                for(x = x1; x < x2; x++)
1684
                                                        *((USHORT*)(src + y * im->bytesPerLine + 8 * x)) = USHRT_MAX;
1684
                                                        *((uint16_t*)(src + y * im->bytesPerLine + 8 * x)) = USHRT_MAX;
1685
                                                for(x = x2; x < im->width; x++)
1685
                                                for(x = x2; x < im->width; x++)
1686
                                                        *((USHORT*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1686
                                                        *((uint16_t*)(src + y * im->bytesPerLine + 8 * x)) = 0;
1687
                                        }
1687
                                        }
1688
                                }
1688
                                }
1689
                        }
1689
                        }
1690
                } // mode
1690
                } // mode
1691
        }       // pixelsize
1691
        }       // pixelsize
...
...
2296
        }else{//16
2296
        }else{//16
2297
                for( y=1; y<src->height-1; y++){
2297
                for( y=1; y<src->height-1; y++){
2298
                        c1 = y * src->bytesPerLine;
2298
                        c1 = y * src->bytesPerLine;
2299
                        for( x=1; x<src->width-1; x++){
2299
                        for( x=1; x<src->width-1; x++){
2300
                                c2 = c1 + x*bpp;
2300
                                c2 = c1 + x*bpp;
2301
                                if( *((USHORT*)(source + c2)) != 0  &&  *((USHORT*)(buff + c2)) != 0 ) { //&& // In overlap region?
2301
                                if( *((uint16_t*)(source + c2)) != 0  &&  *((uint16_t*)(buff + c2)) != 0 ) { //&& // In overlap region?
2302
                                 //( *((USHORT*)(source + c2)) != USHRT_MAX  ||  *((USHORT*)(buff + c2)) != USHRT_MAX ) ){ // above seam?
2302
                                 //( *((uint16_t*)(source + c2)) != USHRT_MAX  ||  *((uint16_t*)(buff + c2)) != USHRT_MAX ) ){ // above seam?
2303
                                        if( pt_average( source + c2, src->bytesPerLine, xav, 2 ) &&
2303
                                        if( pt_average( source + c2, src->bytesPerLine, xav, 2 ) &&
2304
                                            pt_average( buff + c2, src->bytesPerLine, yav, 2 )){
2304
                                            pt_average( buff + c2, src->bytesPerLine, yav, 2 )){
2305
                                                numPts++;
2305
                                                numPts++;
2306
                                                for( i=0; i<3; i++){
2306
                                                for( i=0; i<3; i++){
2307
                                                        xi[i]   += xav[i];
2307
                                                        xi[i]   += xav[i];
...
...
2328
                }
2328
                }
2329
        }
2329
        }
2330
}
2330
}
2331
#endif
2331
#endif
2332
// Average 9 pixels
2332
// Average 9 pixels
2333
int pt_average( UCHAR* pixel, int BytesPerLine, double rgb[3], int bytesPerChannel ){
2333
int pt_average( uint8_t* pixel, int BytesPerLine, double rgb[3], int bytesPerChannel ){
2334
        int x, y, i;
2334
        int x, y, i;
2335
        UCHAR *px;
2335
        uint8_t *px;
2336
        double sum = 1.0 + 4 * 0.5 + 8 * 0.2 + 8 * 0.1 ;//2.6;
2336
        double sum = 1.0 + 4 * 0.5 + 8 * 0.2 + 8 * 0.1 ;//2.6;
2337
#if 0
2337
#if 0
2338
        double bl[3][3] =      {{ 0.1, 0.3, 0.1}, // Blurr overlap using this matrix
2338
        double bl[3][3] =      {{ 0.1, 0.3, 0.1}, // Blurr overlap using this matrix
2339
                                { 0.3, 1.0, 0.3},
2339
                                { 0.3, 1.0, 0.3},
2340
                                { 0.1, 0.3, 0.1}};
2340
                                { 0.1, 0.3, 0.1}};
...
...
2422
                {
2422
                {
2423
                        c1 = y * src->bytesPerLine;
2423
                        c1 = y * src->bytesPerLine;
2424
                        for( x=0; x<src->width; x++)
2424
                        for( x=0; x<src->width; x++)
2425
                        {
2425
                        {
2426
                                c2 = c1 + x*bpp;
2426
                                c2 = c1 + x*bpp;
2427
                                if( *((USHORT*)(source + c2)) != 0  &&  *((USHORT*)(buff + c2)) != 0 ) // In overlap region?
2427
                                if( *((uint16_t*)(source + c2)) != 0  &&  *((uint16_t*)(buff + c2)) != 0 ) // In overlap region?
2428
                                {
2428
                                {
2429
                                        numPts++;
2429
                                        numPts++;
2430
                                        for( i=0; i<3; i++)
2430
                                        for( i=0; i<3; i++)
2431
                                        {
2431
                                        {
2432
                                                c2++;
2432
                                                c2++;
2433
                                                xi[i]   += (double) *((USHORT*)(source + c2));
2433
                                                xi[i]   += (double) *((uint16_t*)(source + c2));
2434
                                                yi[i]   += (double) *((USHORT*)(buff + c2));
2434
                                                yi[i]   += (double) *((uint16_t*)(buff + c2));
2435
                                                xi2[i]  += ((double) *((USHORT*)(source + c2)))*((double) *((USHORT*)(source + c2)));
2435
                                                xi2[i]  += ((double) *((uint16_t*)(source + c2)))*((double) *((uint16_t*)(source + c2)));
2436
                                                xy[i]   += ((double) *((USHORT*)(source + c2)))*((double) *((USHORT*)(buff + c2)));
2436
                                                xy[i]   += ((double) *((uint16_t*)(source + c2)))*((double) *((uint16_t*)(buff + c2)));
2437
                                        }
2437
                                        }
2438
                                }
2438
                                }
2439
                        }
2439
                        }
2440
                }
2440
                }
2441
        }
2441
        }
...
...
2504
                {
2504
                {
2505
                        c1 = y * im->bytesPerLine;
2505
                        c1 = y * im->bytesPerLine;
2506
                        for( x=0; x<im->width; x++ )
2506
                        for( x=0; x<im->width; x++ )
2507
                        {
2507
                        {
2508
                                c2 = c1 + x * bpp;
2508
                                c2 = c1 + x * bpp;
2509
                                if( *((USHORT*)(data + c2 )) != 0 ) // Alpha channel set
2509
                                if( *((uint16_t*)(data + c2 )) != 0 ) // Alpha channel set
2510
                                {
2510
                                {
2511
                                        for( i=0; i<3; i++)
2511
                                        for( i=0; i<3; i++)
2512
                                        {
2512
                                        {
2513
                                                c2++;
2513
                                                c2++;
2514
                                                result = ColCoeff[i][0] * *((USHORT*)(data + c2 )) + ColCoeff[i][1];
2514
                                                result = ColCoeff[i][0] * *((uint16_t*)(data + c2 )) + ColCoeff[i][1];
2515
                                                DBL_TO_US( *((USHORT*)(data + c2 )) , result );
2515
                                                DBL_TO_US( *((uint16_t*)(data + c2 )) , result );
2516
                                        }
2516
                                        }
2517
                                }
2517
                                }
2518
                        }
2518
                        }
2519
                }
2519
                }
2520
        }
2520
        }