4
$\begingroup$

I have probably a very simple question. When I convolve an (grayscale) image using some kernel I get some output. The original pixel can be only between 0 and 255. Is possible that the output of a convolution can be higher? Because we are creating feature map, which I understand is another image. Is the output only up to 255, do we scale it down or it does not matter?

Thanks.

$\endgroup$

2 Answers 2

3
$\begingroup$

It is possible. You may have values less than 0 or greater than 255. It will depend on the values in the kernel. If you want to display the convolution output properly you will need to scale it first. This process is referred to as 'normalization".

$\endgroup$
2
  • $\begingroup$ Thank you. So should I scale the output everytime or it does not matter if I don't need to visualize filters? $\endgroup$
    – Revs
    Jan 30, 2017 at 17:34
  • 3
    $\begingroup$ I would only scale it when visualizing it. $\endgroup$ Jan 30, 2017 at 17:40
1
$\begingroup$

As answered by @Brian O'Donnell, in order to display correctly the convolution result, you should normalize the output image. To normalize your output image you should do something like that:

min_pixel = image.min() 
max_pixel = image.max()
new_min = 0
new_max = 255
new_image = (image-min_pixel)*(new_max-new_min)/(max_pixel-min_pixel)+new_min   

Source: Wikipedia

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.