# The circle of confusion

A large reason for image blur arises from simple geometry - the image point is not at the focal distance. Geometric blur is measured by the size of the circle of confusion, which is simply the diameter of a point image. The function opticsCoC calculates the circle of confusion.

For a description of the circle of confusion see this Wikipedia page. That page links to the original wonderful article describing the geometry.

## Contents

```ieInit
```

## Calculate the circle of confusion diameter for different points

```% Points distances
oDist = logspace(-1.5,0,20);

optics = opticsCreate;
optics = opticsSet(optics,'fnumber',2);
c = zeros(size(oDist));
for ii=1:length(oDist)
c(ii) = opticsCoC(optics,oDist(ii),'um');
end
```

## Plot the circle diameter as a function of distance

```vcNewGraphWin;
semilogy(oDist,c,'b-'); grid on
xlabel('Object distance (m)');
ylabel('Diameter of circle of confusion (um)')
```

## Change f-number, but not focal length, and recalculate

```optics = opticsSet(optics,'fnumber',4);
c = zeros(size(oDist));
for ii=1:length(oDist)
c(ii) = opticsCoC(optics,oDist(ii),'um');
end
hold on
semilogy(oDist,c,'g-'); grid on
xlabel('Object distance (m)');
ylabel('Diameter of circle of confusion (um)')
```

## Change the f-number once more, keeping focal length fixed

```optics = opticsSet(optics,'fnumber',8);
c = zeros(size(oDist));
for ii=1:length(oDist)
c(ii) = opticsCoC(optics,oDist(ii),'um');
end
hold on
semilogy(oDist,c,'r-'); grid on
xlabel('Object distance (m)');
ylabel('Diameter of circle of confusion (um)')

% In all cases
flength = opticsGet(optics,'focal length','mm');
title(sprintf('Focal length %.2f mm',flength));

legend({'f/# = 2','f/# = 4','f/# = 8'})
```