Search code examples
imagematlabmode

How to calculate the mode of an image in matlab


I have an image which already apply a mask, what I need is to get mode image, but because of the mask image obviously mode is the zero of the mask, which require is to omit those zeros and only get mode image of the retina.

enter image description here

I tried to find function, it returns me different from zero but then I get confused when wanting to recover those different values of zeros and make an order and thus find mode.

Someone who has a better option?


Solution

  • As you said, you can extract only the non-zero values and compute the mode. This should do the work:

    mode(myimage(myimage ~=0))
    

    Hope it helps.