Reputation: 265
I have a question. How can I set null value into 0 on an image. Is there any way to do this in matlab. The image type is float-point, 32 bit, tif format. Null value (Nodata) of this image is -3.4028234663e+038. So the number is out of range of float-point. So I wanna replace those values with 0.
Upvotes: 1
Views: 301
Reputation: 32930
Generally speaking, you can find all the elements to replace by:
idx = (I == x); % # x is the "null" value
where I
is your image and x
is the desired value to replace (in your case, that is the "null" value). However, a more practical syntax would be using a certain threshold value instead of the exact value:
idx = (I > y); % # y is a value much lower than x
Now idx
holds the logical indices of the elements you want to zero out. After you obtain idx
, just do:
I(idx) = 0;
P.S
In practice, you can do achieve the same result without creating a temporary variable idx
, like so:
I(I > y) = 0;
Upvotes: 1