Beispiel #1
0
    def test_dpmm(self):
        arr = np.arange(42).reshape(6, 7)
        ai = ArrayImage(arr)

        self.assertIsNone(ai.dpi)

        ai2 = ArrayImage(arr, dpi=20)
        self.assertEqual(ai2.dpi, 20)
        self.assertEqual(ai2.dpmm, 20/25.4)
Beispiel #2
0
    def test_dpmm(self):
        arr = np.arange(42).reshape(6, 7)
        ai = ArrayImage(arr)
        # errors if not passed in
        with self.assertRaises(AttributeError):
            ai.dpi

        ai2 = ArrayImage(arr, dpi=20)
        self.assertEqual(ai2.dpi, 20)
        self.assertEqual(ai2.dpmm, 20 / 25.4)
Beispiel #3
0
    def _getThresholdMask(self, img, proz):
        """ Eine Bildmaske erstellen
        
        img : image.array
        proz : [ min, max]
        """

        min_value, max_value = np.percentile(img, proz)
        threshold_value = (max_value - min_value) / 2 + min_value
        array = np.where(img >= threshold_value, 1, 0)
        threshold_img = ArrayImage(array)
        return threshold_img
Beispiel #4
0
    distTA_pixels = ref_image.dpmm * distTA

    # construct image gradient using sobel filter
    img_x = spf.sobel(ref_img.as_type(np.float32), 1)
    img_y = spf.sobel(ref_img.as_type(np.float32), 0)
    img_z = spf.sobel(ref_img.as_type(np.float32), 2)
    grad_img = np.sqrt(img_x**2 + img_y**2 + img_z**2)

    # equation: (measurement - reference) / sqrt ( doseTA^2 + distTA^2 * image_gradient^2 )
    subtracted_img = np.abs(comp_img - ref_img)
    denominator = np.sqrt((doseTA / 100.0**2) + ((distTA_pixels**2) *
                                                 (grad_img**2)))
    gamma_map = subtracted_img / denominator

    return gamma_map


test_array = np.zeros((5, 5, 5))
test_array[2, 2, 2] = 5
test_img = ArrayImage(test_array, dpi=1)

ref_array = np.zeros((5, 5, 5))
ref_array[2, 2, 2] = 1
ref_image = ArrayImage(ref_array, dpi=1)

gamma_map = gamma3d(ref_image, test_img, threshold=0)

# max gamma value
print(np.max(gamma_map))
print(np.mean(gamma_map))