# Metric for Estimating Congruity between Quantum Images +
## 3 A Measure for Fidelity between Quantum Images
### Fidelity Check Operation (FCO)
#### 3.3.1 Binary Check Operation  
The binary check operation is so named because it is implemented on the binary content of a pair of quantum images comprising the reference image (\(I_{r}\)) and the test image (\(I_{T}\)). The objective of this operation is to probe into the extent of \"likeness\" between the two images in the pair. It quantifies the pixel-wise amount of exactness (i.e., concordance) between corresponding pixels in a reference and test image [1]. The \(BCO\) operation is executed using three simple steps that are enumerated below:  
Binary check algorithm:  
* Step 1: Utilising a thresholding technique similar to the ones presented in [13; 20], after the content of quantum images have been prepared and initialised, they can be transformed into their binary versions based on a pixel threshold (\(p\)) that assigns a value of zero or one to the pixel when \(0\leq p\) < 127 or 128 \(\leq p\) < 255, respectively. This is utilised to convert the content of both the reference and test image in the \(j\)th (reference and test image) pair into their binary versions. * Step 2: Following the transformation of the reference and test images into their binary versions, we extract some detail about the images, albeit separately, and then use them to obtain the binary detail of each \(j\)th pairing of the reference and test images. To do this, first, we compute the number of white (0) and black (1) pixels in the reference and test images, which are described using separate notations referred to as \(n_{r}^{b}\) and \(n_{r}^{w}\) for the reference image and \(n_{T}^{b}\) and \(n_{T}^{w}\) for the test image. Finally, the binary detail in the \(j\)th pairing between a reference image \(I_{r}\) and test image \(I_{T}\) is evaluated using Equation (10):  
\[\Gamma_{j}=I_{Dr}-I_{DT} \tag{10}\]  
where \(I_{D(r\text{ or }T)}\) for an \(N\) = \(n\)\(\times\)\(n\) pixel image is defined in Equation (11):  
\[I_{D(r\text{ or }T)}=\left\{ \begin{array}{cc}\frac{\sum{(n_{b}^{(r\text{ or }T)}-n_{w}^{(r\text{ or }T)})}}{N};&\text{if }n_{b}^{(r\text{ or }T)}\
eq n_{w}^{(r\text{ or }T)}\\ \frac{\sum{(n_{b}^{(r\text{ or }T)}-n_{w}^{(r\text{ or }T)})}}{N}+1;&\text{ otherwise}\end{array} \right.. \tag{11}\]
* Step 3: In the final step of the \(BCO\) algorithm, we count the number of pixel correspondence (\(D\)), in the \(j\)th reference and test image pair (i.e., the number of pixels \(x_{i}y_{i}\) in \(I_{r}\) corresponding with pixels \(x_{i}y_{i}\) in \(I_{T}\)). However, by correspondence, the concordance that arises when pixels have the same value 0 or 1 (as the case may be) is implied. On the FRQI QIP framework, the \(BCO\) can be executed using the circuit in Figure 6. In this sub-circuit, the strip, \(S\) is used to encode a multiple of FRQI images, each of which requires \(2n\)-qubits to encode its spatial content and an additional 1 qubit to capture its chromatic content. The binary detail, \(\Gamma_{j}\), and pair correspondence, \(D_{j}\), between the reference and test image in the \(j\)th pair are computed using the readout from the (ancilla-driven) measurement layer of the \(BCO\) sub-circuit (which shown in the short-dashed rectangles) in Figure 6.  
As is easily deducible from this \(BCO\) sub-circuit, the \(BCO\) operation requires \(m+2n+1\) qubits to encode the \(j\)th pair of reference and test images, where \(m\) is the number of qubits required to encode a strip of \(2^{m}\) images, each of them an FRQI state that is encoded using \(n\) qubits. Similarly, a total of \(m+2^{2n}+2^{s}\) controlled (\(m+(n-s)\)) transformations are required to retrieve the information emanating from the \(BCO\) operation (i.e., the binary details (\(\Gamma_{j}\)) and pair correspondence (\(D_{j}\)) in the \(j\)th pair) [1]. Here, \(s\) is the number of control-condition operations required to restrict the \(BCO\) operation to any ROI within the reference and test image in the \(j\)th pair whose fidelity measure is sought.