# Mathematics in Digital Photography



## JasnaHodzic (May 10, 2009)

Wasn't sure which thread to post this in..so feel free to move it.
I have a calculus project in which I have to find some sort of modern application of higher thinking mathematics, not necessarily calculus. I was interested in basing my project on the mathematics of photography (besides the basics of shutter speed/aperture) but sadly could not find any specific theorems/formulas relating to anything about photography.
 I find this a bit fishy. I had the belief that the sensor technology, lighting, exposure time, etc. had some basis in advanced mathematics. I was wondering if anyone on this forum knew anything about any higher-level mathematics involved in photography? Thanks so much for any responses.


----------



## Garbz (May 10, 2009)

Unfortunately there are very few applications for higher level maths in fundamental photography. Most relationships are linear or logarithmic. The most complicated formula I can think of right now is the Exposure value formula which is EV = Log2 (Aperture^2/shutter speed).

Now if you want to get into the technical gritties then there is higher level maths involved at the physics level of the devices. For instance in a photo sensor, surface integral can calculate the absorption of photons and then along with many other variables eventually the quantum efficiency of the sensor photosite. But Beyond that you're back to linear / logarithmic relationships again.

Also modern metering such as 3D Matrix Metering or Evaluative Metering uses quite complex maths to determine what the desired exposure should be, but if you're going into that you're not too far from image processing which is ALL maths. 

If you are after specifically applications for higher level maths, do a bit of background reading on the Fast Fourier Transform. This has virtually endless applications in digital signal processing, as computers are especially efficient at many operations involving Fourier space. It is often computationally cheaper to Fourier Transform a signal do stuff and then Inverse Fourier Transform back.


----------



## Patrice (May 10, 2009)

Garbz said:


> If you are after specifically applications for higher level maths, do a bit of background reading on the Fast Fourier Transform. This has virtually endless applications in digital signal processing, as computers are especially efficient at many operations involving Fourier space. It is often computationally cheaper to Fourier Transform a signal do stuff and then Inverse Fourier Transform back.



Nice. Did a bit of radio interferometry from deep space objects and lots of satellite signal processing and FFT is an everyday working tool. Applicable to a myriad of applications, especially when modeling analog signals.


----------



## Dwig (May 10, 2009)

Outside of optical design, most of the formulae used in photography are rather simple algebra of the type encountered in basic algebra and geometry classes. They can be complex, with many factors, but still the math operations are rather basic. Trig comes into play occasionally, generally when dealing with field of view calculations. 

The only time I've encountered issues or discussions involving calculus involved relating electronic flash duration with exposure in the classic auto-exposure flash designs involving quelch circuits. There, exposure (quantity of light) is the area under the curve (light intensity over time) and duration is defined by the time when the intensity is greater than some fraction of the peak intensity.


----------



## JasnaHodzic (May 10, 2009)

Thanks guys, I'll look up those formulas. I am open to discussing digital sensors, in fact that was what I was aiming toward. and Dwig, do you know of any specific formulas involved in lighting?
Thanks everyone!


----------



## JasnaHodzic (May 10, 2009)

To Garbz, or anyone, do you have any more information concerning

"Now if you want to get into the technical gritties then there is higher level maths involved at the physics level of the devices. F*or instance in a photo sensor, surface integral can calculate the absorption of photons and then along with many other variables eventually the quantum efficiency of the sensor photosite*. But Beyond that you're back to linear / logarithmic relationships again.

Also modern metering such as 3D Matrix Metering or Evaluative Metering uses quite complex maths to determine what the desired exposure should be, but if you're going into that you're not too far from image processing which is ALL maths. "

I looked up information regarding the Fourier Transform and was literally taken aback by the scope of its applications. I'm trying to condense my research to some specific application, hopefully in terms of digital sensors. I tried doing some research to localize applications in digital sensors and found something called "Discrete Fourier Transform" -sound familiar to anyone?

