opencv gaussian edge color

109 views Asked by At

I'm trying create a gaussian blur, but i have color line and i don't know why. Maybe i have an error in my get of set pixel?

My kernel is good.

I have this result: picture (sorry i can't post directly the picture).

void Filter::gaussian(IplImage * img){
    IplImage * old = cvCloneImage(img);
    int rayon = this->gaussianKernel.rows/2;

    for(int x = rayon; x < img->width - rayon; x++) {
        for(int y= rayon; y < img->height - rayon; y++) {
           Filter::applyKernel3D(img, old,  this->gaussianKernel,Point(y, x));
        }
    }
}


void Filter::applyKernel3D(IplImage * img, IplImage * old, const Mat &kernel, const Point &p){
float sommeR =0, sommeG=0, sommeB=0;
float diviseur = 1;

//oX, oY point en haut à gauche du kernel sur l'image
//(i,j) coordonnées sur le kernel
//(ii, jj) coordonnées sur l'image
int oX = p.x-(kernel.rows/2);
int oY = p.y-(kernel.cols/2);
int ii, jj;
int wii;
float valK= 0 ; //coef du kernel

for(int i = 0; i < kernel.rows; i++) {
    ii= i + oX;

    wii = old->widthStep * ii;
    for(int j= 0; j < kernel.cols; j++) {
        jj= j + oY;
        valK = kernel.at<float>(i, j);

        sommeB += valK * old->imageData[wii + jj * 3 ];
        sommeG += valK * old->imageData[wii + jj * 3 +1];
        sommeR += valK * old->imageData[wii + jj * 3 +2];
    }
}

img->imageData[p.x * img->widthStep + p.y * 3 ]   = sommeB;
img->imageData[p.x * img->widthStep + p.y * 3 + 1] = sommeG;
img->imageData[p.x * img->widthStep + p.y * 3 + 2] = sommeR;
0

There are 0 answers