示例#1
0
 def fun_rcdt_single(self, I):
     # I: (width, height)
     radoncdt = RadonCDT(self.thetas)
     Ircdt = radoncdt.forward(x0_range,
                              self.template / np.sum(self.template),
                              x_range, I / np.sum(I), self.rm_edge)
     return Ircdt
示例#2
0
 def fun_rcdt_single(self, I):
     # I: (rows, columns)
     radoncdt = RadonCDT(self.thetas)
     template = np.ones(I.shape, dtype=I.dtype)
     Ircdt = radoncdt.forward(x0_range, template / np.sum(template),
                              x_range, I / np.sum(I), self.rm_edge)
     return Ircdt
示例#3
0
 def forward_seq(self, X, template):
     self.template = template
     radoncdt = RadonCDT(self.thetas)
     x_hat = []
     for i in range(X.shape[0]):
         x_hat.append(
             radoncdt.forward(x0_range,
                              self.template / np.sum(self.template),
                              x_range, X[i, :] / np.sum(X[i, :]),
                              self.rm_edge))
     return np.asarray(x_hat)
示例#4
0
input_size = int(sys.argv[1])

eps = 1e-6
x0_range = [0, 1]
x_range = [0, 1]
Rdown = 4  # downsample radon projections (w.r.t. angles)
theta = np.linspace(0, 176, 180 // Rdown)
radoncdt = RadonCDT(theta)

I = np.random.rand(input_size, input_size)
template = np.ones(I.shape, dtype=I.dtype)

high.start_counters([
    events.PAPI_FP_OPS,
])
rcdt = radoncdt.forward(x0_range, template / np.sum(template), x_range,
                        I / np.sum(I), False)
print(high.stop_counters()[0] / 1e9)


def discrete_radon_transform(image, steps):
    R = np.zeros((steps, image.shape[0]), dtype=np.float32)
    for s in range(steps):
        rotation = rotate(image, -s * 180 / steps).astype(np.float32)
        R[s] = np.sum(rotation, axis=1)
    return R


I = np.random.rand(input_size, input_size)
high.start_counters([
    events.PAPI_FP_OPS,
])