# Assignment Questions

## Image Formation

**A professional camera has a sensor/image size of 36mmx36mm and a focal length of 50mm. A phone camera has a focal length of 4mm. Both the cameras have a resolution of 16MP and their sensors are square-shaped.**

**Calculate the following:**\
**(a) The image sensor size for the phone camera using the pinhole camera projection equation, and the ratio of this size to that of the professional camera**  \
The pinhole projection equation is given by:

$$u=\frac{xf}{z}, v=\frac{yf}{z}$$

We have u1=v1=36mm, f1=50mm, f2=4mm\
We have to calculate u2 (and v2).

From the above equations, we have $$\frac{f}{z} = \frac{u}{x} = \frac{v}{y}$$

Therefore, $$\frac{f_1}{z_1} = \frac{u_1}{x_1} = \frac{v_1}{y_1}$$ and $$\frac{f_2}{z_2} = \frac{u_2}{x_2} = \frac{v_2}{y_2}$$

Dividing the above two equations, we get $$\frac{f_1}{f_2}=\frac{u_1}{u_2}=\frac{v_1}{v_2}$$

Thus, $$u_2 = u_1 * \frac{f_2}{f_1} = 36*\frac{4}{50}=2.88mm$$

Since the sensor is square-shaped, $$v_2=u_2=2.88mm$$

So the image sensor size for the phone camera is 2.88mmx2.88mm = 8.2944mm$$^2$$.

Required ratio = $$\frac{2.88*2.88}{36*36}$$ = 0.0064

**(b) The sensor pixel size for both cameras**  \
sensor pixel size = sensor area/number of pixels

For the phone camera,\
sensor pixel size = $$\frac{2.88*2.88*10^{-6}}{16*10^6} = 0.5184 pm^2$$

For the professional camera,\
sensor pixel size = $$\frac{36*36*10^{-6}}{16*10^6} = 81pm^2$$

**(c) The image storage requirement**  \
Image storage requirement depends on the number of pixels. Since both the cameras have the same resolution (16MP), the image file size will be same for both.

Each pixel needs one byte of storage and there are 3 color channels, so:

image storage requirement = $$16*10^6*3$$ = 48MB.

**Also explain why professional photographers prefer professional cameras to phone cameras. Discuss drawbacks too.**

As discussed, professional cameras have significantly larger sensors. This leads to a larger pixel size, thereby improving image quality for blow-ups. Larger sensors also capture more light/photons, thereby improving low-light photography.\
However, larger sensors imply longer focal length, making the camera big and bulky. Also, larger sensors are more expensive. Therefore, casual users prefer phone cameras as they prioritize cost and convenience over image quality, and professional photographers prefer professional cameras since they prioritize image quality.

## Connectivity

Given the following two images, compute the number of connected components in the foreground and background for 4-neighborhood foreground and 8-neighborhood background, 4-neighborhood foreground and 4-neighborhood background, 8-neighborhood foreground and 4-neighborhood background, and 8-neighborhood foreground and 8-neighborhood background.

![](https://78796498-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RGcN1FDewjE054H%2F-M5-0RfD06cJZH79q0zb%2F-M5-0VgfwlN7KgR-cKZj%2FConenctivity.JPG?generation=1586990840795274\&alt=media)

| For image (a)                  | connected components in foreground | connected components in background |
| ------------------------------ | ---------------------------------- | ---------------------------------- |
| 4-n foreground, 8-n background | 25                                 | 1                                  |
| 4-n foreground, 4-n background | 25                                 | 1                                  |
| 8-n foreground, 4-n background | 1                                  | 1                                  |
| 8-n foreground, 8-n background | 1                                  | 1                                  |

| For image (b)                  | connected components in foreground | connected components in background |
| ------------------------------ | ---------------------------------- | ---------------------------------- |
| 4-n foreground, 8-n background | 11                                 | 1                                  |
| 4-n foreground, 4-n background | 11                                 | 2                                  |
| 8-n foreground, 4-n background | 1                                  | 2                                  |
| 8-n foreground, 8-n background | 1                                  | 1                                  |
