[SciPy-User] Scaling up root-finding
Nathaniel Smith
njs at pobox.com
Wed Sep 4 16:45:04 EDT 2013
If you know the polynomial coefficients a, b, c and the reported photons,
then why not just use the textbook quadratic formula to get a (vectorised!)
closed form for the incident photons?
This only works for a few polynomial degrees of course, and there's a small
subtlety in selecting the correct root, but it should be more efficient
than your current approach...
-n
On 4 Sep 2013 21:39, "Chris Weisiger" <cweisiger at msg.ucsf.edu> wrote:
> We have a somewhat elderly microscopy camera whose response curve is
> best-characterized as a degree-2 polynomial (starts out steep, then
> flattens out; we hit the camera's maximum bit depth before the function
> stops being monotonic though). That is:
>
> reported photons = a + b * (incident photons) + c * (incident photons)^2
>
> Of course, each pixel is slightly different, giving 512*512 different
> polynomials. I want to linearize the camera's response in post-production,
> by inverting the (monotonic) function so that it maps reported photons to
> incident photons.
>
> The obvious method would be to use something from scipy.optimize's
> root-finding functions. I'm not remotely a numerical analysis expert, so I
> have no feel for which function would be best for this problem.
> Performance-wise, a quick test indicates that it would take about 3.5s on
> my laptop to process a single frame by manually iterating over every pixel
> in the frame and calling scipy.optimize.newton(that pixel's response
> function, that pixel's starting value). This isn't great, but it's well
> within the realm of feasibility.
>
> Is there some more efficient method to do this? In the ideal world we'd be
> able to handle arbitrary-degree polynomials, but I'd be willing to accept
> being restricted to degree-2. Of course, degree-1 is trivial to implement.
>
> Thanks for any advice you care to share.
>
> -Chris
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130904/afd4a49c/attachment.html>
More information about the SciPy-User
mailing list