Beispiel #1
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')
Beispiel #2
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);
    
Beispiel #4
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)
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);
    

#%%

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)
Beispiel #7
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]));

  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")
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)