Home > Software design >  numpy array with inequality sign?
numpy array with inequality sign?

Time:11-08

mask = np.stack([robject_mask, rshadow_mask, mask], axis=1).astype('float')   
   
    mask[mask >= 128] = 255
    mask[mask < 128] = 0

i'm practicing making attention network with pytorch, and i have a question in the code. i think it's about normalizing images to [-1,1], but i cannot understand what it exactly means. anyone know what is this operation's name? what does it mean? or maybe giving me a keyword that i can search?

CodePudding user response:

You're question is not clear, but I'll try explaining what's going on.

mask >= 128

Will output an array of the form of [True, True, False, ...] each true correspond to an index where mask had a value greater than 127.

Then mask[mask >= 128] means any index of mask where the inner array had true in it. Same goes for < 128 just the opposite.

In the end of the proccess, mask will contain either 255 or 0 in each index, depending if the value prior to it was greater than 128 or not.

  • Related