Thanks


----------



## Garbz (May 11, 2009)

The Discrete Fourier Transform basically is the Fourier Transform as applied to a sequence of numbers, as opposed to a continuous function such as an analogue signal. The DFT finds a lot of use in anything that is converted from analogue to digital. Huge use in digital signal processing. Do you have access to a large library? Try and suss out a book called "Digital Signal Processing Concepts and Applications", B Mulgrew, P Grand, J Thompson. It is a book full of endless applications of Laplace and Fourier transforms in the time domain (FFT) and the series domain (DFT).

As with the point about photosites. The digital camera sensor mathematics is highly dependant on things like surface area, rate of photons entering, and the absorption rate which is dependant on the depth the photons reach inside the cell and the electron hole pair photogeneration rate (which is an integral over the length width and depth of the photosite). This is too complicated to explain in a simple form post and we spent several weeks studying just this topic of photovoltaic devices, but here's an example of higher level maths that applies directly to camera sensors, current in a photosite:







Where:
Iph = photocurrent output
G_0 = G0 is the photogeneration rate (this is a surface integral of the photons hitting the sensor).
A = sensor surface area
alpha = absorbtion coefficient
l_n+w+L_e = the volume of the photosite

Now given that G_0 is a surface integral it can be expanded more complicated than that, but often in engineering certain assumptions are made and entire calcuations are reduced to just simple applications. For example for long wavelengths alpha gets very small and thus:

I_ph = e G_0 A (l_n+W+L_e)

So if you do a google search you'll likely end up with simplified formulas which can be directly applied straight out of the net, but if you grab a book like "Optoelectronics and Photonics Principles and Applications", S.O. Kasap. you'll end up with the very high level and complicated formulas on which the simplifications are based.

Heck this is the same for most types of maths. The volume of a sphere is 4/3*pi*r^3 which is the result of a double integral over the sphere model.


----------



## smn_xps (May 11, 2009)

Well, well! 

I haven't had to solve one of those since grad school.

cheers
jerry


----------



## JasnaHodzic (May 11, 2009)

Aaah now I'm scared this may be TOO advanced. I'm in Calculus AB, senior in high school, we're supposed to learn something new mathematically in our project, but nothing too crazy. I have a feeling this involves multiple variables...
Looks like I'm going to have to scratch photography out as an application of calculus or higher thinking math...looks TOO higher level for me 
Thanks so much for your help though, you guys all seem to have a solid foundation in math, so I was also wondering if anyone could suggest some topics that may be appropriate for my project...trust me I've  been looking.
Past projects included aerodynamics, some sort of physics applications, calculus behind music etc.


----------



## Garbz (May 12, 2009)

Are you required to just find an application? Or find an application where you can use numbers and come out with a solution? Basic integration and differentiation find endless uses in control system which you could write a lot about, but the problem is these things are continuous as all variables constantly change. A PID controller for instance is a Proportional, Integral, Derivative controller usually used to maintain a certain property while others are changing for various reasons. The basic example given in Intro to Control Systems is bucket with a leak in it. 

Suppose we wanted to keep the water level constant by adding more water. Since the rate at which water leaks out depends on the amount of water in the bucket (because of a change in pressure with more water). This makes the bucket a giant integrator. if you could take just a single variable (in this case volume) and measure it continuously then you would need to differentiate it before using the signal to control the tap adding more water, or you would end up with a response which jumps around a lot before it achieves a steady level.

Sorry I am having difficulties finding usable applications for calculus which don't result in a complex variable soup such as those used by physics. Control systems seems to be a suitable result. Another example would be an elevator. You wish to get to the correct level as quickly as possible, but you don't want an elevator to either bounce up or down when it gets there, nor stop when it's not inline with the floor. Integration and differentiation of measurable variables (such as position of the elevator) can be used to minimise the problems while maximising the speed at which the elevator reaches the floor.

