So I'm using Keras generator to get data augmented for image segmentation
I have a specific mask which each set of pixel represent a region of my masks, so I must have a range of pixel that contains 11 classes (0 and 255 and 191).
The problem with Keras generator that he is changing the range of pixel.
so I want to detect images that pixel intensity are not equal to my specific classes (pixel range) (255,56,...) and try to delete them from my dataset but im always getting errors.
Y_train : numpy array that contains all the masks
Y_train = array([[[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]],
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]]], dtype=uint8)
I tried this 1st attempt :
for i in range(len(Y_train)):
if Y_train[i] != 255 and Y_train[i] !=56 and Y_train[i] !=137 and Y_train[i] !=26 :
print ('index',i)
Second one :
for i in range (len(Y_train)):
if Y_train[i][Y_train[i] != (0 and 255 and 56 and 137 and 26 and 87 and 112 and 191 and 212 and 164 and 229 and 244 )] :
print('index 0',i)
Third one :
for i in range(len(Y_train)):
if (Y_train[I] != 255 and Y_train[i] !=56 and Y_train[i] !=137)).all() : print('index 0',i)
PS : Sorry for my English
if
andand
only work with scalar True/False values. YourY_train
tests are boolean arrays - check them yourself.