2017-06-23 2 views
0

Ich wollte fragen, wo ich finden kann, wie die GaussianBlur-Funktion in OpenCV implementiert ist. Beim Durchsehen des Quellcodes konnte ich nur diese file finden, aber ich suche nach dem Code, wo die Faltung gemacht wird. Z. B etwas wie folgt aus:Wie funktioniert die GaussianBlur -Funktion in OpenCV

for x to picture.rows 
    for y to picture.cols 
     for r to mask.width 
     for c to mask.cols 
      do convolution 

Hat der OpenCV Weichzeichnen der Faltung für jedes Pixel oder so etwas wie jedes zweite Pixel berechnet es zu beschleunigen?

+0

Die Implementierung enthält bestimmte Details aus dem Computer-Vision-Bereich, die so beim Thema kann nicht sein. –

Antwort

-1

Unten sind einige Links, wo der Gaussian Filter implementiert wurde Ich hoffe, es hilft Ihnen.

Beispielcode -

int main(int argc, char** argv) 
{ 
    //create 2 empty windows 
    namedWindow("Original Image" , CV_WINDOW_AUTOSIZE); 
    namedWindow("Smoothed Image" , CV_WINDOW_AUTOSIZE); 

    // Load an image from file 
    Mat src = imread("MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED); 

    //show the loaded image 
    imshow("Original Image", src); 

    Mat dst; 
    char zBuffer[35]; 

    for (int i = 1; i < 31; i = i + 2) 
    { 
     //copy the text to the "zBuffer" 
     _snprintf_s(zBuffer, 35,"Kernel Size : %d x %d", i, i); 

     //smooth the image using Gaussian kernel in the "src" and save it to "dst" 
     GaussianBlur(src, dst, Size(i, i), 0, 0); 

     //put the text in the "zBuffer" to the "dst" image 
     putText(dst, zBuffer, Point(src.cols/4, src.rows/8), CV_FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255), 2); 

     //show the blurred image with the text 
     imshow("Smoothed Image", dst); 

     //wait for 2 seconds 
     int c = waitKey(2000); 

     //if the "esc" key is pressed during the wait, return 
     if (c == 27) 
     { 
      return 0; 
     } 
    } 

    //make the "dst" image, black 
    dst = Mat::zeros(src.size(), src.type()); 

    //copy the text to the "zBuffer" 
    _snprintf_s(zBuffer, 35,"Press Any Key to Exit"); 

    //put the text in the "zBuffer" to the "dst" image 
    putText(dst, zBuffer, Point(src.cols/4, src.rows/2), CV_FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255)); 

    //show the black image with the text 
    imshow("Smoothed Image", dst); 

    //wait for a key press infinitely 
    waitKey(0); 

    return 0; 
} 

Links-

Link 1

Link2

+0

Während die Links die Frage beantworten könnten, ziehen Sie bitte in Betracht, die relevanten Inhalte von ihnen in die Antwort zu kopieren. –

+0

hinzugefügt den Beispielcode wie vorgeschlagen –

+0

Dies ist nicht die Implementierung des Gauß-Filters ... es ist nur einige Code, der es verwendet. – Miki