pdollar / toolbox

Piotr's Image & Video Matlab Toolbox
849 stars 500 forks source link

imresamplemex.cpp unintialized variable bug #13

Open JoeyZhu opened 8 years ago

JoeyZhu commented 8 years ago

resample output has wild big value in some case, due to use uninitialized variable in imresamplemex.cpp:

for(; y<hn; y++) { B0[ybs[y]] += C[yas[y]] * ywts[y];

should initialize B0 before use:

for(int i = 0; i < hb; i++) B0[i] = 0;
hardegg commented 8 years ago

Yes it's true. I'm not using matlab but a pure c++ compiling. Inside function "resample", I add a new line in the beginning and everything is ok now, otherwise it will generate very big value (>255 for a float type image ranging in [0, 255])

memset(B, 0, hb*wb*sizeof(T));

I guess it might be ok for matlab. Maybe before passing to function the variable will be initialized to zeros by default. However, in c++ it's not true.

Hope the author can fix this.

HamzaKhribi commented 7 years ago

I had the same issue on matlab and even though adding your tweaks it kept giving me the same big values. please can someone help me with this issue