join_objects.py
1 |
#!/usr/bin/python
|
---|---|
2 |
import sys, os, datetime |
3 |
import os |
4 |
import numpy as np |
5 |
import h5py # |
6 |
#matplotlib.use('Agg')
|
7 |
from matplotlib.pylab import * |
8 |
import matplotlib.pyplot as plt |
9 |
from mpl_toolkits.basemap import Basemap |
10 |
from scipy import * |
11 |
from scipy import fftpack |
12 |
from scipy import ndimage |
13 |
from scipy import optimize |
14 |
from optparse import OptionParser |
15 |
from gnuradio.eng_option import eng_option |
16 |
##import beacon_conf as c #Archivo de Configuracion
|
17 |
import time |
18 |
|
19 |
|
20 |
a=np.zeros((10,10)) |
21 |
for i in range(3,len(a)): |
22 |
for j in range(0,len(a)-3): |
23 |
if j==i-3: |
24 |
a[i][j]=1
|
25 |
if j==i-2: |
26 |
a[i][j]=1
|
27 |
if j==i:
|
28 |
a[i][j]=1
|
29 |
if j==i+1: |
30 |
a[i][j]=1
|
31 |
|
32 |
a[4][5]=0 |
33 |
|
34 |
|
35 |
lbl=ndimage.label(a)[0]
|
36 |
slice_x, slice_y = ndimage.find_objects(lbl==2)[0] |
37 |
roi = lbl[slice_x, slice_y] |
38 |
plt.imshow(roi) |
39 |
|
40 |
print lbl
|
41 |
print roi
|