Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2016-02-06 02:04:04 -0600

Nbb gravatar image

Normalize image 0 - 255 for display

Hi, I am trying to create a gaussian kernel and then normalize it so I can display it because the values are all too small like to the power of negative something. i used the normalize function but im still getting a black screen. the minimum is supposed to be 0 and the max 255 and everything else is scale in between. my code is below. help thanks.

 int main() {

    Mat kernelX  = getGaussianKernel(49, 13);
    Mat kernelY  = getGaussianKernel(49, 13);
    Mat kernelXY = kernelX * kernelY.t();

    normalize(kernelXY, kernelXY, 0, 255);

    namedWindow("l", CV_WINDOW_NORMAL);
    imshow("l", kernelXY);
    waitKey(0);
}

Normalize image 0 - 255 for display

Hi, I am trying to create a gaussian kernel and then normalize it so I can display it because the values are all too small like to the power of negative something. i used the normalize function but im still getting a black screen. the minimum is supposed to be 0 and the max 255 and everything else is scale in between. my code is below. help thanks.

 int main() {

    Mat kernelX  = getGaussianKernel(49, 13);
    Mat kernelY  = getGaussianKernel(49, 13);
    Mat kernelXY = kernelX * kernelY.t();

    normalize(kernelXY, kernelXY, 0, 255);

    namedWindow("l", CV_WINDOW_NORMAL);
    imshow("l", kernelXY);
    waitKey(0);
}

this is what i got in matlab with code

gaussian = fspecial('gaussian', [49 49], 13);
colormap gray
imagesc(gaussian);

How can I get the same result in opencv ?

image description