Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:32:49+00:00 2026-05-21T11:32:49+00:00

Several users have asked about the speed or memory consumption of image convolutions in

  • 0

Several users have asked about the speed or memory consumption of image convolutions in numpy or scipy [1, 2, 3, 4]. From the responses and my experience using Numpy, I believe this may be a major shortcoming of numpy compared to Matlab or IDL.

None of the answers so far have addressed the overall question, so here it is: “What is the fastest method for computing a 2D convolution in Python?” Common python modules are fair game: numpy, scipy, and PIL (others?). For the sake of a challenging comparison, I’d like to propose the following rules:

  1. Input matrices are 2048×2048 and 32×32, respectively.
  2. Single or double precision floating point are both acceptable.
  3. Time spent converting your input matrix to the appropriate format doesn’t count — just the convolution step.
  4. Replacing the input matrix with your output is acceptable (does any python library support that?)
  5. Direct DLL calls to common C libraries are alright — lapack or scalapack
  6. PyCUDA is right out. It’s not fair to use your custom GPU hardware.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:32:50+00:00Added an answer on May 21, 2026 at 11:32 am

    It really depends on what you want to do… A lot of the time, you don’t need a fully generic (read: slower) 2D convolution… (i.e. If the filter is separable, you use two 1D convolutions instead… This is why the various scipy.ndimage.gaussian, scipy.ndimage.uniform, are much faster than the same thing implemented as a generic n-D convolutions.)

    At any rate, as a point of comparison:

    t = timeit.timeit(stmt='ndimage.convolve(x, y, output=x)', number=1,
    setup="""
    import numpy as np
    from scipy import ndimage
    x = np.random.random((2048, 2048)).astype(np.float32)
    y = np.random.random((32, 32)).astype(np.float32)
    """)
    print t
    

    This takes 6.9 sec on my machine…

    Compare this with fftconvolve

    t = timeit.timeit(stmt="signal.fftconvolve(x, y, mode='same')", number=1,
    setup="""
    import numpy as np
    from scipy import signal
    x = np.random.random((2048, 2048)).astype(np.float32)
    y = np.random.random((32, 32)).astype(np.float32)
    """)
    print t
    

    This takes about 10.8 secs. However, with different input sizes, using fft’s to do a convolution can be considerably faster (Though I can’t seem to come up with a good example, at the moment…).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really sorry, I realize there have been several questions asked about cocos2d touch
Several variations of this question have been asked, and I've definitely learned from reading
Several of our users have asked us to include data relative to their account
So I have this game database, where I have several users with fields, id,
I have a query that might be executed by several users consecutively. I'm scared
I release several modifications a week for my Windows Services and my users have
I have users that have several objects and can upload images for those objects.
I have several sites where users can send me email through an html form
I have several textboxes where users can enter information into them. This can include
I have several workflows where the users want to set the number of days

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.