Re: 2-D Convolutions in IDL w/o zero-padded edges [message #56391] |
Wed, 24 October 2007 01:56 |
Tal
Messages: 26 Registered: August 2007
|
Junior Member |
|
|
>> Is there a way in IDL to convolve an image with a kernal and return only those parts of the convolution that are computed without zero-padded edges?
Yes. i think so.
if
b is the result
a is the source image
k is the kernel
s is the scale factor (for example: total(k))
then
b = convol(a,k,s,/edge_truncate)
should produce what you want and will not pad the edges with zeros.
hope this helps,
Tal
|
|
|
Re: 2-D Convolutions in IDL w/o zero-padded edges [message #56396 is a reply to message #56391] |
Tue, 23 October 2007 14:50  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
Matt Harner wrote:
> Hello.
>
> I am familiar with IDL and convolutions independently but not
> together. Is there a way in IDL to convolve an image with a kernal
> and return only those parts of the convolution that are computed
> without zero-padded edges? This would be equivalent to the MATLAB
> procedure conv2(image,kernel, 'valid').
>
> Thanks in advance for any help.
> Matt
Maybe you could compute the convolution over the whole area, then keep
only the valid entries... so if your kernel is a 3*3 one, you would do
GoodResults = AllResult[1:Xsize-2; 1:Ysize-2]
If you are using a kernel that is not a square, I have a function to
reduce your study area so that every pixel has a complete neighborhood
(you define the neighborhood by its coordinates as if it was centered on
cell 0;0)
Jean
|
|
|