Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gaussian Blur give images a black border on left and right side #7

Closed
nilsou opened this issue Jul 23, 2012 · 7 comments
Closed

Gaussian Blur give images a black border on left and right side #7

nilsou opened this issue Jul 23, 2012 · 7 comments
Assignees

Comments

@nilsou
Copy link

nilsou commented Jul 23, 2012

When applying a gaussian blurr to images, the returned image has two black bands on each side.

This must have something to do with difficulty to apply the filter at the edge of the image but I don't really know how to deal with it...

Any idea?

@nilsou
Copy link
Author

nilsou commented Jul 23, 2012

Oops just saw that there is another issue about that...

However, is there a way to have edge pixels averaged with transparent ones. instead of black ones?

@gdawg
Copy link
Owner

gdawg commented Jul 24, 2012

Yeah on the edges you end up with the average calculation being low because of the "missing" pixels off each side.

I get around this in one of my apps by cropping and slightly resizing the picture, it's been a while since I looked at this code in depth but I'll open it up and have a think about whether that could be done, might make for better results!

@jasonm23
Copy link

It should be optional for the core convolution engine, as there's no "right" answer, for example:

  1. you might want zero pixels at the edges
  2. or you might want to only process the pixels that are fully covered by the matrix (ignore those that slip off the edge.)
  3. or you might want to wrap around,
  4. or you might want to duplicate the edge pixels to provide cover for the real edge pixels.

... those are the usual strategies off the top of my head.

@gdawg
Copy link
Owner

gdawg commented Jan 30, 2013

Sorry I've been so slow getting back to this,

based on the way the Accelerate.Framework works I'm thinking the best option would be to duplicate the edge pixels prior to the convolution call then crop the resulting image back down to the original size.

I think anything else would result in extra vDSP calls (and associated data-type) shuffling which is a bit cumbersome, compilcated (and slow!)

I haven't been active on this in quite a while but might have cause to look into it again in the next few weeks.

TBC...

@ghost ghost assigned gdawg Jan 30, 2013
@k06a
Copy link

k06a commented Aug 20, 2013

This stills actual problem...

@beatboxerish
Copy link

This is still an actual problem

@gdawg
Copy link
Owner

gdawg commented Mar 18, 2023

Sorry this library is essentially abandoned at this point and I wouldn't recommend using it in new projects.

Apple's Core Image library provides similar functionality and be my choice if I were to look into this in 2023.

If for some reason you're stuck with this library it's worth noting (as @jasonm23 does above) that there is no one true correct solution to this problem. The algorithm combines each pixel with weighted values from it's neighbours therefore at the edges (where some neighbours are missing) it's simply not possible to calculate the correct value due to missing inputs.

Some workarounds you might want to consider are:

  • cropping the result
  • expanding the image, projecting the edge pixels outwards then cropping the result back to the original size

@gdawg gdawg closed this as completed Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants