liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.08k stars 1.71k forks source link

why padding the image matrix divisible by 4 #171

Closed dodoma closed 8 years ago

dodoma commented 8 years ago

hi, liuliu

I notice that in ccv_memory.c

mat.step = (cols * CCV_GET_DATA_TYPE_SIZE(type) * CCV_GET_CHANNEL(type) + 3) & -4;

why should do this? for speed or scale reason?

It means if I use ccv_dense_matrix(200, 102, CCV_8U, data, 0) to get a new matrix, I should make sure the data also padded, How to confirm this if the data is a opencv Mat?

liuliu commented 8 years ago

most image processing functions, such as opencv padding to 4. You can set mat->step as well to enforce that rule in OpenCV.