コード例 #1
0
ファイル: rescale.py プロジェクト: tjacek/res_ensemble
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)
コード例 #2
0
ファイル: tools.py プロジェクト: tjacek/preproc
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)
コード例 #3
0
ファイル: tools.py プロジェクト: tjacek/preproc
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: motion.py プロジェクト: tjacek/res_ensemble
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)
コード例 #6
0
ファイル: auto.py プロジェクト: tjacek/res_ensemble
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)
コード例 #7
0
ファイル: sampling.py プロジェクト: tjacek/res_ensemble
def sample_imgs(in_path,out_path):
    imgs.transform(in_path,out_path,sample_seq)
コード例 #8
0
def raw_projection(in_path, out_path, dim=0):
    helper = get_helper(dim)
    imgs.transform(in_path, out_path, helper, False)
コード例 #9
0
def smooth_frames(in_path, out_path):
    fun = [gauss_helper, scale]
    imgs.transform(in_path, out_path, gauss_helper, single_frame=True)
コード例 #10
0
def scaled_frames(in_path, out_path):
    imgs.transform(in_path, out_path, scale, single_frame=True)
コード例 #11
0
ファイル: balanced.py プロジェクト: tjacek/preproc
def box_frame(in_path, out_path):
    fun = [balanced_frames]
    imgs.transform(in_path, out_path, fun, single_frame=False)
コード例 #12
0
def rescale_imgs(in_path, out_path):
    imgs.transform(in_path, out_path, norm_z, single_frame=False)
コード例 #13
0
def box_frame(in_path, out_path):
    fun = [equal_box]  #[extract_box]
    imgs.transform(in_path, out_path, fun, single_frame=False)
コード例 #14
0
ファイル: box.py プロジェクト: tjacek/res_ensemble
def box_frame(in_path, out_path):
    imgs.transform(in_path, out_path, extract_box, single_frame=False)
コード例 #15
0
ファイル: tools.py プロジェクト: tjacek/preproc
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)
コード例 #16
0
ファイル: rescale.py プロジェクト: tjacek/res_ensemble
def rescale(in_path, out_path, dim_x=64, dim_y=64):
    imgs.transform(in_path, out_path, scale, single_frame=True)
コード例 #17
0
        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)
コード例 #18
0
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)
コード例 #19
0
def imgs_only(in_path, out_path):
    fun = imgs.Pipeline([center_pcloud, pclouds.to_img])
    imgs.transform(in_path, out_path, fun)