Пример #1
0
    def grayfromIR(self):

        ir_filename = os.path.join(os.getcwd(), '..', 'data', self.ircube)

        spectral_cube, wavenumbers = read_spimage(ir_filename)

        ir_gray = emsc_b(spectral_cube, wavenumbers)

        ir_gray_im = ImagePil.fromarray(
            min_max_scaler(ir_gray, 0, 255).astype('uint8'))

        ir_gray_im = ImagePil.fromarray(
            min_max_scaler(standard_scaler(ir_gray), 0, 255).astype('uint8'))

        if save == True:

            ir_gray_im.save(os.path.join(os.getcwd(), '..', 'data',
                                         'ir_gray.png'),
                            compress_level=9)

        else:

            pass

        return ir_gray, ir_gray_im
Пример #2
0
 def write_results(self):
     img_sitk = blend_images(self.fixed_sitk, self.moving_sitk,
                             self.final_transform)
     PilImage.fromarray(
         min_max_scaler(
             standard_scaler(sitk.GetArrayViewFromImage(img_sitk)), 0,
             255).astype("uint8")).save(self.registration_path)
     self.final_transform.WriteTransform(self.transform_path)
Пример #3
0
    def grayfromHandE(self):

        he_filename = os.path.join(os.getcwd(), '..', 'data', self.he_image)

        he_image = ImagePil.open(he_filename)

        he_gray_im = ImagePil.fromarray(
            min_max_scaler(he_gray, 0, 255).astype('uint8'))

        he_gray_im.save(os.path.join(os.getcwd(), '..', 'data', 'he_gray.png'),
                        compress_level=9)

        return he_gray, he_gray_im
    def plot_values(self):
        self.metric_values.append(self.registration_method.GetMetricValue())

        if (self.registration_method.GetOptimizerIteration() % 10 !=
                0) or not self.debug:
            return

        # Clear the output area (wait=True, to reduce flickering), and plot current data
        clear_output(wait=True)
        # Plot the similarity metric values

        _, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 10))

        img_sitk = blend_images(self.fixed_sitk, self.moving_sitk,
                                self.final_transform)
        img = min_max_scaler(
            standard_scaler(sitk.GetArrayViewFromImage(img_sitk)), 0,
            255).astype("uint8")

        img = np.asarray(
            ImagePil.fromarray(img).resize(
                (img.shape[1] / 4, img.shape[0] / 4)))

        ax1.imshow(img)

        ax2.plot(self.metric_values, "r")
        ax2.plot(
            self.multires_iterations,
            [self.metric_values[index] for index in self.multires_iterations],
            "b*",
        )

        ax2.set_xlabel("Iteration Number", fontsize=12)
        ax2.set_ylabel("Metric Value", fontsize=12)

        plt.show()
Пример #5
0
 def write(self, filename):
     ImagePil.fromarray(min_max_scaler(self.data, 0,
                                       255).astype("uint8")).save(filename)