Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Mon Nov 15 23:17:20 2010
- @author: myname
- """
- def findMinBoundBox( img ):
- "Given a binary image of 0's and 1's, this function finds the minimum box\
- which encapsulates all 1's in the image.\
- Input is a 2D binary numpy.ndarray\
- Output is coordinats in input frame coordinateset, organized as:\
- (left, upper, right, lower)"
- xmin=1000;
- xmax=0;
- ymin=1000;
- ymax=0;
- for i in range(0,img.shape[0]):
- for j in range(0,img.shape[1]):
- if(tstImg[i,j]):
- if(xmin>i):xmin=i;
- if(xmax<i):xmax=i;
- if(ymin>j):ymin=j;
- if(ymax<j):ymax=j;
- return [(ymin,xmin,ymax,xmax)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement