2.5
and using another exponentiation identity, raising an arbitrary number to the exponent of
2.5
becomes the product of the number’s square and square root. Squaring a number is
effectively a multiplication with itself and square rooting can be implemented via the
available CORDIC IP core [14]. Looking at the denominator, the division by a constant
can be replaced with a multiplication by the inverse of the constant. Since the inverse of
the constant is less than one, it is scaled up by
2
8
so that integer multiplication can be
performed. Finally, focusing on the numerator, the constant being added must be scaled
by
2
8
to match the scaling already applied to the 8-bit sRGB values. The piece-wise
function after the application of these modifications is shown in Equations 3.2b.
,
,
≤ 0.03928
=
÷ 12.92
=
÷ 12.92
=
÷ 12.92
&'(& )
,
,
> 0.03928
= +
,
+ 0.055.
1.055
/
0
1.2
= +
,
+ 0.055.
1.055
/
0
1.2
(3.2a)
16
= +
,
+ 0.055.
1.055
/
0
1.2
,
,
≤ 10
=
≫ 4
=
≫ 4
=
≫ 4
&'(& )
,
,
> 10
= ,
+ 14.
1
5,
+ 14. 56.0
= ,
+ 14.
1
5,
+ 14. 56.0
= ,
+ 14.
1
5,
+ 14. 56.0
(3.2b)
With the first transform in the color conversion process modified, the conversion
from the linear sRGB color space to the CIE XYZ color space follows next [12]. As shown
in Equation 3.3a, the RGB values are arranged as a column vector and pre-multiplied by a
3x3 matrix of constants. In order to facilitate integer arithmetic, all elements of the constant
matrix are scaled by a factor of
2
12
. With additional down scaling implied in Equation
3.3b, the results of this transform are comparable to the original algorithm with a scaling
17
factor of
2
16
. As can be seen, there is not much else that can be done to this stage to make
it more implementation-friendly. Matrix multiplication is easily mapped to an FPGA via
the use of multiply-accumulate operations, a standard method in digital signal processing
(DSP). Rather than creating our own custom core to implement this operation, an existing
IP core has been used and our overall design time has been shortened.
6
7
8
9
: = 6
0.4361 0.3851 0.1431
0.2225 0.7169 0.0606
0.0139 0.0971 0.7141
: 6
:
(3.3a)
6
7
8
9
: = 6
1786 1577 586
911 2936 248
57
397 2924
: 6
:
(3.3b)
Once the pixel values are converted to corresponding values in the CIE XYZ color
space, the final conversion to the CIE L*a*b* color space is performed [13]. Note that the
following constants – based on a reference white point – are needed for this transform:
X
n
= 0.964203
,
Y
n
= 1.000
, and
Z
n
= 0.824890
. Equations 3.4a, 3.5a, and 3.6a, show that the
X, Y, and Z values from the previous transformation step need to be divided by these
constants. In the case of
8
8
<
, the constant is one and no division is required. For the
other two cases, division could be replaced by a multiplication with the inverted and scaled
up constants. However, since the inverted constants are approximately one, we have
chosen to eliminate this step completely. These modifications are captured in Equations
3.4b, 3.5b, and 3.6b.
=
∗
= 116 ,8 8
<
. − 16
(3.4a)
=
∗
= 116 8 − 16
(3.4b)
18
@
∗
= 500 A ,7 7
<
. − ,8 8
<
.B
(3.5a)
@
∗
= 500 C 7 − 8 D
(3.5b)
E
∗
= 200 A ,8 8
<
. − ,9 9
<
.B
(3.6a)
E
∗
= 200 C 8 − 9 D
(3.6b)
Function
f(x)
is a piece-wise function [13] and is given in Equation 3.7a. Since the
input values to this step are scaled by a factor of
2
16
, the constant value that the input values
are compared against must also be scaled by the same factor – which is a similar
modification to the one performed in Equations 3.2a. In the first case of Equation 3.7a, a
cube root operation is required. To create a custom core to perform this operation would
be time consuming and there are no pre-existing Xilinx IP cores for this operation. Using
a set of basic algebraic manipulations, the cube root operation can be replaced by the
product of multiple square root iterations, as shown in Equation 3.7b. To handle the second
case of Equation 3.7a the constant
7.787
can be rounded to
8.0
, which effectively replaces
the multiplication with a three bit-shifts to the left. The addition of a constant value must
be scaled by
2
16
in order to match the scaling already applied to the input value. These
changes are shown in Equation 3.7b.
= F
G H
, ) > 0.008856
7.787
+ 16 116, ) ≤ 0.008856
(3.7a)
= I
G 2 G GJ
, ) > 580
≫ 3 + 9040, ) ≤ 580
(3.7b)
19
The resulting CIE L*a*b* pixel values are finally scaled to 8-bit integer values
using equations 3.8 and 3.9. Note that the results from equations 3.4a, 3.5a, and 3.6a have
been labeled with apostrophes to avoid duplicated symbols. For Equation 3.8, the division
by
100
can be combined with the multiplication by
255
, resulting in a multiplication by
26
– not shown. The addition of a constant needs no modifications in Equations 3.9.
=
∗
= 255 ,=
∗
100.0.
(3.8)
@
∗
= @
∗
+ 128.0
E
∗
= E
∗
+ 128.0
(3.9)
Once the color space conversion is completed, the vector gradients of each color
plane are calculated. As mentioned in the previous chapter, two vector gradients must be
computed for each color image plane. The gradient calculation is basically a difference
calculation between neighboring pixels, and is shown in Equations 3.10 and 3.11. The
division by two is avoided by scaling both cases of the piecewise function by two. This
scaling factor can be removed when the results are imported into MATLAB, preserving
the precision required by this stage. By inspection, the operations performed to calculate
the gradient in the x direction are nearly identical to those used for the y direction. The
only differences are the variables that are indexed and the limits
m
and
n
. For
implementation, it is important to note that the image cannot be indexed bi-directionally as
it would in MATLAB. The input pixels must be loaded sequentially, and their relative
position in time is referenced to
t
. By pre-arranging the CIE L*a*b* results in both a row-
major format and also a column-major format, one design can be used for both directions
of the vector gradient. The only additional point of consideration is that the number of
20
rows
m
or columns
n
must be specified in conjunction with the input format of the image.
By modifying the instruction set of the framework (MCF), a custom user instruction has
been added to load the appropriate value, which is denoted by
k
in Equation 3.12, and
discussed in more detail in the next section.
K Lℎ& &NO@L)PK( E&'PQ, '&L
R
, @K
S
E& Lℎ& T@ )&KL( )K Lℎ& @K )T&UL)PK(
P @K V E W )X@ &.
YOTLℎ&TXPT&, '&L Z @K [ E& TPQ @K UP'OXK )K )U&(, @K \ E& @ ]) &' ^@'O& @L @
'PU@L)PK QTL Z @K [ PT QTL @ L)X& _.
R
), ` = a
] ) + 1, ` − ] ), ` ,
PT ) = 1, K
b
] ) + 1, ` − ] ) − 1, `
2
c , PLℎ&TQ)(&
(3.10)
S
), ` = a
] ), ` + 1 − ] ), ` ,
PT ` = 1, X
b
] ), ` + 1 − ] ), ` − 1
2
c , PLℎ&TQ)(&
(3.11)
S
), ` = dC] L + 1 − ] L D ≪ 1,
PT L = 1, f
C] L + 1 − ] L − 1 D,
PLℎ&TQ)(&
(3.12)
Do'stlaringiz bilan baham: |