Commit a55d83d5 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[core][mapping] Add functions for computing rsm and magnification axes transformations

parent 31386782
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "27/05/2021"
__date__ = "04/06/2021"
import numpy
try:
......@@ -148,3 +148,25 @@ def compute_moments(values, data):
kurt = kurtosis(stack, axis=0)
return com, std, skews, kurt
def compute_rsm(H, W, d, ffz, mainx):
pix_arr = numpy.meshgrid(numpy.arange(H), numpy.arange(W))
pix_arr[0] = (pix_arr[0] - W / 2) * d
pix_arr[1] = (H / 2 - pix_arr[1]) * d
pix_arr[0] = numpy.arctan2((ffz - W / 2) * pix_arr[0], mainx)
pix_arr[1] = numpy.arctan2(pix_arr[1], numpy.sqrt(ffz * ffz + mainx * mainx))
return pix_arr
def compute_magnification(H, W, d, obx, obpitch, mainx):
pix_arr = numpy.meshgrid(numpy.arange(H), numpy.arange(W))
d1 = obx / numpy.cos(obpitch)
d2 = mainx / numpy.cos(obpitch) - d1
M = d2 / d1
d /= M
pix_arr[0] = (pix_arr[0] - W / 2) * d
pix_arr[1] = (H / 2 - pix_arr[1]) * d
return pix_arr
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment