1

I'm trying to implement an "LOG blob detector" using python and openCV. the idea is to create 10-15 levels of LOG filters, apply each of them to my original gray scale image and save the images in an array of size height x width x numOfLevels and then find the local maximums on the 3D array.

The problem is I'm not sure how to save these in an array.

I tried to do the following:

myImage = cv2.imread('butterfly.jpg')
gray_image = cv2.cvtColor(myImage, cv2.COLOR_BGR2GRAY)
sigma = 2
k = 2**(0.25)
std2 = float(sigma**2)
arr = []
for i in range(10):
    filt_size =  2*np.ceil(3*sigma)+1
    H = log_filt( filt_size, sigma)
    H *= sigma**2
    dst = cv2.filter2D(gray_image,-1,H)
    arr.append(dst)
    cv2.imshow('Gray', dst)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    sigma = sigma * k
    std2 = float(sigma**2)
    plt.imshow(H,interpolation='nearest')

But then if I try to take on the of the images and use cv2.imshow(arr[0]) I get the following error:

TypeError: Required argument 'mat' (pos 2) not found

What am I doing wrong here?

Is there a better way to save these in an array?

Maybe using np.array somehow?

1
  • Please always include the full error traceback, not just the error message. Commented Nov 7, 2015 at 16:18

1 Answer 1

3

Your error:

cv2.imshow(arr[0]) I get the following error: TypeError: Required argument 'mat' (pos 2) not found

Is because you pass the image (arr[0]) as first parameter, but you should pass it as second:

cv2.imshow('WindowName', arr[0])

See the OpenCV 2.4 and 3.0 documentation of imshow:

cv2.imshow(winname, mat)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.