## View Streamed Image data on Simulink in Real-time

Two more months to go and it ends the final semester of final year at the University. All are rushing to finalise their final year projects, do simulations again and again, create test cases etc. Since our final year project is related to FPGA implementation of an image processing application, we used to work with images and they need to send as a data stream to the FPGA for processing. When performing simulations (Using MATLAB Simulink Xilinx Block set) we created the image in to data stream and sent it via Ethernet cable to the FPGA, so called Hardware co-simulation. The way we created the data stream is described in my previous article and I wish to add another article on Hardware Co-simulations in future.

However we had a small problem which the resulted image can only be viewed after performing the full simulation, which takes a lot of time, sometimes it takes hours. So finally by using a combination of MATLAB function block, unit delay block and video viewer block we were abled to design a model which reshapes the image stream back to its original image in real-time. From this article I will share my experience on creating the real-time image viewer for image streams.

## Streaming data from MATLAB-workspace to Simulink

Since we are having our final year project term in the university we are working in a rush with the projects. Our final year project is related to a hardware implementation related to image processing; we use MATLAB together with Xilinx for simulations. This is something I did to make our final year project simulations easy. In this article I share my experience on how to send workspace data to MATLAB simulink with respect to a clock and data enable flag generated by simulink blocks.

MATLAB simulink block “from workspace” allows us to send workspace variables to simulink. The data format must be with at-least two column matrix since the first column is considered as the time stamp. To get a basic idea about how “from workspace” block works, let’s use following simulink model.

## Photo Effects using MATLAB 1.0

Last few days I edited some of my photos using Picasa 3. In this application I found some interesting effects which can be added to images such as pictures which you can use as Facebook profile pictures etc.

I was quite interested to know how they were implemented. However I came out with a small set of solutions developed by myself to archive similar results to Picasa. In this article I will share my solutions to implement “Soft Focus” and “Focal B&W” by Picasa and an effect bit similar to the “Vignetting Effect” say “Shading Effect”.

## Sorting Algorithms sample codes on JAVA, C++ and MATLAB

Sorting is the process which puts the elements in a list to an order. Sorting algorithms are used to optimize the performance and resources usage in computer science. Since I was interested to work with C++ I decided to implement some of those algorithms to be familiar with the language, but later on I thought it may be useful to implement those in JAVA as well as in MATLAB. From this article I am going to share my experiences in implementing those codes in above languages. I used Wikipedia, sorting algorithms website and the book “Introduction to Algorithms 3e” as my references. The algorithms I implemented was,

Sample codes will be as below. In MATAB, this can be used to compare any numeric data type such as uint8, uint16, int8, int16, double, etc. But in case of JAVA and C++ I wrote them to work with integers. Since I am new to C++ I some good points in using arrays/pointers with C++, such as how to initialize an array with a length which is an argument of that function, to get the size of an array, etc. These codes may not be the optimised codes for above algorithms but a small attempt to implement those on three platforms.

## Digital Image Zooming on MATLAB using spline Interpolation

In my previous article on image zooming I shared how I implemented the basic image zooming methods namely ‘nearest neighbour’, ‘bi-linear’, ‘bi-cubic’ on MATLAB. In this article I will share how I used MATLAB built-in function ‘spline ()’ to zooms images on MATLAB.

### Function spline () on MATLAB

Just for getting basic idea let’s have a brief look on the MATLAB spline function. MATLAB spline function performs cubic spline interpolation (on Wikipedia, gatech.edu) for a given data set. The spline interpolation function is as below.

yy = spline(x, y, xx)

The yy[] is the cubic spline interpolated value for the values y[] if underlying function at the breakpoints defined by x[] for the interpolant xx. The first example found in MATLAB help (‘doc spline’) is as below.

x = 0:10; y = sin(x); xx = 0:.25:10; yy = spline(x,y,xx); plot(x,y,'o',xx,yy);

## Contrast Stretching for Gray Scale images with MATLAB

When studying “Introduction to Image Processing and Machine vision” and “Bio Medical Engineering and Instrumentation” for the end semester exam, I read a small section related to those two modules which can be easily implemented using MATLAB. “Contrast Stretching” is a simple piecewise linear transformation function which expands the range of intensity of the image to user defined span.

Simple mathematical illustration of the process is as below.

## GETTING STARTED WITH MATLAB COMPILER

When you using your MATLAB programs such as GUI related things its bit messy to run MATLAB and then to run your MATLAB scripts since MATLAB takes some time to run and it uses more resources from your computer. So it’s very easy if we can run our MATLAB applications without running MATLAB. The MATLAB compiler gives us the opportunity which to convert our m-scripts to exe files. In this article I’ll try to share my experiences on configuring MATLAB compiler and to deploy a MATLAB script to an *.exe file.

## CONFIGURING MATLAB COMPILER

Make sure you got installed ANSI C or C++ Compiler in your computer. First type ‘`mbuild -setup`’ on your MATLAB command prompt.

Press ‘y’ and Enter to continue on operation (Pressing <ENTER> is also sufficient since the default answer is [y].) Then MATLAB will list down all the compilers you have installed in your computer and prompt you to select a compiler to use.

I choose ‘Microsoft Visual C++ 2008 SP1 in C:\Program Files\Microsoft Visual Studio 9.0’ as my compiler, so I enter ‘2’.

## MATLAB GUI programming (code level) 1.0 – Paint Effect for Images

When surfing in facebook I saw a lot of profile pictures which is modified as painted images. Rather than using the facebook apps I thought to write my own program to do it for me. In this article I’ll try to share my experience on GUI programming in MATLAB without MATLAB GUI guide and the construction of the paint brush effect code.

When studying the image with paint brush effect I noticed that the image colour levels are now limited to a low number, which is most likely a one colour intensity to represent a set of colour. By keeping this in mind I coded a small test program as below.

clc, clear all, close all; im = imread('image_3.jpg'); rateR = 40; rateG = 60; rateB = 50; ima(:,:,1) = cast(rateR*round(im(:,:,1)/rateR),'uint8'); ima(:,:,2) = cast(rateG*round(im(:,:,2)/rateG),'uint8'); ima(:,:,3) = cast(rateB*round(im(:,:,3)/rateB),'uint8'); imshow(ima); imhisto(:,1) = imhist(ima(:,:,1)); imhisto(:,2) = imhist(ima(:,:,2)); imhisto(:,3) = imhist(ima(:,:,3)); figure, plot(imhisto);

Hopefully it got worked, what I have done is,

## Switch Mode Power Supplies MATLAB simulation 1.0

When dealing with switch mode power supply design, we faced a problem in simulating SMPS circuits since most of simulation software is not flexible with simulating circuits which has tapped transformers. We face this problem specially on simulating isolated switch mode converters such as fly-back converter.

MATLAB simulink SimPowerSystems block set gives a best solution in simulating switch mode power supplies. From this article I’ll work on design a buck converter works on continuous mode and another in discontinuous mode with calculations and to implement both on MATLAB simulink.

### Design Problem