Assume for example the following image matrix:
>> Img = [-2, -1, 0, 1, 2];
You could set all negative elements to zero:
>> ImgZeros = Img;
>> ImgZeros(Img<0) = 0
ImgZeros =
0 0 0 1 2
Or any other value useful to you, e.g. NaN
:
>> ImgNans = Img;
>> ImgNans(Img<0) = nan
ImgNans =
NaN NaN 0 1 2
You could 'shift' all the values up such that the lowest negative value becomes zero:
>> ImgZeroFloor = Img - min(Img(:))
ImgZeroFloor =
0 1 2 3 4
You could convert the whole thing to a grayscale image in the range (0,1):
>> ImgGray = mat2gray(Img)
ImgGray =
0 0.2500 0.5000 0.7500 1.0000
etc.
As to why you're getting negative values, who knows. It's problem specific. (If I had to guess for MRI I would say it's due to numerical inaccuracy during the conversion process from an MRI signal to pixel intensities.)