Raspberry Pi & Simulink: A Future of Graphical Programming

We used some colorful props to make the color inversion noticeable. Figures 3 and 4 below show a snapshot of the video feed before and after the color inversion.

Figure 3

Snapshot before color inversion.

Figure 4

Snapshot after color inversion.

As an extension of this project, you can vary the constant value of 255 added to the individual RGB components. This simply shifts the RGB components of the image, giving interesting visual effects on the same image. You can be more interactive by setting the constant block to a value of 1 and adding a slider gain block. Now when you run this on the Raspberry Pi, you can adjust the slider gain and see the color inversion update instantly on the video display.

This project can be used to demonstrate how easy it is for young makers to get up and running with their first Raspberry Pi project in a few hours.

Edge detection
In this example, we'll walk through the implementation of an algorithm that can detect the edges on an input image from a webcam. You can use the same hardware as the previous example, where you have a USB webcam connected to the Raspberry Pi.

Edge detection is a fundamental tool in image processing. It aims at identifying points in a digital image where the brightness changes sharply. These points are typically organized into a set of curved line segments termed edges. Given that the image intensity may be regarded as a two-variable function, edges may be detected by computing its slope's local maxima.

The slope of a two-variable function may be easily determined by computing the gradient magnitude of that function. The slope's local maxima coordinates correspond to the local peaks of the gradient magnitude. An approximate and deterministic way to find such local maxima is to find where the slope function exceeds a given threshold.

Let's look at the top-level model shown in Figure 5. The Video Capture library block from Simulink generates three signals to represent color image data for each pixel. Y is the luma component (essentially a grayscale signal). Cb is the blue-difference chroma component, and Cr is the red-difference chroma component.

Figure 5

Simulink model with edge detection algorithm.

The grayscale image data is used as an input to the edge detection algorithm. The threshold block has a slider interface that allows you to tune the threshold while the algorithm is running on your Raspberry Pi.

Image processing projects are an attractive way of introducing hardware programming to young makers, especially because you can see the results immediately. The potentially steep learning curve associated with new programming languages is considerably reduced with graphical modeling tools such as Simulink. Not only does the combination of Raspberry Pi and Simulink enable users to get up and running quickly, but it also provides an easy way to interact and explore the image processing algorithm in Simulink while it's running on the Pi. Additionally, this combination is a great example of project-based learning, a current trend in using hands-on projects to reinforce conceptual learning.

Websites such as MakerZone, element14, Adafruit, and others are helping aspiring makers bring their projects to life, encouraging them to continue investing time, effort, and energy in engineering and science.

My limited experience with graphical programming is that of using LabView for a test set that a customer requested, rather than my usual programming language of choice. I am not a big fan of graphical programming although I know a lot of folks are - I do get concerned because I think that "you can focus on engineering/design concepts, instead of teaching a programming language" may be a good start for getting young people interested - but if you don't learn a programming language, you sacrifice the ability to have low level control when you need it.

A few weeks ago, Ford Motor Co. quietly announced that it was rolling out a new wrinkle to the powerful safety feature called stability control, adding even more lifesaving potential to a technology that has already been very successful.

It won't be too much longer and hardware design, as we used to know it, will be remembered alongside the slide rule and the Karnaugh map. You will need to move beyond those familiar bits and bytes into the new world of software centric design.

People who want to take advantage of solar energy in their homes no longer need to install a bolt-on solar-panel system atop their houses -- they can integrate solar-energy-harvesting shingles directing into an existing or new roof instead.

Focus on Fundamentals consists of 45-minute on-line classes that cover a host of technologies. You learn without leaving the comfort of your desk. All classes are taught by subject-matter experts and all are archived. So if you can't attend live, attend at your convenience.