Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python numpy bbox

def bbox1(img):
    a = np.where(img != 0)
    bbox = np.min(a[0]), np.max(a[0]), np.min(a[1]), np.max(a[1])
    return bbox

def bbox2(img):
    rows = np.any(img, axis=1)
    cols = np.any(img, axis=0)
    rmin, rmax = np.where(rows)[0][[0, -1]]
    cmin, cmax = np.where(cols)[0][[0, -1]]

    return rmin, rmax, cmin, cmax
Comment

PREVIOUS NEXT
Code Example
Python :: pbcopy stands for 
Python :: Can the string find method be used to search a list? 
Python :: python open file partially 
Python :: context manager requests python 
Python :: using a print function 
Python :: not mutable data type in python 
Python :: check entries smaller 0 after groupby 
Python :: pvector python processing 
Python :: plt force axis numbers 
Python :: how to convert 2 dimensional in 1 dimensional array 
Python :: python turtle documentation 
Python :: function to sort a list of points based on their x and y-coordinates 
Python :: pd datetime 
Python :: serialization in python 
Python :: python remove warnings 
Python :: requests encoding python 
Python :: extract list from string python 
Python :: how to add a key in python dictionary 
Python :: dataframe 
Python :: the range() function 
Python :: getting the number of missing values in pandas 
Python :: python serial port 
Python :: if statements python 
Python :: python loop dictionary 
Python :: camel case to snake case python 
Python :: python run system commands 
Python :: python chatbot api 
Python :: how to do the sum of list in python 
Python :: django template filter 
Python :: python function return function 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =