Пример #1
0
  def __init__(self, pipeline, source, sink = None, title = 'ProcessViewer', scale = None, axis = None, invertY = True, **args):
    if isinstance(pipeline, pln.ProcessingStep) and not isinstance(pipeline, pln.Pipeline):
      pipeline = pln.Pipeline(pipeline);
    if not isinstance(pipeline, pln.Pipeline):
      raise RuntimeError('process expected to be a Pipeline');
    
    self.pipeline = pipeline;
    self.source = source;   
    
    if sink is None:
      sink = np.zeros_like(source);
    self.sink = sink;

    # buffer for intermediate results
    self.sources = [self.source];      
    for s in range(pipeline.nsteps-1):
      self.sources.append(np.zeros_like(source));
    self.sources.append(sink);
    
    ### Gui
    pg.QtGui.QWidget.__init__(self, **args)
    self.setWindowTitle(title);
    self.resize(1000,800);    
    
    self.layout = pg.QtGui.QGridLayout(self);
    self.layout.setContentsMargins(0,0,0,0)        
  
    self.tab = pg.QtGui.QTabWidget()
    self.tab.setTabPosition(pg.QtGui.QTabWidget.North)

    self.source_viewer = guidv.DataViewer(source = self.source, scale = scale, axis = axis, invertY = invertY);
    self.viewers = [self.source_viewer];
    self.tab.addTab(self.source_viewer, 'Source') 
    
    for i,p in enumerate(pipeline.steps):
      pv = ProcessViewer(process = p, source = self.sources[i], sink = self.sources[i+1], scale = scale, axis = axis, invertY = invertY);
      pv.parameter.paramSet.sigTreeStateChanged.disconnect(pv.updateParameter);
      pv.parameter.paramSet.sigTreeStateChanged.connect(partial(self.updateParameter, pid = i));
      self.tab.addTab(pv, p.name)
      self.viewers.append(pv);
    
    self.layout.addWidget(self.tab);
    
    self.show();
Пример #2
0
 def __init__(self, process, source, sink = None, title = None, scale = None, axis = None, invertY = True, **args):
   if not isinstance(process, pln.ProcessingStep):
     raise RuntimeError('process expected to be a ProcessingStep');
   
   self.process = process;
   self.source = source;   
   
   if sink is None:
     sink = np.zeros_like(source);
   self.sink = sink;
   
   ### Gui
   pg.QtGui.QWidget.__init__(self, **args)
   if title is None:
     title = process.name;
   if title is None:
     title = 'Process'
   self.setWindowTitle(title);
   self.resize(1000,800);    
   
   self.layout = pg.QtGui.QGridLayout(self);
   self.layout.setContentsMargins(0,0,0,0)        
 
   splitter = pg.QtGui.QSplitter();
   splitter.setOrientation(pg.QtCore.Qt.Horizontal)
   splitter.setSizes([50, self.width() - 50]);
   self.layout.addWidget(splitter);
   
   # parameter tree
   self.parameter = guipar.ParameterTree(name = process.name, parameter = process.parameter);
   splitter.addWidget(self.parameter);
   
   # dataviewer
   self.viewer = guidv.DataViewer(source = self.sink, scale = scale, axis = axis, invertY = invertY);    
   splitter.addWidget(self.viewer);
   
   splitter.setStretchFactor(0, 0);
   splitter.setStretchFactor(1, 1);
   
   self.parameter.paramSet.sigTreeStateChanged.connect(self.updateParameter);
   
   self.updateParameter();
   self.show();
Пример #3
0
roi = [slice(652319, 652637)]; # turn
#roi = [slice(586000, 600000)]; # no shape detection failure

images = data_images[roi];
shapes = data_shapes[roi];
shape_info = data_shape_info[roi];
nt = shapes.shape[0];

#%%


blur = np.zeros(images.shape);
for i in range(nt):
  blur[i] = cv2.GaussianBlur(images[i], ksize = (5,5), sigmaX = 0);
  
dv.plot(blur);



#%% head tail trajectories

head_tails = [];
for i in range(nt):
  center = shapes[i][0:2].T;
  head_tails.append(center[[0,-1]]);
head_tails = np.array(head_tails);
  
#%%
  
plt.figure(1); plt.clf();
plt.scatter(*(head_tails[:,0,:].T), color = 'red')
Пример #4
0
  def __init__(self, pipeline, source, sink = None, title = None, scale = None, axis = None, invertY = True,  **args):
    if isinstance(pipeline, pln.ProcessingStep) and not isinstance(pipeline, pln.Pipeline):
      pipeline = pln.Pipeline(pipeline);
    if not isinstance(pipeline, pln.Pipeline):
      raise RuntimeError('process expected to be a Pipeline');
    
    self.pipeline = pipeline;
    self.source = source;   
    
    if sink is None:
      sink = np.zeros_like(source);
    self.sink = sink;

    # buffer for intermediate results
    self.sources = [self.source];      
    for s in range(pipeline.nsteps-1):
      self.sources.append(np.zeros_like(source));
    self.sources.append(sink);
    
    ### Gui
    pg.QtGui.QWidget.__init__(self, **args)
    if title is None:
      title = pipeline.name;
    if title is None:
      title = 'Pipeline'
    self.setWindowTitle(title);
    self.resize(1000,800);    
    
    self.layout = pg.QtGui.QGridLayout(self);
    self.layout.setContentsMargins(0,0,0,0)        
  
    splitter = pg.QtGui.QSplitter();
    splitter.setOrientation(pg.QtCore.Qt.Horizontal)
    splitter.setSizes([50, self.width() - 50]);
    self.layout.addWidget(splitter);
    
    # parameter trees
    self.tab = pg.QtGui.QTabWidget()
    self.tab.setTabPosition(pg.QtGui.QTabWidget.North)
    
    # source tab
    param = guipar.ParameterTree(name = 'Source', parameter = dict());
    self.tab.addTab(param, 'Source');
    
    self.parameters = [];
    for i,p in enumerate(self.pipeline.steps):
      param = guipar.ParameterTree(name = p.name, parameter = p.parameter);
      param.paramSet.sigTreeStateChanged.connect(partial(self.updateParameter, pid = i));
      self.tab.addTab(param, p.name);
      self.parameters.append(param);
    
    splitter.addWidget(self.tab);
    
    # dataviewer
    self.viewer = guidv.DataViewer(source = self.source, scale = scale, axis = axis, invertY = invertY);    
    splitter.addWidget(self.viewer);
    
    splitter.setStretchFactor(0, 0);
    splitter.setStretchFactor(1, 1);
    
    self.tab.currentChanged.connect(self.updateView);    
    
    self.show();
Пример #5
0
r = perimeter / 2 / np.pi
a = np.pi * r**2

print a, area

#%% cureled

#%%

blur2 = np.zeros(turn2.shape)
for i in range(blur2.shape[0]):
    blur2[i] = cv2.GaussianBlur(np.asarray(turn2[i], dtype=float),
                                ksize=(5, 5),
                                sigmaX=0)

dv.plot(blur2)

#%%
plt.figure(7)
plt.clf()
for d in range(3):
    plt.subplot(1, 3, d + 1)
    plt.imshow(frame_color[:, :, d])

#%%

dv.plot(data_images.transpose([1, 2, 0]))

#%%

fids = range(500000, 500000+300);


ht = np.array([data_shape[f][:2,[0,-1]].T for f in fids])


plt.figure(16); plt.clf();
plt.scatter(ht[:,0,0], ht[:,0,1], c = 'r')
plt.scatter(ht[:,1,0], ht[:,1,1], c = 'b')

#%%

d = data_image[fids]

dv.plot(d.transpose([1,2,0]));


#%% draw contours on images and thenplot via dv

fids = [9];
fids = range(520000+400, 520000+800);
n = len(fids);
dc = np.zeros((n, data_image.shape[1],  data_image.shape[2]));
for i,f in enumerate(fids):
  img = np.asarray(data_image[f].copy(), dtype = 'float32');
  img = cv2.GaussianBlur(img, ksize = (3,3), sigmaX = 0);
  cnt = data_shape[f][:2].T;
  cnt = np.asarray(np.reshape(cnt, (cnt.shape[0], 1, cnt.shape[1])), dtype = int);
  dc[i] = cv2.polylines(img, [cnt], False, 255, 1);
    
Пример #7
0
data_meta_file = os.path.join(data_dir, data_name % (region_id, 'meta'))

data_shape_file = os.path.join(data_dir, data_name % (region_id, 'shapes'))

#%%

turn = np.load(os.path.join(data_dir, 'Tests/turn_000.npy'))

#dv.plot(turn)
data = -turn
blur = np.zeros(data.shape)

for i in range(data.shape[0]):
    blur[i] = cv2.GaussianBlur(data[i], ksize=(5, 5), sigmaX=0)

dv.plot(blur > 185)

#%%

data0 = blur * (blur > 185)
for i in range(data0.shape[0]):
    data0[i][data0[i] > 0] = i + 1

