Home > Net >  how to filter an numpy.ndarray by a spevific number?
how to filter an numpy.ndarray by a spevific number?

Time:04-28

roi_pixel_img = crop_img[indices_list]
print (roi_pixel_img)

enter image description here

when i add (I use only to use the entire array (meaning only a part):

np.set_printoptions(threshold=sys.maxsize)

th output is:

enter image description here

the whole part happens in a while loop because I'm extracting pixels in this section, which is irrelevant to the question.

My goal is not to include the lines with [0 255 255] in this array, how can I do that?

the type of roi_pixel_img is numpy.ndarray.

is it even possible to answer this question without an example code for you ?

CodePudding user response:

You can do this by creating an indexing array:

r = (roi_pixel_img == [0,255,255]).all(axis = -1)

roi_pixel_img[~r]
  • Related