boris-kz / CogAlg

This project is a Computer Vision implementation of general hierarchical pattern discovery principles introduced in README
http://www.cognitivealgorithm.info
MIT License
91 stars 41 forks source link

Shouldn't it be np.empty(shape=(height, width)...), instead of (width, height)? #22

Closed Twenkid closed 4 years ago

Twenkid commented 5 years ago

Shouldn't (height, width) in In def comp_pixel(frame, p__): be (width, height)?

dert__ = np.empty(shape=(width, height, 4), dtype=int) # initialize dert__

The order of dimension declaration in numpy arrays?

According to the code in the initialization:

height, width = image.shape

And to code tests like this::

 w = 4; h = 2
>>> k = np.zeros(shape=(w,h,1), dtype=int)
>>> k
array([[[0],
        [0]],

       [[0],
        [0]],

       [[0],
        [0]],

       [[0],
        [0]]])
>>> k = np.zeros(shape=(h,w,1), dtype=int)
>>> k
array([[[0],
        [0],
        [0],
        [0]],

       [[0],
        [0],
        [0],
        [0]]])

https://github.com/boris-kz/CogAlg/blob/1ce8aa2c3e4bdcc0259ce2a8c6e83b6a1143a83e/frame_2D_alg/frame_blobs.py#L61

khanh93vn commented 5 years ago

Thanks for discovering it. I'll fix it.

Twenkid commented 5 years ago

NP! We should watch about it, it's a common potential mistake in OpenCV-Numpy projects.

boris-kz commented 5 years ago

Thanks Todor!

On Tue, Mar 19, 2019, 1:14 PM Todor Arnaudov notifications@github.com wrote:

NP! We should watch about it, it's common potential mistake in OpenCV-Numpy projects.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/boris-kz/CogAlg/issues/22#issuecomment-474475972, or mute the thread https://github.com/notifications/unsubscribe-auth/AUAXGcUaKxJsMiRZToU1hItMJKdH6-uHks5vYRrwgaJpZM4b72bW .