0

How should I approach the problem of removing negative pixels from MRI slices (or any image)?

Also, it would really help if someone can briefly explain why they occur.

I have read many online references especially those on MATLAB forum, but they seem to have diverse reasons as to why they occur.

Sorry, I don't have a code to post, since I am figuring out my approach yet.

3 Answers3

0

An MRI slice is presumably for us here nothing but an image, which is also nothing but a matrix. Since a matrix representing an image have only positive values, 'a negative pixel' also, presumably, mean the pixels having a value lower than a certain threshold. Let's have such a scenario: load clown loads a matrix X to your workspace representing a clown image, to see it first do imagesc(X);colormap(gray);. If you want to cut out some values lower than a threshold, you can do:

threshold=10;
newValue=0; 
X(find(X>threshold))=newValue;
imagesc(X)
colormap(gray) 
0

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.)

Tasos Papastylianou
  • 21,371
  • 2
  • 28
  • 57
0

Another way to limit your values is to use a sigmoid function

https://en.wikipedia.org/wiki/Sigmoid_function

It can be scaled so that all answers range from 0 to 255 And it can be used to limit the spikes in raw data balance. Its often used in neural networks.

Peter
  • 2,043
  • 1
  • 21
  • 45