def time(in_path, out_path): def pairs(seq_i): return [ np.concatenate([seq_i[j], seq_i[j + 1]]) for j in range(len(seq_i) - 1) ] imgs.transform(in_path, out_path, pairs, single_frame=False)
def sigma_filtr(in_path, out_path): def helper(img_i): std_z = np.std(img_i) value_i = np.mean(img_i) + 0.5 * std_z print(value_i) img_i[img_i < value_i] = 0 return img_i imgs.transform(in_path, out_path, helper, True)
def time(in_path, out_path): def helper(frames): size = len(frames) return [ np.concatenate([frames[i - 1], frames[i]], axis=0) for i in range(1, size) ] transform = [proj.scale, helper] imgs.transform(in_path, out_path, transform, single_frame=False)
def projection(in_path, out_path): proj_x = get_projection(dim=0) proj_y = get_projection(dim=1) def full_projection(frames): x_frames = proj_x(frames) y_frames = proj_y(frames) return [ np.concatenate([proj_x, proj_y], axis=0) for proj_x, proj_y in zip(x_frames, y_frames) ] imgs.transform(in_path, out_path, full_projection, False)
def transform(in_path, out_path, type="diff"): single = True if (type == "diff"): fun = diff_helper single = False if (type == "motion"): fun = motion_helper single = False if (type == "canny"): fun = lambda img_i: cv2.Canny(img_i, 100, 200) if (type == "smooth"): fun = smooth if (type == "noise"): fun = lambda img_i: np.abs(img_i - smooth(img_i)) imgs.transform(in_path, out_path, fun, single)
def reconstruct(in_path, model_path, out_path=None, diff=False): model = load_model(model_path) if (not out_path): out_path = os.path.split(in_path)[0] + '/rec' def rec_helper(X): X = np.array(X) X = data.format_frames(X) pred = model.predict(X) if (diff): pred = np.abs(pred - X) pred = [np.vstack(frame_i.T) for frame_i in pred] return pred imgs.transform(in_path, out_path, rec_helper, False)
def sample_imgs(in_path,out_path): imgs.transform(in_path,out_path,sample_seq)
def raw_projection(in_path, out_path, dim=0): helper = get_helper(dim) imgs.transform(in_path, out_path, helper, False)
def smooth_frames(in_path, out_path): fun = [gauss_helper, scale] imgs.transform(in_path, out_path, gauss_helper, single_frame=True)
def scaled_frames(in_path, out_path): imgs.transform(in_path, out_path, scale, single_frame=True)
def box_frame(in_path, out_path): fun = [balanced_frames] imgs.transform(in_path, out_path, fun, single_frame=False)
def rescale_imgs(in_path, out_path): imgs.transform(in_path, out_path, norm_z, single_frame=False)
def box_frame(in_path, out_path): fun = [equal_box] #[extract_box] imgs.transform(in_path, out_path, fun, single_frame=False)
def box_frame(in_path, out_path): imgs.transform(in_path, out_path, extract_box, single_frame=False)
def rescale_imgs(in_path, out_path, dim_x=64, dim_y=128): rescale = proj.Scale(dim_x, dim_y) if (files.dict_of_dicts(in_path)): imgs.transform(in_path, out_path, rescale, True) else: imgs.transform_action_img(in_path, out_path, rescale)
def rescale(in_path, out_path, dim_x=64, dim_y=64): imgs.transform(in_path, out_path, scale, single_frame=True)
for point_i in points.T: if(point_i[0]>1.5*self.center[0]): dist=np.abs(point_i[0]-self.center[0]) dist/=self.center[0] delta=dist*self.scale if(point_i[1]<self.center[1]): point_i[1]-=delta else: point_i[1]+=delta return points def gap_agum(frames): frames=[ proj.nonzero_points(frame_i) for frame_i in frames] center=pclouds.center_of_mass(frames) # frames=[filtr_points(frame_i,1.5*center[0]) for frame_i in frames] helper=GapTransform(center,16.0) frames=[helper(frame_i) for frame_i in frames] frames=[ pclouds.to_img(frame_i) for frame_i in frames] return frames def filtr_points(points,threshold): new_points=[] for point_i in points.T: if(point_i[0]<threshold): new_points.append(point_i) return np.array(new_points).T if __name__ == "__main__": imgs.transform("../agum/box","test",gap_agum)
def outliner_img(in_path,out_path): fun=[tools.median_smooth,outliner, proj_center.center_norm, pclouds.to_img, proj.scale] imgs.transform(in_path,out_path,fun)
def imgs_only(in_path, out_path): fun = imgs.Pipeline([center_pcloud, pclouds.to_img]) imgs.transform(in_path, out_path, fun)