image processing style (2D kernel) convolutions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kyler Laird

    image processing style (2D kernel) convolutions?

    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
  • Jeff Epler

    #2
    Re: image processing style (2D kernel) convolutions?

    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_hei ght):
    output[r] = (convolve(input[r-1], filter[0])
    + convolve(input[r], filter[1])
    + convolve(input[r+1], filter[2])

    Jeff

    Comment

    Working...