main content

histogram equalization -凯发k8网页登录

this example shows how to use the vision hdl toolbox™ histogram library block to implement histogram equalization.

this example model provides a hardware-compatible algorithm. you can generate hdl code from this algorithm, and implement it on a board using a xilinx™ zynq™ reference design. see (vision hdl toolbox support package for xilinx zynq-based hardware).

introduction

the model shows how to use the histogram library block to enhance the contrast of images by applying the histogram equalization. to learn more, refer to the block reference page. there are three components in this histogram equalization example.

  • video partition partitions a big image into four non-overlapping small images for parallel histogram computation.

  • hdlhistogram computes the accumulated histogram of the image.

  • equalization applies the equalized histogram to the original image and generates the contrast-enhanced image.

video partition

there are use cases where histogram is computed over an entire image, or over small regions-of-interest representing sections of the image. computing histogram of a big image is time consuming. the video partition component in this example divides a big image into four non-overlapping small images. histogram is computed over the four small images simultaneously. each input frame is partitioned into four 120 by 160 small images. each small image is connected to a frame to pixels block to generate pixel streams and corresponding control signals.

hdlhistogram

hdlhistogram subsystem is optimized for hdl code generation. the histogram of the pixel streams is computed using the histogram block. because the input image is grey scale with data type uint8, the input pixels are grouped into 256 bins. the model reads the calculated histogram bins sequentially once the block asserts the readrdy signal. the bin values are sent for cumulative histogram calculation. after all 256 bin values are read, the model asserts binreset to reset all bins to zero. the collected histogram of each small image is then added together to compute the accumulated histogram of the big image.

the timing diagram of reading and resetting the histogram bins is shown in the following figure.

equalization

histogram equalization can be applied to the current frame where the accumulated histogram was calculated, or the frame after. if applying to the current frame, the input video needs to be stored. this example delays the input video by one frame and performs uniform equalization to the original video. the equalized video is then compared with the original video.

hdl code generation

the hdl code generated from the histogram was synthesized using xilinx ise on a virtex6 (xc6vlx240t-1ffg1156) fpga, and the circuit ran at about 190 mhz, which is sufficient to process the data in real time.

to check and generate hdl code of this example, you must have an hdl coder™ license.

you can use the commands

makehdl('histogramequalizationhdl/hdlhistogram')

or

makehdltb('histogramequalizationhdl/hdlhistogram')

to generate hdl code and test bench for the hdlhistogram subsystem. note: test bench generation takes a long time due to the large data size. consider reducing the simulation time before generating the test bench.

网站地图