In this notebook, we will demonstrate how to use the box blur filter. We take advantage of the Pynq’s ability to buffer HDMI signals in order to perform a filter. The box blur filter is relatively simple. As shown in the image below, the value of each pixel outputted is the average of the pixel in the center and the surrounding pixels.
In order to perform this function, we need access to three rows worth of pixel data. We achieve this by stalling the HDMI signal for two rows while buffering the RGB values of the pixels. Once all the need RGB values are buffered the algorithm is performed and the HDMI output signals are sent.
In :from pynq.drivers.video import HDMI from pynq import Bitstream_Part from pynq.board import Register from pynq import Overlay Overlay("demo.bit").download()
In :hdmi_in = HDMI('in') hdmi_out = HDMI('out', frame_list=hdmi_in.frame_list) hdmi_out.mode(3) hdmi_out.start() hdmi_in.start()
In [ ]:import ipywidgets as widgets from ipywidgets import Button, HBox, VBox, Label words = ['HDMI Reset'] items = [Button(description=w) for w in words] def on_hdmi_clicked(b): hdmi_out.stop() hdmi_in.stop() hdmi_out.start() hdmi_in.start() items.on_click(on_hdmi_clicked) widgets.VBox([items])
In :hdmi_out.stop() hdmi_in.stop() del hdmi_out del hdmi_in