| |
 |
|
|
Science Forum Index » Image Processing Forum » Image Convolution and Gibbs Effect
Page 1 of 1
|
| Author |
Message |
| Leotrisport |
Posted: Tue Jan 02, 2007 7:44 am |
|
|
|
Guest
|
Hi , I`m new in image processing and I having some problems with Image
Convolution with and without FFT2D.
First I`m used to work with 1d Convolution (ie:Audio) and my only
concern with convolution was "circular convolution" for example if I
convolve a signal (N=256) with a filter kernel (M=32 nonzeros), I need
to pad with zeros the signal with 32 samples so the signal would be
(N=288) so I could easly convolve the signal and just use the 256
samples from response.
Just some weeks ago I`m start to convert a Matlab code to C code where
it would run in a FPGA (PowerPC) processor, and I saw in the source
code in Matlab that before convolution the guy made an operation called
mirror to minimize the Gibbs effect.
This is just another name for "Circular convolution"? What operation I
need to make before do a convolution in Image processing? (Using FFT or
normal convolution)? |
|
|
| Back to top |
|
| Marco Al |
Posted: Tue Jan 02, 2007 10:04 am |
|
|
|
Guest
|
Leotrisport wrote:
Quote: First I`m used to work with 1d Convolution (ie:Audio) and my only
concern with convolution was "circular convolution" for example if I
convolve a signal (N=256) with a filter kernel (M=32 nonzeros), I need
to pad with zeros the signal with 32 samples so the signal would be
(N=288) so I could easly convolve the signal and just use the 256
samples from response.
You can do that, but the hard drop to zero at the edges introduces high
frequency components you don't want (ringing at the edges, similar to
gibbs effect). Hell you could just as well save yourself the trouble of
padding, whether you borrow frequency components from the start of
create them from the drop to zero doesn't really matter. They are both
unwanted. It's simply easier to notice in images than in audio.
Correct mirroring (point symmetrical) avoids the effect.
Marco |
|
|
| Back to top |
|
| Leotrisport |
Posted: Tue Jan 02, 2007 11:37 am |
|
|
|
Guest
|
And what the mirroring does? It repeats the image in the boundaries?
How much samples I should extend from the original image? I mean if I
convolve an Image 256x256 with a kernel 128x128 How much mirroring I
should do? and after the convolution I will need to crop x samples from
the boundaries in the result image?
Marco Al escreveu:
Quote: Leotrisport wrote:
First I`m used to work with 1d Convolution (ie:Audio) and my only
concern with convolution was "circular convolution" for example if I
convolve a signal (N=256) with a filter kernel (M=32 nonzeros), I need
to pad with zeros the signal with 32 samples so the signal would be
(N=288) so I could easly convolve the signal and just use the 256
samples from response.
You can do that, but the hard drop to zero at the edges introduces high
frequency components you don't want (ringing at the edges, similar to
gibbs effect). Hell you could just as well save yourself the trouble of
padding, whether you borrow frequency components from the start of
create them from the drop to zero doesn't really matter. They are both
unwanted. It's simply easier to notice in images than in audio.
Correct mirroring (point symmetrical) avoids the effect.
Marco |
|
|
| Back to top |
|
| Marco Al |
Posted: Tue Jan 02, 2007 12:31 pm |
|
|
|
Guest
|
Leotrisport wrote:
Quote: And what the mirroring does? It repeats the image in the boundaries?
The pixels inside the image are mirrored to outside the image, so for
instance the pixel at (-1,-1) in original image coordinates is set to
the value of pixel at (+1,+1).
An alternative is point symmetrical extension, where the pixel at
(-1,-1) is set to 2*(0,0)-(1,1).
Quote: How much samples I should extend from the original image? I mean if I
convolve an Image 256x256 with a kernel 128x128 How much mirroring I
should do?
127 pixels in theory is enough in theory, but in practice you will use
128. So your image would become 512x512.
Quote: and after the convolution I will need to crop x samples from
the boundaries in the result image?
Indeed.
Marco
PS. I am talking about true boundaries here BTW. Not boundaries you
introduce so you can use smaller FFTs for overlap save convolution. |
|
|
| Back to top |
|
| Martin Leese |
Posted: Tue Jan 02, 2007 7:22 pm |
|
|
|
Guest
|
Leotrisport wrote:
Quote: Hi , I`m new in image processing and I having some problems with Image
Convolution with and without FFT2D.
First I`m used to work with 1d Convolution (ie:Audio) and my only
concern with convolution was "circular convolution" for example if I
convolve a signal (N=256) with a filter kernel (M=32 nonzeros), I need
to pad with zeros the signal with 32 samples so the signal would be
(N=288) so I could easly convolve the signal and just use the 256
samples from response.
Just some weeks ago I`m start to convert a Matlab code to C code where
it would run in a FPGA (PowerPC) processor, and I saw in the source
code in Matlab that before convolution the guy made an operation called
mirror to minimize the Gibbs effect.
This is just another name for "Circular convolution"? What operation I
need to make before do a convolution in Image processing? (Using FFT or
normal convolution)?
You can do convolution either in the frequency
domain (where it becomes simple multiplication)
or in the space domain.
Gibbs phenomenon is an artifact associated with
Fourier transforms, so is confined to the former.
Mirroring the data in the space domain is done
to prevent edge effects. These artifacts only
appear at the edges of the image, unlike the
ringing of Gibbs phenomenon which can appear all
over the image.
There are several alternatives to mirroring in
the space domain. You can replicate the edge
pixel, or pad with pixels with the same
statistical properties as the edge pixels. Note
that all such techniques, including mirroring,
are wrong. (They can, however, be extremely
useful.) Their purpose is to suppress artifacts;
they cannot eliminate them.
Whether convolution is faster in the frequency
domain or the space domain depends on the sizes
of the image and convolution kernel. You might
find these previous threads in this newsgroup
helpful:
http://groups.google.ca/group/sci.image.processing/browse_frm/thread/dfa0cf646e0121ea/8a48e5b8a9e88d85?lnk=st&q=&rnum=23&hl=en#8a48e5b8a9e88d85
http://groups.google.ca/group/sci.image.processing/browse_frm/thread/42a74f75ec6ea636/dd601995272eb9de?lnk=st&q=&rnum=16&hl=en#dd601995272eb9de
http://groups.google.ca/group/comp.graphics.algorithms/browse_frm/thread/7bb5ba14ecacd807/c934cc04700511ad?lnk=st&q=&rnum=12&hl=en#c934cc04700511ad
--
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/ |
|
|
| Back to top |
|
| aruzinsky |
Posted: Wed Jan 03, 2007 12:20 pm |
|
|
|
Guest
|
"There are several alternatives to mirroring in
the space domain. You can replicate the edge
pixel, or pad with pixels with the same
statistical properties as the edge pixels. Note
that all such techniques, including mirroring,
are wrong. (They can, however, be extremely
useful.) Their purpose is to suppress artifacts;
they cannot eliminate them."
Another alternative that works artistically well with PSF (all
non-negative and sum equal to one) kernels is to discard (effectively set
to zero) the weights that fall outside the image border and re-normalize
the weights that fall inside the image borders. This also works
artistically well with binary masks of arbitrary shape, e.g, to simulate
bokeh. |
|
|
| Back to top |
|
| |
|
Page 1 of 1
All times are GMT - 5 Hours
The time now is Fri Nov 21, 2008 7:31 pm
|
|