By Viet Nguyen
I’m totally newbie in Python and i’m trying to create a 1280×720 BOOLEAN matrix which is TRUE when x-index and y-index are satisfied in conditions. Specifically, the black area is where i want all values is TRUE, others is FALSE.
This is the image geometry of the matrix
So far i did a code like this:
mask_mat = np.zeros((1280,720),np.bool) for i in np.arange(640,1220): for j in np.arange(0,360): if ((j > (-9/16*i + 690))&(j < (-9/16*i + 750))): mask_mat[i][j] = True;
But the loop take up so much time. So please help!
Source: Stack Overflow