May-09-2019, 12:06 PM
Hello everyone
Despite some help on this forum I am still struggling with np.where
Can someone help solve my problem?
I have a numpy array derived from an image which is 1024 x 1024 x 4 in size. eg [10,11,0] is the red attribute of the pixel located at x axis 11 y axis 10 (yes its reversed).
Lets assume that my array has various values all less than 253 in all the array except for the locations 10,11 and 23,24 and 83,89. I want to use np.where to find the locations of pixels where [x,y,0]>252.
How can I do this using np.where ?
The output I want to generate is a list of positions i.e [[10,11], [23,24],[83,89]} so it may be necessary to convert tuple into a list and then swap the x and y axis.
I have tried using
Thanks Peter
Despite some help on this forum I am still struggling with np.where
Can someone help solve my problem?
I have a numpy array derived from an image which is 1024 x 1024 x 4 in size. eg [10,11,0] is the red attribute of the pixel located at x axis 11 y axis 10 (yes its reversed).
Lets assume that my array has various values all less than 253 in all the array except for the locations 10,11 and 23,24 and 83,89. I want to use np.where to find the locations of pixels where [x,y,0]>252.
How can I do this using np.where ?
The output I want to generate is a list of positions i.e [[10,11], [23,24],[83,89]} so it may be necessary to convert tuple into a list and then swap the x and y axis.
I have tried using
new_list = img[np.where(img[:, :][0] >252)]I get the following error
Output:TypeError: 'builtin_function_or_method' object is not subscriptable
but this is not working for me.Thanks Peter