# Particle Swarm Optimisation in Practice: Multiple Applications in a Digital Microscope System
## 5 Colour Reproduction Accuracy  
The colour reproduction accuracy is very important in digital microscopes as the colour sensitivity of the sensor seldom reproduces the colour space required by monitors [39]. In 1996, HP and Microsoft developed a standard colour space (sRGB) for use in monitors, printers and the internet [40]. In order to render the image on a display as accurately as possible these RGB pixel values need to be mapped to the device-independent colour space sRGB. Figures 9 and 10 and demonstrates the essence of the challenge. A reference colour chart (Figure 9) is placed under the microscope and an image (Figure 10) taken with no colour correction applied. The measured colours are not an accurate representation of the reference colour chart and look washed out/lack vibrancy. In the digital microscope, colour correction is part of the simplified image processing pipeline shown in Figure 11.  
Figure 8: The 2D point cloud matching application. Figure 11: Microscope image processing pipeline. Figure 9: Macbeth chart. Figure 10: Measured colours. The image processing pipeline works as follows:  
* Light from the object under inspection is focused on the image sensor using a single or combination of lenses. Infrared light is blocked using an infrared filter. * The image sensor converts the incoming light to a Bayer image. * The Bayer image is converted into a red, green and blue (RGB) image. * The RGB image is white balanced. * The RGB colour pixel measurements that are dependent on the sensor, optics and lighting characteristics do not accurately represent the actual object RGB colours and are corrected by a colour correction matrix. * Gamma correction is applied to match the gamma of the display. There are many methods of mapping from device dependent RGB to the sRGB space, such as look up tables, linear and polynomial regression and neural networks [41]; however, a simple 3 \(\times\) 3 matrix linearly transforming the device dependent RGB to the sRGB space \"is not easily challenged\" [41]. In addition, the application of this mapping is conducted in real time and performed in an FPGA, ruling out alternative methods due to speed and resource usage. In order to find a 3 \(\times\) 3 colour correction matrix, a number of known sRGB colours are measured by the sensor and a matrix is derived that maps these measured values to the known sRGB colours. A reference colour checker chart [42] was imaged by the camera. A region of interest (Figure 12) within each colour was selected and the mean RGB values of that region of interest calculated. A table of colour regions vs. reference sRGB values [43] provides the ground truth for each colour in the chart. The reference sRGB values are non-linear, with an exponent Gamma of approximately 2.2 applied to their normalised values [40]. The measured RGB values also have a Gamma of 2.2 applied to their normalised values within the FPGA. To convert these into linear space RGB\({}_{\mathrm{L}}\) where a linear 3 \(\times\) 3 matrix can be used to transform the device-dependent RGB values to device-independent sRGB values, each RGB value is divided by 255 and a Gamma power of 2.2 is applied. \[\mathrm{RGB_{L}}=(\mathrm{RGB}/255)^{2.2} \tag{5}\]  
Table 5 shows the measured, reference sRGB values and the 3 \(\times\) 3 colour correction matrix. Figure 12: X-rite colour checker chart measured by the camera showing the region of interest areas. A 3 \(\times\) 3 matrix needs to be found that transforms the measured colours to the reference colours as accurately as possible. The most common method of correcting colour is the linear method using a 3 \(\times\) 3 matrix to transform the measured colour to the reference colour [44]. Let R and M denote 3 \(\times\) N matrices of reference colours and measured colours. N is the number of RGB samples.