Пример #1
0
    def holo_complex_transform(self):
        # Transform X_train and X_test using hologram filtering.
        (X_train, y_train), (X_test, y_test) = self.Org

        print('Performing complex hologram transformation...')
        sim = recon.Simulator(X_train.shape[1:])

        def holo(X_train):
            X_train_holo_abs_l = []
            X_train_holo_ang_l = []
            for x in X_train:
                X_train_h = sim.diffract_full(x)
                X_train_holo_abs_l.append(np.abs(X_train_h))
                X_train_holo_ang_l.append(np.angle(X_train_h))
            X_train_holo = np.zeros(
                (X_train.shape[0], 2, X_train.shape[1], X_train.shape[2]))
            X_train_holo[:, 0, :, :] = np.array(X_train_holo_abs_l)
            X_train_holo[:, 1, :, :] = np.array(X_train_holo_ang_l)
            return X_train_holo

        X_train_holo = holo(X_train)
        X_test_holo = holo(X_test)

        self.Data = (X_train_holo, y_train), (X_test_holo, y_test)
        self.Holo_complex = self.Data
        self.complex_flag = True
Пример #2
0
    def _holo_transform_r0(self):
        # Transform X_train and X_test using hologram filtering.
        (X_train, y_train), (X_test, y_test) = self.Org

        print('Performing hologram transformation...')
        sim = recon.Simulator(X_train.shape[1:])
        X_train_holo = np.array([sim.diffract(x) for x in X_train])
        X_test_holo = np.array([sim.diffract(x) for x in X_test])

        self.Data = (X_train_holo, y_train), (X_test_holo, y_test)
        self.Holo = self.Data
Пример #3
0
def holo_transform(Org):
    # Transform X_train and X_test using hologram filtering.
    (X_train, dump_train), (X_test, dump_test) = Org

    print('Performing hologram transformation...')
    sim = recon.Simulator(X_train.shape[1:])
    X_train_holo = np.array([sim.diffract(x) for x in X_train])
    X_test_holo = np.array([sim.diffract(x) for x in X_test])

    Data = (X_train_holo, dump_train), (X_test_holo, dump_test)
    return Data
Пример #4
0
def recon_transform(Holo):
    """
    One-shot Recon with Hologram Image
    """
    (X_train_holo, dump_train), (X_test_holo, dump_test) = Holo

    print('Performing first-shot recon...')
    sim = recon.Simulator(X_train_holo.shape[1:])
    X_train_recon = np.array(
        [np.abs(sim.reconstruct(x)) for x in X_train_holo])
    X_test_recon = np.array([np.abs(sim.reconstruct(x)) for x in X_test_holo])

    Data = (X_train_recon, dump_train), (X_test_recon, dump_test)
    return Data
Пример #5
0
    def _recon_transform_r0(self):
        if not hasattr(self, 'Holo'):
            self.holo_transform()

        (X_train_holo, y_train), (X_test_holo, y_test) = self.Holo

        print('Performing first-shot recon...')
        sim = recon.Simulator(X_train_holo.shape[1:])
        X_train_recon = np.array(
            [np.abs(sim.reconstruct(x)) for x in X_train_holo])
        X_test_recon = np.array(
            [np.abs(sim.reconstruct(x)) for x in X_test_holo])

        self.Data = (X_train_recon, y_train), (X_test_recon, y_test)
        self.Recon = self.Data
Пример #6
0
def holo_complex_transform(Org):
    (X_train, y_train), (X_test, y_test) = Org

    print('Performing complex hologram transformation...')
    sim = recon.Simulator(X_train.shape[1:])

    def holo(X_train):
        X_train_holo_abs_l = []
        X_train_holo_ang_l = []
        for x in X_train:
            X_train_h = sim.diffract_full(x)
            X_train_holo_abs_l.append(np.abs(X_train_h))
            X_train_holo_ang_l.append(np.angle(X_train_h))
        X_train_holo = np.zeros(
            (X_train.shape[0], 2, X_train.shape[1], X_train.shape[2]))
        X_train_holo[:, 0, :, :] = np.array(X_train_holo_abs_l)
        X_train_holo[:, 1, :, :] = np.array(X_train_holo_ang_l)
        return X_train_holo

    X_train_holo = holo(X_train)
    X_test_holo = holo(X_test)

    Data = (X_train_holo, y_train), (X_test_holo, y_test)
    return Data