image processing style (2D kernel) convolutions?

K

Kyler Laird

It appears that Numeric only supports 1D convolutions. I need to
apply a 2D kernel such as
0 1 0
1 -4 1
0 1 0
to an image. Is there such a capability in Python/Numeric? It
appears that numarray has convolve2d(), but I don't have it
available where I'm working.

(I could express the problem better but I have a feeling that
people who know the answer know exactly what I mean. Tell me if
that's not true.)

Thank you.

--kyler
 
J

Jeff Epler

Well, it seems that you could convolve each row of the input image with
each row of the kernel, with the rows offset from each other. Then sum
the 3 convolved rows to get the output row

I know this isn't the right notation, and doesn't deal with r-1 or r+1
being out of range..
for r in range(input_height):
output[r] = (convolve(input[r-1], filter[0])
+ convolve(input[r], filter[1])
+ convolve(input[r+1], filter[2])

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,969
Members
47,524
Latest member
ecomwebdesign

Latest Threads

Top