In this notebook, we will explore the averaging of RGB values. Each color is made up of some mixture of red, green, and blue (More information in RGB Filter Example). To convert an image to grayscale, the values of red, green, and blue are added together and then divided by three to get the average color value. This averaged value is the new color value that is used for each red, green, and blue values. This creates a "black and white" image which is comprised of different shades of grey.
This notebook will use a video filter that will convert any image to a grayscale ("black and white") image.
In [1]:
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 [2]:
hdmi_in = HDMI('in')
hdmi_out = HDMI('out', frame_list=hdmi_in.frame_list)
hdmi_out.mode(2)
hdmi_out.start()
hdmi_in.start()
In [3]:
Bitstream_Part("gscale_p.bit").download()
In [4]:
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[0].on_click(on_hdmi_clicked)
widgets.VBox([items[0]])
In [5]:
hdmi_out.stop()
hdmi_in.stop()
del hdmi_out
del hdmi_in