Thilina's Blog

I might be wrong, but…

Process spatial operations without ‘for’ loops in MATLAB

While working on some image enhancement applications which the intensity of a given pixel is also a function of its location (spatial coordinates), I used to use ‘for’ loops to iterate each pixel at once and calculate its intensity based on (x,y) value obtained from those two ‘for’ loops. This is very annoying since it takes quite some time to process two ‘for’ loops as well as it is a belief that the MATLAB ‘for’ loops are used to slow. In this article I share my experience how I avoided the requirement of two ‘for’ loops by using the properties of complex numbers for a photo effect which I described in a previous article of mine.

Normally in an image there is an mxnx3 matrix which represents red, green and blue intensities respectively. In my case I append another 4th matrix of coordinates which makes the image matrix as mxnx4. (Even-though there is a memory drawback in this design, it is very easy to handle rather than two nested ‘for’ loops).

This 4th matrix contains complex numbers which their real value is equal to row index and its imaginary value is equal to its column index. And now we do have another advantage. Using the properties of complex numbers we can easily calculate the distance and angle between two pixels in interest which is very useful in image effects such as ‘focal BW’.

Continue reading

2013 October 18 Posted by | Image Processing, MATLAB | , , , , | 1 Comment

Photo Effects using MATLAB 3.0 – Image warping using MATLAB – Fisheye Similar Effect

The term fisheye was coined in 1906 by American physicist and inventor Robert W. Wood based on how a fish would see an ultra-wide hemispherical view from beneath the water (a phenomenon known as Snell’s window) (Wikipedia). I tried several domain transformation functions to create the fisheye effect and ultimately I ended up with warping an image into a circle which gives somewhat similar result to the fisheye effect. In this article I am going to share my experience on warping an image in to a circle (fisheye effect, my version).

Here is an example of correct fisheye effect.


Continue reading

2013 April 22 Posted by | Image Processing, MATLAB | , , , | 3 Comments

Setting up VTK and ITK environments for Ubuntu

Visualization Toolkit which is known as VTK is an open source software system for image processing, visualization and 3D computer graphics which is also vastly used in biomedical image processing and visualization. VTK is mainly consists of C++ class library and several interpreted interface layers. ITK is Insight Segmentation and Registration toolkit which is also open source and a cross platform which provides an extensive software tools for image analysis. In this article I am going to share my experience on how to install VTK and ITK environments on Ubuntu.

Continue reading

2013 February 9 Posted by | Biomedical, C++, Image Processing, ITK, Ubuntu, VTK | , , , , | 7 Comments

Photo Effects using MATLAB 2.0 – Optical Illusion using MATLAB – Shake your head and see the image

This is something I found really interesting while wandering in facebook. Most of facebook fan pages shares a set of images which has black and white columns saying “shake your head and see the image”, which will results in seeing a hidden image in black and white column grid. Later when I search google, also found a number of images which similar to the images shared around facebook. In this article I share my attempts and experience on how I create my own optical illusion (shake your head and see image) using MATLAB.

When we look at the image closely we can notice the hidden image with very low intensity, which is not noticeable when we look at it from a average distance of our eye to monitor. This is what I have done and it gives much better results when we use gray scale images than colour images. Fist I made a frame which has black and white columns (binary image) in same size of my source image. Then I performed element-wise multiplication with source image and created brightness shifted and normalized image as follows. Then again it was multiplied element-wise with the negation of frame.

Continue reading

2012 April 12 Posted by | Image Processing, MATLAB | Leave a comment

Translation Invariant Image Registration using Phase Correlation – Panorama Imaging on MATLAB

Panorama Imaging is one of most specialized techniques in photography. The ratio of this photo is 2:1 or larger in size. Nowadays even modern mobile phones also have the feature of capturing panorama images, specially accelerometer based techniques have made it easier to capture wonderful pieces of images in panoramic way. Unfortunately in my mobile phone camera, even though it has panoramic imaging, it does not have such flexible feature on creating panorama images, therefore what I do is take two pictures and stitch them using MATLAB.

Continue reading

2012 March 24 Posted by | Image Processing, MATLAB, Technology | 9 Comments

Hardware co-simulations for image processing applications using MATLAB Simulink Xilinx Block-set

When working with image processing applications on hardware level, during the simulations I personally felt, very hard to work with bit/byte data, without seeing the resulting image/video data. For this kind of application we need to stream in and stream out data bits/bytes to and for the hardware module we implemented. MATLAB Simulink with combination of Xilinx Block-set gives great help in dealing this issue. By using MATLAB we can reshape images in to data stream as well as reshape data streams back in to images in MATLAB environment as I discussed in my previous article.

But the problem rises with the complexity of the system in interest. According to the performance of your computer the simulation time can be varying, sometimes it may be able to take hours. Hardware Co simulations on MATLAB come as the solution for the pc performance limitation issue. In this article I am going to share my experiences on performing a hardware co-simulation on MATLAB with the FPGA development kit Atlys Spartan 6 with xls45-3 FPGA.

Continue reading

2011 December 6 Posted by | Electronics, FPGA, Image Processing, MATLAB, Technology | 1 Comment

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.

Continue reading

2011 September 25 Posted by | Electronics, FPGA, Image Processing, MATLAB | 11 Comments

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.


Continue reading

2011 July 1 Posted by | FPGA, Image Processing, MATLAB | 6 Comments

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”.

Continue reading

2011 June 18 Posted by | Image Processing, MATLAB | 4 Comments

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, 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);

Continue reading

2011 May 5 Posted by | Image Processing, MATLAB | 21 Comments

%d bloggers like this: