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 6477199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:55:09+00:00 2026-05-25T06:55:09+00:00

My platform is Mac OS X 10.6 and install python 2.7.2/opencv by homebrew. I

  • 0

My platform is Mac OS X 10.6 and install python 2.7.2/opencv by homebrew.
I want to use cv.filter2D to do Lanczos resampling, here is my code:

import cv

src = cv.imread('img.jpg')
dst = cv.CloneMat(src)
kernel = cv.CreateMat(7, 7, cv.CV_32FC1)

for i in range(-3, 4):
    for j in range(-3, 4):
        kernel[i+3, j+3] = L(i, 3) * L(j, 3)

cv.filter2D(src, dst, kernel)
cv.imshow(dst)

My problem is cv.filter2D.
If I use

cv.filter2D(src, dst, kernel) 

, which wrote in OpenCV Reference Manual, it will get error message.

Traceback (most recent call last):
  File "lanczos.py", line 27, in <module>
    cv.filter2D(src, dst, kernel)
TypeError: only length-1 arrays can be converted to Python scalars

Under python I type

cv.filter2D.__doc__

, it said the function prototype is

'filter2D(src, ddepth, kernel[, dst[, anchor[, delta[, borderType]]]]) -> dst'

if I use

cv.filter2D(src, -1, kernel, dst)

instead, the error message become

Traceback (most recent call last):
  File "lanczos.py", line 27, in <module>
    cv.filter2D(src, 1 , kernel, dst)
TypeError: <unknown> is not a numpy array

seems no people encounter this problem before?

  • 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-25T06:55:10+00:00Added an answer on May 25, 2026 at 6:55 am

    what is the version of your opencv, my version is:

    >>> import cv2 as cv
    >>> cv.__version__
    '$Rev: 4557 $'
    

    I can use a ndarray as the kernel, and don’t need to create an empty array for the result, filter2D() will return a new ndarray.

    import cv2 as cv
    import numpy as np
    src = cv.imread('img.jpg')
    kernel = np.ones((7,7), dtype=np.float)/49.0
    dst = cv.filter2D(src, -1, kernel)
    cv.imwrite("result.jpg", dst)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How could I programmatically install a font on the Mac platform (Snow Leopard)? What
I'm writing some cross-platform code between Windows and Mac. If list::end() "returns an iterator
I'm writing cross platform C++ code (Windows, Mac). Is there a way to check
I am looking to write some C# code for linux/windows/mac/any other platform, and am
I'm trying to install matplotlib for graphing applications in Python on Mac OS X.
I was able to install and use IBM DB2 Express-C 9.5.2. beta in Mac
I need a cross platform method of determining the MAC address of a computer
How do I find out what platform SCons is building for (Linux, Mac OS
platform: django 1.0, google app engine, app-engine-patch , python 2.5.4 i am tring to
When considering a platform for a game, I've decided on multi-platform (Win/Lin/Mac) but can't

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.