Sorry I can't come up with anything more basic right now. Both of these are ultimately very complicated topics.


----------



## smn_xps (May 12, 2009)

You should take a look at spline functions then. they are used for fitting functions to data sets that do not have a clear linear, quadratic, cubic, or other well known form. 

spline functions are cool in that they require that the first and second derivatives match at the nodes, though end conditions can vary depending on the application.

If you need a project idea you could attempt to write code to compute a cubic spline function using your TI calculator. This should be doable for a hard working and clever high school student. I can offer some help if needed, but ask your teacher if my help is allowed first. 

cheers
jerry


----------



## smn_xps (May 12, 2009)

now that i give that just a bit more thought spline functions may have some application to image processing. for example if you want to increase the resolution of a photo you have to add pixels between the pixels you already have. Now adding pixels is no big deal but you would need a way of choosing the color of each pixel which could be more challenging. a spline function could be found that to models the colors across the row (or column) of pixels and then that spline function can be used to compute the colors that should be placed between. I have no idea if this is the strategy used in image processing applications or not. I would think they use something less computationally demanding.

good luck
jerry


----------



## Garbz (May 12, 2009)

Define computationally demanding? Afterall I have a 4 core 2.4Ghz computer now. ScienceDirect - Signal Processing: Image Communication : Least-squares spline resampling to a hexagonal lattice The least squares spline resampling process is used in both commercial resizers like "Resize-IT" and as features of programs such as AutoPano Pro. The best part is because it uses iterration it can be as compuationally nice or challenging as you want it to be.


----------



## smn_xps (May 13, 2009)

Garbz said:


> Define computationally demanding? ...



I was just trying to convey the idea that using a cubic spline function on (potentially) thousands of nodes to interpolate the midpoints would take much more computational time than interpolating using a line through adjacent nodes. code that is demanding on a graphing calculator is trivial on a supercomputer, as you know.

i suggested using a TI graphing calculator as a platform, the code that i have written for a cubic spline function will take 20 - 30 seconds to run on one of these with a dozen or so nodes. on your machine a decent code should do that in a blink, or maybe 3/4 of a blink. I have used the same algorithm in C++ and it will print results in a second or so. I am sure there is much more efficient code than mine to be had. I only write code for fun and have very little experience or training with it.  

back in undergrad i had to write some code to solve a math problem as an assignment for one course i was taking. I chose to write some code to test all permutations of an 11 set for a particular quality.  when i wrote it i tested using a 4 set and my new-red-hot-state-of-the-art laptop ran it in a few seconds. so I let it run with the 11 set and it took 11 hours to process! that was demanding, and probably terribly inefficient, code for that machine.

cheers
jerry


----------



## Garbz (May 13, 2009)

Oh I know the feeling. We had to impliment Finite Difference Time Domain methods in Matlab to simulate a EM wave propegating through an object. That was nasty. It's not that it took an hour to simulate, it's that I had to finetune it and wait for an hour for the results so the assignment took ages even though no real work was done on it.

Modern computers chew through this kind of thing through. I was just pointing out the microsoft school of thought, efficient code no longer matters when everyone has mutlicore machines with +2GB of RAM. Actually come to think of it slower still is an interpolator based on a windowed sinc function. I gave up using that option in Panorama Tools though because that really did take way to long for little gain in quality.


----------



## smn_xps (May 13, 2009)

Garbz said:


> ...efficient code no longer matters ...




if you  had my coding skills you'd be glad for that. :thumbup:


my latest is code that takes data from the sonar unit on my fishing boat and uses it to make contour plots of the lake bottom that can be loaded back to the GPS unit so I know where i'm at with respect to water depth. still has a few things that need fine tuned, but works nicely. 



back to photography now,
Jerry


----------



## Garbz (May 14, 2009)

Hahahha try limit yourself to a slow microcontroller and 4kb of memory for a while. You'll be surprised how quickly your algorithms improve


----------

