This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Classes | |
class | DPoint |
Functions | |
QRgb | interpolatedPixelValue (double xp, double yp, QImage *image) |
QRgb | blendColors (QRgb color1, QRgb color2, double alpha) |
DPoint | findTwoLineIntersection (DPoint p1, DPoint p2, DPoint p3, DPoint p4) |
|
Definition at line 355 of file tilt.cpp. Referenced by interpolatedPixelValue(). 00356 { 00357 double alpha2 = 1.0-alpha; 00358 return qRgb( (int) QMAX( QMIN( 255, alpha2*qRed (color1) + alpha*qRed(color2) ), 0 ), 00359 (int) QMAX( QMIN( 255, alpha2*qGreen(color1) + alpha*qGreen(color2) ), 0 ), 00360 (int) QMAX( QMIN( 255, alpha2*qBlue (color1) + alpha*qBlue(color2) ), 0 ) ); 00361 }
|
|
Definition at line 363 of file tilt.cpp. References DPoint::x(), and DPoint::y(). Referenced by correctImageTilt(). 00365 { 00366 //---------------------------------------------- 00367 //=== Case 1: neither line has a change in X === 00368 //---------------------------------------------- 00369 //If there is no change in x for both lines, 00370 //either lines will NEVER or ALWAYS intersect. 00371 if(p1.x() == p2.x() && 00372 p4.x() == p3.x()) 00373 { 00374 //Ok, if their x values are equal, return 00375 //intersection point as line A's point A. 00376 //Yes, this is a little arbitratry. But 00377 //theoreticaly this section of code will almost 00378 //never be executed. 00379 if( p1.x() == p3.x() ) 00380 { return DPoint( p1.x(), p1.y() ); } 00381 //Else lines will never intersect, 00382 //return pair (-32000,-32000) 00383 else 00384 { return DPoint( -32000, -32000 ); } 00385 } 00386 //---------------------------------------------- 00387 //Else, we know at least one of the lines 00388 //does NOT have a slope of infinity!!! 00389 //---------------------------------------------- 00390 00391 //---------------------------------------------- 00392 //=== Case 2: line A has no change in X === 00393 //---------------------------------------------- 00394 //If line A has an infinite slope (no change in x) 00395 //we know line B does not have an infinite slope... 00396 else if( p1.x() == p2.x() ) 00397 { 00398 double slopeB = ((double) (p4.y() - p3.y()) ) / (p4.x() - p3.x()); 00399 00400 double yInterceptB = p3.y() - slopeB*p3.x(); 00401 00402 //y = mx+b 00403 return DPoint( p2.x(), slopeB*p2.x() + yInterceptB ); 00404 } 00405 //---------------------------------------------- 00406 //=== Case 3: line B has no change in X === 00407 //---------------------------------------------- 00408 //If line B has an infinite slope (no change in x) 00409 //we know line A does not have an infinite slope... 00410 else if( p4.x() == p3.x() ) 00411 { 00412 double slopeA = ((double) (p2.y() - p1.y()) ) / (p2.x() - p1.x()); 00413 00414 double yInterceptA = p1.y() - slopeA*p1.x(); 00415 00416 //y = mx+b 00417 return DPoint( p4.x(), slopeA*p4.x() + yInterceptA ); 00418 } 00419 //---------------------------------------------- 00420 //=== Case 4: both lines have non infinite slopes === 00421 //---------------------------------------------- 00422 else 00423 { 00424 double slopeA = ((double) (p2.y() - p1.y()) ) / (p2.x() - p1.x()); 00425 double slopeB = ((double) (p4.y() - p3.y()) ) / (p4.x() - p3.x()); 00426 double yInterceptA = p1.y() - slopeA*p1.x(); 00427 double yInterceptB = p3.y() - slopeB*p3.x(); 00428 00429 //y1 = mx1+b 00430 //y2 = nx2+c 00431 //at intersection y1=y2 and x1 = x2 so... 00432 //mx +b = nx + c 00433 //x(m-n) = c-b 00434 //x = (c-b)/(m-n) 00435 //where m and n are slope and 00436 //b and c are y-intercepts. 00437 //x = (c-b)/(m-n) 00438 double x = (yInterceptB - yInterceptA) / (slopeA - slopeB); 00439 return DPoint( x, (slopeA * x) + yInterceptA ); 00440 } 00441 }
|
|
Definition at line 308 of file tilt.cpp. References blendColors(). Referenced by correctImageTilt(). 00310 { 00311 //do boundary checking to 00312 //ensure we don't read beyond image boundaries 00313 if(xp < 0 || xp >= image->width() || 00314 yp < 0 || yp >= image->height() ) 00315 return qRgb( 0, 0, 0 ); 00316 00317 //get four pixel colors, 00318 int x = (int)xp; 00319 int y = (int)yp; 00320 00321 uchar* scanLine1 = image->scanLine( y ); 00322 00323 uchar* scanLine2; 00324 if( y < image->height() - 1 ) 00325 scanLine2 = image->scanLine( y+1 ); 00326 else 00327 scanLine2 = scanLine1; 00328 00329 QRgb p1,p2,p3,p4; 00330 00331 p1 = *((QRgb*)scanLine1+x); 00332 p3 = *((QRgb*)scanLine2+x); 00333 00334 if( x < image->width() - 1) 00335 { 00336 p2 = *((QRgb*)scanLine1+x+1); 00337 p4 = *((QRgb*)scanLine2+x+1); 00338 } 00339 else 00340 { 00341 p2 = p1; 00342 p4 = p3; 00343 } 00344 00345 //blend four colors 00346 double alphaY = yp - y; 00347 double alphaX = xp - x; 00348 00349 p1 = blendColors( p1, p2, alphaX ); 00350 p3 = blendColors( p3, p4, alphaX ); 00351 p1 = blendColors( p1, p3, alphaY ); 00352 return p1; 00353 }
|