12.12.2012 Views

Xcell Journal: The authoritative journal for programmable ... - Xilinx

Xcell Journal: The authoritative journal for programmable ... - Xilinx

Xcell Journal: The authoritative journal for programmable ... - Xilinx

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

same address location, thus increasing the<br />

total amount of memory by a factor of<br />

four. This methodology can be mitigated<br />

based on pixel bit width – that is, 8-bitwide<br />

pixels can use this approach to fit into<br />

a 32-bit-wide memory footprint.<br />

Design Implementation with System Generator<br />

Our example will implement image rotation<br />

with the following assumptions:<br />

• Input image size and pixel widths are<br />

known at the time of implementation<br />

• Use the Hotelling trans<strong>for</strong>m of the<br />

<strong>for</strong>m:<br />

Sx = Dx * cos(t) + Dy * sin(t)<br />

Sy = Dy * cos(t) – Dx * sin(t)<br />

• Bi-linear interpolation<br />

• Increased memory bandwidth is<br />

accounted <strong>for</strong> by reading the data out<br />

of the frame buffer four times faster<br />

than the incoming pixel rate<br />

Frame Buffer Read Address Generation<br />

Because the data will be output in raster<br />

scan <strong>for</strong>mat, you can create the destination<br />

address with two counters representing the<br />

two dimensions. <strong>The</strong>se values must be center-adjusted<br />

around zero be<strong>for</strong>e being<br />

trans<strong>for</strong>med. At this point, any adjustment<br />

changes the center of rotation <strong>for</strong> the output<br />

image.<br />

<strong>The</strong> following two examples demonstrate<br />

manipulating the output image by<br />

using minimal extra logic:<br />

• Two adders are all that are required to<br />

add pan control <strong>for</strong> the output image.<br />

• Using two multipliers, you can scale<br />

the destination addresses to zoom in or<br />

out from the center point.<br />

As interpolation occurs at a later stage,<br />

zooming and panning at this point will<br />

result in an output image with each pixel<br />

uniquely interpolated, versus a simple copy<br />

or additional interpolation procedure later.<br />

Figure 2 demonstrates a 45-degree counterclockwise<br />

rotation with 8x zoom.<br />

Once the destination address is correct<br />

<strong>for</strong> center, pan, and zoom, the trans<strong>for</strong>m is<br />

applied. <strong>The</strong> resulting addresses are reverse-<br />

corrected <strong>for</strong> the centering function. <strong>The</strong><br />

numbers are of the <strong>for</strong>m integer with a decimal<br />

portion. <strong>The</strong> integer portions are the<br />

required source address locations to read<br />

from the frame buffer. <strong>The</strong> decimal por-<br />

Figure 2 – Zoom and pan incorporated<br />

into the algorithm<br />

Figure 3 – Original picture<br />

<strong>for</strong> subjective comparison<br />

Figure 4 – Image rotated counter-clockwise 7.5<br />

degrees, followed by rotation clockwise 7.5 degrees.<br />

DIGITAL SIGNAL PROCESSING<br />

tions are used to create weighting factors<br />

used <strong>for</strong> the bi-linear interpolation.<br />

Weighting the Data<br />

Four pixels are fetched from the frame<br />

buffer to create a 2 x 2 matrix containing<br />

the source address pixel and its original<br />

neighbors to the right, below, and belowright,<br />

which we will identify as XY, XpY,<br />

XYp, and XpYp, respectively. <strong>The</strong> source<br />

address trans<strong>for</strong>m uses the decimal portions<br />

of {Sx,Sy} represented as {Rx,Ry} to create<br />

the following weighting equations:<br />

• Weighting(XY) = Wxy = (1 – Rx) (1– Ry)<br />

• Weighting(XpY) = Wxpy = (Rx) (1 – Ry)<br />

• Weighting(XYp) = Wxyp = (1 – Rx) (Ry)<br />

• Weighting(XpYp) = Wxpyp = (Rx) (Ry)<br />

<strong>The</strong>se equations can be shown to be<br />

equal to the following equations to reduce<br />

the number of multipliers necessary from<br />

four to one:<br />

• Wxy = (1 – Rx) – Wxyp<br />

• Wxpy = (Rx) – Wxpyp<br />

• Wxyp = (Ry) – Wxpyp<br />

• Wxpyp = (Rx) (Ry)<br />

<strong>The</strong> interpolated pixel value is the summation<br />

of the 2 x 2 matrix pixels multiplied<br />

by their respective weighting functions.<br />

Compare the original image in Figure 3<br />

with an image that was rotated through 7.5<br />

degrees, followed by a -7.5 degree rotation<br />

in Figure 4.<br />

Conclusion<br />

In this article, I’ve shown how to use System<br />

Generator to explore and implement image<br />

processing algorithms.<br />

<strong>The</strong> use of a mathematical simulation<br />

tool with image handling capabilities allows<br />

you to easily investigate various options in<br />

an intuitive capacity. Although this example<br />

shows an image rotation implementation,<br />

these same methodologies can help you<br />

develop any image processing algorithm.<br />

If you have any questions or suggestions,<br />

call me, Daniel Michek, at (858)<br />

431-5901, or send me an e-mail at<br />

daniel.michek@xilinx.com.<br />

Winter 2004 <strong>Xcell</strong> <strong>Journal</strong> 65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!