Die seite weicht am stärksten von allen ab und laut vielen anderen seiten ist das mit dem hsv auch nicht so toll.
Hier mein vertikaler sobel:
Ich berechne vorher noch den maximalen und minimalen wert zur begrenzung.Code:void sobel_filtering2( ) /* Spatial filtering of image data */ /* Sobel filter (horizontal differentiation */ /* Input: image1[y][x] ---- Outout: image2[y][x] */ { /* Definition of Sobel filter in horizontal direction */ int weight[3][3] = { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 }}; int x_size2,y_size2; double pixel_value; double min, max; int x, y, i, j; /* Loop variable */ /* Maximum values calculation after filtering*/ printf("Now, filtering of input image is performed\n\n"); min = DBL_MAX; max = -DBL_MAX; for (y = 1; y < Y - 1; y++) { for (x = 1; x < X - 1; x++) { pixel_value = 0.0; for (j = -1; j <= 1; j++) { for (i = -1; i <= 1; i++) { pixel_value += weight[j + 1][i + 1] * picdatagrey[(x+i)+X*(y+j)];//image1[y + j][x + i]; } } if (pixel_value < min) min = pixel_value; if (pixel_value > max) max = pixel_value; } } if ((int)(max - min) == 0) { printf("Nothing exists!!!\n\n"); return ; } printf("max:%f\nmin:%f\n",max,min); /* Initialization of image2[y][x] */ x_size2 = X; y_size2 = Y; for (y = 0; y < y_size2; y++) { for (x = 0; x < x_size2; x++) { //image2[y][x] = 0; picdatafiltert[x+X*y]; } } /* Generation of image2 after linear transformtion */ for (y = 1; y < Y - 1; y++) { for (x = 1; x < X - 1; x++) { pixel_value = 0.0; for (j = -1; j <= 1; j++) { for (i = -1; i <= 1; i++) { pixel_value += weight[j + 1][i + 1] * picdatagrey[(x+i)+X*(y+j)];//image1[y + j][x + i]; } } //printf("sobel:%f\n",pixel_value); pixel_value = MAX_BRIGHTNESS * (pixel_value - min) / (max - min); picdatafiltert[x+X*y] = (unsigned char)pixel_value; } } }
Mein horizontaler sieht gleich aus, nur andere matrix
und das verbinden:
Was mich wundert, wieso die anderen das letzte kombinierte bild so toll schwarz kriegen mit nur den kanten. Bei mir sehen die so aus:Code:void verbinden() { for(int i=0;i<X*Y;i++) { picdatafiltert3[i]=sqrt(picdatafiltert2[i]*picdatafiltert2[i]+picdatafiltert[i]*picdatafiltert[i]); //picdatafiltert3[i]=(picdatafiltert2[i]+picdatafiltert[i])/2; } }
http://mitglied.lycos.de/b534463/vertikal.jpg
http://mitglied.lycos.de/b534463/horizontal.jpg
http://mitglied.lycos.de/b534463/beide.jpg
Von hier hab ich das beispiel:
http://de.wikipedia.org/wiki/Sobel







Zitieren

Lesezeichen