#%%

import vispy as vp
#from vispy import app, visuals, scene

# build visuals
GraphPlot3D = vp.scene.visuals.create_visual_node(vp.visuals.VolumeVisual)
Пример #8
0
fids = range(500000, 500000+300);


ht = np.array([data_shape[f][:2,[0,-1]].T for f in fids])


plt.figure(16); plt.clf();
plt.scatter(ht[:,0,0], ht[:,0,1], c = 'r')
plt.scatter(ht[:,1,0], ht[:,1,1], c = 'b')

#%%

d = data_image[fids]

dv.plot(d.transpose([1,2,0]));


#%% draw contours on images and thenplot via dv

fids = [9];
fids = range(520000+400, 520000+800);
n = len(fids);
dc = np.zeros((n, data_image.shape[1],  data_image.shape[2]));
for i,f in enumerate(fids):
  img = np.asarray(data_image[f].copy(), dtype = 'float32');
  img = cv2.GaussianBlur(img, ksize = (3,3), sigmaX = 0);
  cnt = data_shape[f][:2].T;
  cnt = np.asarray(np.reshape(cnt, (cnt.shape[0], 1, cnt.shape[1])), dtype = int);
  dc[i] = cv2.polylines(img, [cnt], False, 255, 1);
    
Пример #9
0

#%%

pmu.get_movie_from_frame(movie_files, failed_id[0], n_frames=n_frames)

#%% 

plt.figure(1); plt.clf();

plt.imshow(data_image[263332-37443])

#%%


dv.plot(data_image.transpose([2,1,0]))


#%% curled
263332-37520



#%% turns

i = 337714;
i = 109715;

turn = data_image[i-75:i+150];

dv.plot(turn)
Пример #10
0
n_frames = pmu.get_n_frames(movie_files)

#%%

pmu.get_movie_from_frame(movie_files, failed_id[0], n_frames=n_frames)

#%%

plt.figure(1)
plt.clf()

plt.imshow(data_image[263332 - 37443])

#%%

dv.plot(data_image.transpose([2, 1, 0]))

#%% curled
263332 - 37520

#%% turns

i = 337714
i = 109715

turn = data_image[i - 75:i + 150]

dv.plot(turn)

#%%

#%% cureled




#%%


blur2 = np.zeros(turn2.shape);
for i in range(blur2.shape[0]):
  blur2[i] = cv2.GaussianBlur(np.asarray(turn2[i], dtype = float), ksize = (5,5), sigmaX = 0);
  

dv.plot(blur2);




#%%
plt.figure(7); plt.clf();
for d in range(3):
  plt.subplot(1,3,d+1); plt.imshow(frame_color[:,:,d])


#%%

dv.plot(data_images.transpose([1,2,0]));

Пример #12
0
  d = cv2.GaussianBlur(np.asarray(data_image[i], dtype = 'float'), ksize= (3,3), sigmaX = 0);
  dz = d[75-w:75+w+1, 75-w:75+w+1].flatten();
  dz[dz < 135] = 135;
  dz[dz > 145] = 145;
  features[j] = np.dot(dz, project);


features = (features - np.mean(features, axis = 0));
features = (features / np.std(features, axis = 0));

print features.shape


#%%
 
dv.plot(features) 

#%%
import sklearn.manifold as sl;
n_components = 2;
metric = 'euclidean';
tsne = sl.TSNE(n_components=n_components, init = 'pca', random_state = 10, metric = metric)
Y = tsne.fit_transform(features)

#%%


fig = plt.figure(17);
plt.clf();
plt.scatter(Y[:,0], Y[:,1], c = range(len(Y[:,0])), cmap = plt.cm.Spectral);
plt.title("t-SNE")
Пример #13
0
data_shape_file = os.path.join(data_dir, data_name % (region_id, 'shapes'));



#%%

turn = np.load(os.path.join(data_dir, 'Tests/turn_000.npy'))

#dv.plot(turn)
data = -turn;
blur = np.zeros(data.shape);

for i in range(data.shape[0]):
  blur[i] = cv2.GaussianBlur(data[i], ksize = (5,5), sigmaX = 0);

dv.plot(blur>185)

#%%

data0 = blur * (blur>185);
for i in range(data0.shape[0]):
  data0[i][data0[i] > 0] = i +1;

#%%

import vispy as vp;
#from vispy import app, visuals, scene

# build visuals
GraphPlot3D = vp.scene.visuals.create_visual_node(vp.visuals.VolumeVisual)