Reputation: 51
I'm new to Matlab. I have these simple lines. The problem is that the sum variable does not take negative values. All variables are double.
Inp_pixel = Inp_padded(x, y);
Filter_pixel = Filter(f_row, f_col);
sum = sum + (Inp_pixel * Filter_pixel);
for example: if Filter_pixel = -1 and Inp_pixel = 150 and sum = 0. the expected result should be -150 but I get sum = 0
Upvotes: 1
Views: 124
Reputation: 51
The problem was in Inp_pixel. This variable assigned from an uint8 2D array. that's why this variable didn't take the negative value of the multiplication. I used cast() function to solve this problem. for more details about this function please check this link. MATLAB documentation page
Upvotes: 1