How do I create a Boolean matrix with a corresponding index condition in Python?

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

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273