How to exclude NaN values from evaluation on raster data

I have a raster which have NaN values. I would like to evaluate graythresh for my data, but the NaN values are taken into account and as a results I have 0 (zero). Is there a way to exclude NaN values from evaluation or remove them from data?

 Accepted Answer

x_no_nans = x(~isnan(x))

4 Comments

... and then graythresh(x_no_nans). graythresh() does not care what order the data is in.
I have one more question, if the implementation of Otsu method in matlab is sensitive for very small values? I have one dataset with values between 0-1, but the majority of values is smaller than 0.004, so evaluated threshold is 0. The threshold is visible on image, but the algorithm cannot find it, and I think it is due to very small values.
What is EM, the effectiveness metric output? Otsu is not great for all images, it's really only for when there is an object in the foreground.
I have two datasets where the threshold is zero. EM is for these data: 0.9862, and 0.5902

Sign in to comment.

More Answers (0)

Asked:

on 5 Aug 2015

Edited:

on 7 Aug 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!