Search code examples
arraysopencvnumpypixel

Get the next value from the minimum value in array


I have a image, it's a array. I want to get the value after minimum value, I wish you understand me because I dont speak english very well. The minimum value in a pixel of this image is -3.40282e+38. I want to know the value that is after -3.40282e+38.

it must be for example 0.3 0.4..

I tried with image.min() but it print -3.40282e+38 .. I need the next value of that.

also I tried

 minimo = img.min()
for i in range(rows):
 for j in range(cols):
     for k in img[i,j]:
          if k> minimo:
               print k.min()

but I got this error

 TypeError: 'numpy.float32' object is not iterable

Solution

  • You can do it like this:

    import numpy as np
    sorted_vec = np.unique(img.reshape(-1))
    second_smallest = sorted_vec[1]