Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Nov 15 23:17:20 2010
  4.  
  5. @author: myname
  6. """
  7.  
  8. def findMinBoundBox( img ):
  9.    "Given a binary image of 0's and 1's, this function finds the minimum box\
  10.    which encapsulates all 1's in the image.\
  11.    Input is a 2D binary numpy.ndarray\
  12.    Output is coordinats in input frame coordinateset, organized as:\
  13.    (left, upper, right, lower)"
  14.     xmin=1000;
  15.     xmax=0;
  16.     ymin=1000;
  17.     ymax=0;
  18.     for i in range(0,img.shape[0]):
  19.         for j in range(0,img.shape[1]):
  20.             if(tstImg[i,j]):
  21.                 if(xmin>i):xmin=i;
  22.                 if(xmax<i):xmax=i;
  23.                 if(ymin>j):ymin=j;
  24.                 if(ymax<j):ymax=j;
  25.    return [(ymin,xmin,ymax,xmax)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement