 Timestamp:
 May 25, 2009, 2:16:26 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpipi/trunk/pipi/analysis/measure.c
r3342 r3517 34 34 double ret = 0.0; 35 35 float *p1, *p2; 36 int x, y, w, h ;36 int x, y, w, h, gray; 37 37 38 38 w = i1>w < i2>w ? i1>w : i2>w; … … 42 42 f2 = i2>last_modified; 43 43 44 gray = f1 == PIPI_PIXELS_Y_F32 && f2 == PIPI_PIXELS_Y_F32; 45 44 46 /* FIXME: this is not right */ 45 pipi_get_pixels(i1, PIPI_PIXELS_Y_F32); 46 pipi_get_pixels(i2, PIPI_PIXELS_Y_F32); 47 if(gray) 48 { 49 p1 = (float *)i1>p[PIPI_PIXELS_Y_F32].pixels; 50 p2 = (float *)i2>p[PIPI_PIXELS_Y_F32].pixels; 51 } 52 else 53 { 54 pipi_get_pixels(i1, PIPI_PIXELS_RGBA_F32); 55 pipi_get_pixels(i2, PIPI_PIXELS_RGBA_F32); 56 p1 = (float *)i1>p[PIPI_PIXELS_RGBA_F32].pixels; 57 p2 = (float *)i2>p[PIPI_PIXELS_RGBA_F32].pixels; 58 } 47 59 48 p1 = (float *)i1>p[PIPI_PIXELS_Y_F32].pixels; 49 p2 = (float *)i2>p[PIPI_PIXELS_Y_F32].pixels; 60 if(gray) 61 { 62 for(y = 0; y < h; y++) 63 for(x = 0; x < w; x++) 64 { 65 float a = p1[y * i1>w + x]; 66 float b = p2[y * i2>w + x]; 67 ret += (a  b) * (a  b); 68 } 69 } 70 else 71 { 72 for(y = 0; y < h; y++) 73 for(x = 0; x < w; x++) 74 { 75 float a, b, sum = 0.0; 50 76 51 for(y = 0; y < h; y++) 52 for(x = 0; x < w; x++) 53 { 54 float a = p1[y * i1>w + x]; 55 float b = p2[y * i2>w + x]; 56 ret += (a  b) * (a  b); 57 } 77 a = p1[(y * i1>w + x) * 4]; 78 b = p2[(y * i2>w + x) * 4]; 79 sum += (a  b) * (a  b); 80 81 a = p1[(y * i1>w + x) * 4 + 1]; 82 b = p2[(y * i2>w + x) * 4 + 1]; 83 sum += (a  b) * (a  b); 84 85 a = p1[(y * i1>w + x) * 4 + 2]; 86 b = p2[(y * i2>w + x) * 4 + 2]; 87 sum += (a  b) * (a  b); 88 89 ret += sum / 3; 90 } 91 } 58 92 59 93 /* TODO: free pixels if they were allocated */
Note: See TracChangeset
for help on using the changeset viewer.