MATLAB: Following is the error occured during thresholding

thresholding

Following is the error occured in my code. please, can you help me for sorting out this error.
Error using .* Integers can only be combined with integers of the same class, or scalar doubles.
Error in thresholding (line 13) thix1=max(ix,level1.*ones(size(ix)));

Best Answer

Try this:
hix1 = max(ix, uint8(level1).*ones(size(ix), 'uint8'));
or this:
hix1 = uint8(max(double(ix), level1.*ones(size(ix))));