Lecture 19 Cameras and Lenses
一、Camera
1、Pinhole Image Formation
![image-20210128191238341](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128191238341.png)
最早的相机是从小孔成像开始的。
2、Important Parts
(1)、Shutter Exposes Sensor For Precise Duration
![image-20210128191353648](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128191353648.png)
快门,控制光能在相机中待多长时间。(光在1/x秒内在相机中)
(2)、Sensor Accumulates Irradiance During Exposure
![image-20210128191601972](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128191601972.png)
传感器,记录的是光的Irradiance。
二、Professional Term
1、Field of View (FOV)(视场)
Effect of Focal Length on FOV
![image-20210128192152384](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128192152384.png)
f:Focal length(焦距)
h:传感器的高度
视场通俗来讲就是我们拍照能看到的范围。
For a fixed sensor size, decreasing the focal length increases the field of view.
那么我们根据几何相关知识,就可以得出FOV的角度:
![image-20210128192328020](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128192328020.png)
Focal Length v. Field of View
-
For historical reasons, it is common to refer to angular field of view by focal length of a lens used on a 35mm-format film (36 x 24mm)
-
Examples of focal lengths on 35mm format:
--17mm is wide angle 104°
--50mm is a “normal” lens 47°
--200mm is telephoto lens 12°
-
Careful! When we say current cell phones have approximately 28mm “equivalent” focal length, this uses the above convention.
人们在定义视场的时候,通常认为以35mm胶片(传感器)为基础。因此就有了通过焦距来定义视场的说法。(等效焦距)
比如:在35mm胶片下,17mm的焦距对应的镜头视场角度是104°(广角镜头),200mm的焦距对应的镜视场角度是12°。
手机上经常是28mm焦距,但是手机镜头看起来很薄,是因为28mm焦距的镜头对应的是35mm的传感器,而手机的传感器其实很小,那么对应的焦距其实也很小。
Effect of Sensor Size on FOV
![image-20210128193058017](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128193058017.png)
那么如果单纯改变传感器大小,大的传感器自然对应更大的视场,小的传感器对应更小的视场。
Maintain FOV on Smaller Sensor?
![image-20210128193300539](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128193300539.png)
To maintain FOV, decrease focal length of lens in proportion to width/height of sensor
接着刚刚提到的手机摄像头。对于手机来说,如果传感器小,那么焦距也要相应变小,即可达到相同的视场。
2、Exposure
-
H = T x E(Exposure = time x irradiance)
-
Exposure time (T)
--Controlled by shutter
-
Irradiance (E)
--Power of light falling on a unit area of sensor
--Controlled by lens aperture and focal length
曝光,在相机里决定曝光的两个因素是时间和进光量(Irradiance)
Exposure Controls in Photography
Aperture size(光圈大小)
- Change the f-stop by opening / closing the aperture (if camera has iris control)
通过f-stop这个值可以控制光圈的大小,从而可以决定挡住多少光(控制进光量)。
Shutter speed(快门速度)
- Change the duration the sensor pixels integrate light
快门速度越快,快门开放的时间就会越短,感光器暴露在光线中的时间也就越短,从而可以控制进光量。
ISO gain (感光度)
- Change the amplification (analog and/or digital) between sensor values and digital image values
感光度相当于一个后期处理,该接收到多少光还是多少,只不过在后期乘上一个数改变整体的亮度。当然感光度也可以在硬件上改变,比如改变感光器的灵敏度。
Exposure: Aperture, Shutter, Gain (ISO)
![image-20210128201726675](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128201726675.png)
用不同的参数不同的值会影响最后图像的成像。
①、ISO (Gain)
Third variable for exposure
Film: trade sensitivity for grain
Digital: trade sensitivity for noise
- Multiply signal before analog-to-digital conversion
- Linear effect (ISO 200 needs half the light as ISO 100)
ISO为200的照片效果就是比ISO为100的提高了一倍
ISO Gain vs Noise in Canon T2i
![image-20210128201906363](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128201906363.png)
如果说ISO是对图片后期的处理,那么对在低ISO下拍摄的照片,如果提高了ISO,虽然曝光度被提高,但是噪声依然也会被放大。
②、F-Number (F-Stop): Exposure Levels
Written as FN or F/N. N is the f-number
Informal understanding: the inverse-diameter of a round aperture
![image-20210128202312162](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128202312162.png)
F就是光圈直径的逆(焦距/直径)
③、Physical Shutter
Effect of Shutter Speed
![image-20210128202534671](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128202534671.png)
Motion blur: handshake, subject movement
Doubling shutter time doubles motion blur
比较慢的快门速度会产生运动模糊(因为快门速度慢了以后曝光时间长,光在感光器上停留时间长)
Rolling shutter: different parts of photo taken at different times
![image-20210128202707829](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128202707829.png)
由于对于机械的快门来讲,打开有一个过程(从一侧打开),因此实际上感光器上记录的是不同时间的光,如果这时被记录物体的速度非常快,那么就会产生扭曲。
Fast and Slow Photography
High-Speed Photography
Normal exposure = extremely fast shutter speed x (large aperture and/or high ISO)
对于高速摄影来说,需要在更短的时间内拍出更多张照片,可以记录很多个一瞬间。
Long-Exposure Photography
对于慢速摄影来说,给一个特别长的曝光时间,就可以在环境相对黑暗的情况下记录下来光的运动轨迹
④、Constant Exposure: F-Stop vs Shutter Speed
Example: these pairs of aperture and shutter speed give equivalent exposure
![image-20210128202921376](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128202921376.png)
If the exposure is too bright/dark, may need to adjust f-stop and/or shutter up/down.
Photographers must trade off depth of field (?) and motion blur for moving subjects
在实际拍照的时候,各个参数需要权衡,来达到想要的效果。
三、Thin Lens Approximation
Ideal Thin Lens – Focal Point
![image-20210128203540066](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128203540066.png)
整个过程我们研究的透镜都是理想情况下的透镜
(1) All parallel rays entering a lens pass through its focal point.
所有平行光通过透镜都会聚集在一个点上
(2) All rays through a focal point will be in parallel after passing the lens.
过焦点的所有光线通过透镜都会变为平行光
(3) Focal length can be arbitrarily changed (in reality, yes!).
我们假设透镜的焦距可以任意改变(现代的相机可以通过透镜组来实现这个效果,就好像是一个透镜的焦距可以任意改变)
从任何一个方向入射的光,如果经过透镜的中心点,光线的方向都不会发生改变
1、The Thin Lens Equation
![image-20210128203840129](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128203840129.png)
我们定义物距z0,像距zi,焦距f。1/焦距=1/像距+1/物距
这个式子的推导如下:
Gauss’ Ray Tracing Construction
![image-20210128204429634](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128204429634.png)
根据相似三角形我们可以得到:
![image-20210128204444406](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128204444406.png)
然后经过一系列化简:
![image-20210128204502477](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128204502477.png)
2、Defocus Blur
Computing Circle of Confusion (CoC) Size
![image-20210128204620541](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128204620541.png)
CoC:远处如果有个平面Focal Plane,所有光经过透镜后都会被聚焦到右边的成像平面Sensor Plane上,如果物体Object不在Focal Plane上,那么其成像就会在Image上,显然Image没有到成像平面Sensor Plane,那么光线就会继续传播,那么当碰到成像平面Sensor Plane时,就不再聚集到一个点,而成了一片(一个圆),这个圆就叫Circle of Confusion(CoC),那么就会模糊。
Circle of confusion is proportional to the size of the aperture
![image-20210128205224537](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128205224537.png)
由上式可以得到CoC(C)的大小与透镜(光圈)本身的大小(A)成正比,也就是说,看到的东西是否模糊取决于光圈的大小(如下图)。
CoC vs. Aperture Size
![image-20210128205534113](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128205534113.png)
Revisiting F-Number
- Formal definition: The f-number of a lens is defined as the focal length divided by the diameter of the aperture
- Common f-stops on real lenses: 1.4, 2, 2.8, 4.0, 5.6, 8, 11, 16, 22, 32
- An f-stop of 2 is sometimes written f/2, reflecting the fact that the absolute aperture diameter (A) can be computed by dividing focal length (f) by the relative aperture (N).
f数=焦距/光圈直径
Example F-Stop Calculations
![image-20210128205753258](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128205753258.png)
Size of CoC is Inversely Proportional to F-Stop
![image-20210128205830706](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128205830706.png)
f:焦距
N:f数
D(A):光圈直径
从这里可以看出,CoC与N也有反比关系。
3、Ray Tracing Ideal Thin Lenses
Ray Tracing for Defocus Blur (Thin Lens)
![image-20210128210736383](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128210736383.png)
将透镜的原理用在光线追踪上:
(One possible) Setup:
- Choose sensor size, lens focal length and aperture size
首先确定成像平面的大小、透镜本身的焦距和光圈大小
- Choose depth of subject of interest zo
然后定义透镜与拍摄平面(物距)的距离
- Calculate corresponding depth of sensor zi from thin lens equation
根据前两项确定的数据算出像距
Rendering:
- For each pixel x’ on the sensor (actually, film (胶片))
在成像平面上选一个点x‘
- Sample random points x’’ on lens plane
在透镜上选另一个点x’’
- You know the ray passing through the lens will hit x’’’ (because x’’’ is in focus, consider virtual ray (x’, center of the lens))
连接x’和透镜中心点并延长,与subject plane相交得到交点x‘’‘,这样我们就可以知道x‘’’→x‘’这条光线最终会被记录在x‘点上
- Estimate radiance on ray x’’ -> x’’’
因此我们只需要考虑x‘’→x’‘这条光线上的radiance,算出来记到x’上。
4、Depth of Field
![image-20210128211423382](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128211423382.png)
Set circle of confusion as the maximum permissible blur spot on the image plane that will appear sharp under final viewing conditions
用大小光圈会让一个距离范围的物体模糊。
Circle of Confusion for Depth of Field
![image-20210128211521113](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128211521113.png)
i.e. depth range in a scene where the corresponding CoC is considered small enough
景深:场景中一段一定深度的光经过透镜,打到成像平面,在成像平面附近的某个区域,这个区域内CoC都是足够小的。
景深所对应的这一段就是CoC足够小的这段范围。
Depth of Field (FYI)
![image-20210128211835238](https://gitee.com/dmtzhuozhuo/computer-graphics/raw/master/img/image-20210128211835238.png)
考虑景深的最近和最远处,从而得到如上的公式。