コード例 #1
0
ファイル: datasets.py プロジェクト: guoyii/Resul
    def __getitem__(self, idx):
        if self.Dataset_name is "train":
            image, image_origin = self.imgset[idx]
        else:
            image, image_name, image_origin = self.imgset[idx]
        # print("Image max {} min {} mean {}".format(np.array(image).max(), np.array(image).min(), np.array(image).mean()))
        sinogram_full = self.project(image, self.proj_id_full)
        sinogram_sparse = sparse_view_f(sinogram_full,
                                        self.geo_full["sino_views"],
                                        self.geo_sparse["sino_views"])
        sinogram_inter = my_map_coordinates(
            sinogram_sparse,
            (self.geo_full["sino_views"], self.geo_full["nDetecU"]),
            order=3)

        image_full = self.fbp(sinogram_full, self.proj_id_full,
                              self.proj_geom_full, self.vol_geom_full)
        image_sparse = self.fbp(sinogram_sparse, self.proj_id_sparse,
                                self.proj_geom_sparse, self.vol_geom_sparse)
        image_inter = self.fbp(sinogram_inter, self.proj_id_full,
                               self.proj_geom_full, self.vol_geom_full)

        sample = {
            "image_full": image_full,
            "image_true": image,
            "image_origin": image_origin,
            "image_sparse": image_sparse,
            "image_inter": image_inter,
            "sinogram_sparse": sinogram_sparse,
            "sinogram_full": sinogram_full
        }
        return sample
コード例 #2
0
ファイル: datasets.py プロジェクト: guoyii/UnetDa
    def __getitem__(self, idx):
        if self.Dataset_name is "train":
            image= self.imgset[idx]
        else:
            image, image_name = self.imgset[idx]
        
        sinogram_full = self.project(image, self.proj_id_full)
        sinogram_sparse = sparse_view_f(sinogram_full, self.geo_full["sino_views"], self.geo_sparse["sino_views"])

        image_full = self.fbp(sinogram_full, self.proj_id_full, self.proj_geom_full, self.vol_geom_full)
        image_sparse = self.fbp(sinogram_sparse, self.proj_id_sparse, self.proj_geom_sparse, self.vol_geom_sparse)


        if self.Dataset_name is "train":
            sample = {"image_full": torch.from_numpy(image_full).unsqueeze_(0),
                    "image_true": image,
                    "image_sparse": torch.from_numpy(image_sparse).unsqueeze_(0),
                    "image_res": torch.from_numpy(image_full - image_sparse).unsqueeze_(0)}
        else:
            sample = {"image_full": torch.from_numpy(image_full).unsqueeze_(0), 
                    "image_true": image,
                    "image_sparse": torch.from_numpy(image_sparse).unsqueeze_(0),
                    "image_res": torch.from_numpy(image_full - image_sparse).unsqueeze_(0),
                    "image_name":image_name}
        return sample
コード例 #3
0
ファイル: datasets.py プロジェクト: guoyii/TradDa
 def __getitem__(self, idx):
     image, image_name = self.imgset[idx]
     
     sinogram_full = self.project(image, self.proj_id)
     sinogram_sparse = sparse_view_f(sinogram_full, self.geo_full["sino_views"], self.geo_sparse["sino_views"])
     sinogram_inter = my_map_coordinates(sinogram_sparse, (self.geo_full["sino_views"], self.geo_full["nDetecU"]), order=1)
     
     return image, sinogram_full, sinogram_sparse, sinogram_inter, image_name
コード例 #4
0
ファイル: datasets.py プロジェクト: guoyii/IterDa
    def __getitem__(self, idx):
        if self.Dataset_name is "train":
            image = self.imgset[idx]
        else:
            image, image_name = self.imgset[idx]

        # print("Image max {} min {} mean {}".format(np.array(image).max(), np.array(image).min(), np.array(image).mean()))
        sinogram_full = self.project(image, self.proj_id_full)
        sinogram_sparse = sparse_view_f(sinogram_full,
                                        self.geo_full["sino_views"],
                                        self.geo_sparse["sino_views"])
        # sinogram_inter = my_map_coordinates(sinogram_sparse, (self.geo_full["sino_views"], self.geo_full["nDetecU"]), order=1)
        # sinogram_inter = my_extension(sinogram_sparse, (self.geo_full["sino_views"], self.geo_full["nDetecU"]))

        image_full = self.fbp(sinogram_full, self.proj_id_full,
                              self.proj_geom_full, self.vol_geom_full)
        image_sparse_0 = self.fbp(sinogram_sparse, self.proj_id_sparse,
                                  self.proj_geom_sparse, self.vol_geom_sparse)

        image_i1_pred = self.pred_sample(image_sparse_0, self.model_i1)
        sinogram_i1_pred = self.project(image_i1_pred, self.proj_id_full)
        sinogram_new = self.updata_sinogram(sinogram_sparse, sinogram_i1_pred)
        image_sparse_1 = self.fbp(sinogram_new, self.proj_id_full,
                                  self.proj_geom_full, self.vol_geom_full)

        image_i2_pred = self.pred_sample(image_sparse_1, self.model_i2)
        sinogram_i2_pred = self.project(image_i2_pred, self.proj_id_full)
        sinogram_new = self.updata_sinogram(sinogram_sparse, sinogram_i2_pred)
        image_sparse_2 = self.fbp(sinogram_new, self.proj_id_full,
                                  self.proj_geom_full, self.vol_geom_full)

        image_i3_pred = self.pred_sample(image_sparse_2, self.model_i3)
        sinogram_i3_pred = self.project(image_i3_pred, self.proj_id_full)
        sinogram_new = self.updata_sinogram(sinogram_sparse, sinogram_i3_pred)
        image_sparse_3 = self.fbp(sinogram_new, self.proj_id_full,
                                  self.proj_geom_full, self.vol_geom_full)

        if self.Dataset_name is "train":
            sample = {
                "image_full": torch.from_numpy(image_full).unsqueeze_(0),
                "image_true": image,
                "image_sparse_0": image_sparse_0,
                "image_sparse_1": image_sparse_1,
                "image_sparse_2": image_sparse_2,
                "image_sparse": torch.from_numpy(image_sparse_3).unsqueeze_(0)
            }
        else:
            sample = {
                "image_full": torch.from_numpy(image_full).unsqueeze_(0),
                "image_true": image,
                "image_sparse_0": image_sparse_0,
                "image_sparse_1": image_sparse_1,
                "image_sparse_2": image_sparse_2,
                "image_sparse": torch.from_numpy(image_sparse_3).unsqueeze_(0),
                "image_name": image_name
            }
        return sample