Skip to content
Advertisement

Combining various image channels after gaussian filtering produces white image

I am trying to implement a gaussian filter for an image with dimensions (256, 320, 4).

I first generated a gaussian Kernel for the same and then individually perform the convolution on each of the 4 channel, i.e on all the 256*320 greyscale images. After performing this I wish to combine the image into a coloured image.

However, when I do this it does not seem to work as expected. The expectation is to see a blurred version of the original image with the blurring depending on the value of sigma. However, when I run the code, I simply get a white image, no blurring nothing.

JavaScript

To test the function out, a helper function is called >

JavaScript
JavaScript

OutputImage from code

Advertisement

Answer

It seems all problem is that you get images in float64 but matplot needs uint8 to display it.

imageio saves it in file as correct images but with warning "Lossy conversion from float64 to uint8"

Both problem can resolve converting to uint8

JavaScript

Full working code with few small changes

  • I removed dstack
  • I needed size = output.shape[:2] and final_output[:size[0],:size[1],i] = output[:,:]
JavaScript

Original image Lenna from Wikipedia

enter image description here

Result:

enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement