Friday, December 14, 2012

Plotting a pentagram with MATLAB.


Figure: As seen after running the code

This is a MATLAB code to plot the symbol of pentagram on a Cartesian coordinate system. The symbol consists of 1 circle and 1 pentagram - a 5-pointed star drawn with 5 straight strokes.

Basically this algorithm focuses on the getting the coordinates to draw:

(1) the circle and
(2) the horizontal line.

Later the horizonzal line is manipulated to generate the other 4 lines to form the pentagram.



Contents

The variables

n = 2^8; % Number of sampling points
t = linspace(0,2*pi,n); % Interval
noSides = 5; % Number of sides of the polygon
innerAngle = 2*pi/noSides; % Interior angle of a pentagon.

% Variables for the cirle
r = 2; % Radius
h = 0; % Transition distance
k = 0; % Transition distance

xsfact = 1.3; % Factor to extend the display range of the xy-axes.

Equations for the circle

x = r*cos(t)+h;
y = r*sin(t)+k;

Equation(s) for the horizontal line

% The length of the horizontal line
lH = r*sin(innerAngle)*2;
% Distance to the horizontal line from the center
dist_lH = r*cos(innerAngle);
% The definition interval of the horizontal line
xH = linspace(-lH/2, lH/2, n);

Rotation

Here the horizontal line from the previous will be simply duplicated for 4 times. Every point (x,y) will be multiplied with a 2D-rotation matrix.

side = zeros(2,n);
side(1,:) = xH;
side(2,:) = -dist_lH;

side1rot = rot2d(innerAngle)*side;
side2rot = rot2d(innerAngle*2)*side;
side3rot = rot2d(innerAngle*3)*side;
side4rot = rot2d(innerAngle*4)*side;

Plotting

figure,
hold on
plot(x,y, 'r')
plot(xH, -dist_lH, 'r')
plot(side1rot(1,:), side1rot(2,:), 'r')
plot(side2rot(1,:), side2rot(2,:), 'r')
plot(side3rot(1,:), side3rot(2,:), 'r')
plot(side4rot(1,:), side4rot(2,:), 'r')
hold off
axis(xsfact.*[min(x) max(x) min(y) max(y)])
title('Das Pentagramm')


Monday, December 10, 2012

Report on the Seminar: Media and Democracy



On the last Nov. 2 until Nov. 4 of 2012, World University Service e.V. (WUS) through its wing STUBE Hessen (stands for STUdienBEgleitprogramm) organized a weekend seminar with the theme: Media and democracy: On methods and means of mobilization. This event was held in a youth hostel in Fulda, a Baroque city located to the east of the state Hesse. Around 18 foreign students were present, all from numerous Hessian colleges - Frankfurt, Darmstadt, Fulda, Marburg, Giessen and so on. Three presenters delivered talks during separate sessions and it was moderated by a representative of STUBE from WUS headquarter in Wiesbaden (the capital of the state Hesse). This is the writer's report on this event.

For participation on its programs, STUBE targets foreign students from Asia, Africa and Latin America. Students of nationalities such as Mongolian, Chinese, Chilean, Mexican, Georgian, Albanian, Kenyan, Nepalese, Syria etc were spotted during this event.

During the introduction session on the day of our arrival, participants were introduced to the President of the Uni. of Applied Sciences of Fulda, Prof. Dr.-Ing. Karim Khakzar, who was accompanied by his daughter. He expressed welcome to us to the city Fulda and briefly informed us about his college.

The talks/lectures

Among the objectives of this seminar was to discuss some questions on the social media, which is proven to be a critical factor in today's politics everywhere in this world. This was so as many recent and current events - London Riot, Arab Spring, Barack Obama's Presidential Campaign etc, were known of involving a lot of mobilization via social media such as Facebook, Twitter, Reddit and so on. Therefore the invited lecturers were picked from relevant backgrounds - one graduate student of information science, an NGO activist and a journalist who happened to be an active blogger. All talks were delivered in English.

The first talk was delivered by a Vietnamese postgraduate student from Darmstadt, Mr. T.A. Nguyen. He gave a presentation which taught the pariticipants about the Internet and its impacts. Began with the introduction to the Internet, he lead us to the issues of network security, related incidents such as the London Riot and Wikileaks and censorship.

Then Mr. T. Kowohl, a law clerk by profession, talked about NGO-campaigns, mentioning some case studies from Amnesty International, of which he is a member. His objective is to show us the risks and benefits of social media froma legal perspective. He also requested us to form groups, in which the participants were to discuss make suggestions to Amnesty International on how it should conduct its campaigns everywhere.

On the next day, the final talk was delivered by Mr. J. Kucharz. who is the editor of the website http://netzfeuilleton.de/. He mentioned that he wanted to engage us into becoming our own media mogul, by starting to be active in online media. Various successful examples on online media were shown to us - bloggers, authors, YouTube-ers and so on. The Participants have also discussed the question of how they envision the media landscape of the future.

The Baroque city Fulda

That was the writer's second time coming to Fulda - the first one was in January 2009, when the writer went there as a lone wolf. Nothing much has changed since the last time. Prof. Khakzar, who the writer has mentioned above, told us that Fulda has the reputation of being the cleanest city in Hesse. It does not have much attractions for students - i.e. students find this city not so entertaining at nights, hence the weekend life of students here are relatively quiet. This, as Prof. Khakzar has alleged, is contributing to the high rate of students graduating from Fulda. The writer personally would agree with that, since Fulda is located so far away from other major cities in Hesse - 2 hours of train journey from Frankfurt alone to get there.

Nevertheless, some of the participants attending the seminar, went out during the second night in Fulda. They searched for any student-friendly place to have drinks and they have managed to spot a cosy shisha bar. The writer can't recall the price, but the writer would say it was so affordable that one could order one shisha just for oneself alone.

The conduct/behaviour of the students

Some students were found to be very articulate - actively asking questions and expressing opinions, accompanying their points with examples from their respective home countries. However a few of the participants could also be considered as rude, impolite and irritating because they talked to each other during the lectures, half as loud as the voice of the presenter in the approximately 50 m² room.

Apart from that, a few students also were found to be unfocused or diverted from the main objectives of this seminar. Some were even expressing disappointment that current political issues e.g. Arab Spring were not brought into discussion - as they thought this was the purpose of this seminar. As the writer thought this critic was unnecessary and unfair to the organizer, The writer pointed out that they have been not reading the clear descriptions of this seminar on its brochure, which was already distributed much earlier.

During the second / last night in the youth hostel, some students who were staying (not going to the shisha bar), used the seminar room as a place to put on some loud music and dance. They were having fun until one 40-year-old-plus man, who happened to be another guest the hostel, came to them and gave a threat, telling them to stop partying or he'll complain tomorrow to the hostel admin, saying that this would be their last time to come here. That was very ironic, since this hostel was supposed to be a youth hostel.

Summary

This seminar can be considered as successful in achieving its objectives. Participants were exposed on the availability of social media as a very useful tool in promoting their causes - be it political or anything else. Participants generally found the conducting of the seminar in English very favorable. The seminar has motivated the writer to be more active in using social media, hence by being active again in writing on this blogspot. The venue - a youth hostel in Fulda - it was a good place to hold a instructive events such as this, but located very far from the central  part of Fulda.

Thursday, November 15, 2012

Easy Curve Fitting with MATLAB



Basically this exercise is about an easy and common curve fitting, which is used on a set of raw data points. The book 'Mathematische Formelsammlung' by Lothar Papula was referred for this exercise and its particular chapter is 'Ausgleichs- oder Regressionsparabel'.

Your mission, should you choose to accept it, is to fit a parabolic curve of the form y(x) = a*x^2 + b*x + c, to the given set of raw data points.

At the end of this post, I've included the link to download the M-script file.

Raw data
x = [-3:1:5]';
y = [-3.94 -1.47 -4.66 -3.21 0.84 7.24 15.58 27.94 42.59]';
[n,m] = size(x);
Calculation
The curve parameter a, b and c can be determined from the method of least squares (German- Methode der kleinsten Quadrate), which uses linear equation system with 3 equations and 3 unknowns.

x4 = x.^4;
x3 = x.^3;
x2 = x.^2;

sx4 = sum(x4);
sx3 = sum(x3);
sx2 = sum(x2);

sx = sum(x);
sy = sum(y);

x2y = x2.*y;
xy = x.*y;
sx2y = sum(x2y);
sxy = sum(xy);
Formation of the known matrices
The targetted matrix equation is as follows: A*K = vekb. Out of those 3 matrices, A and vekb are known.


A = [sx4 sx3 sx2;...
    sx3 sx2 sx;...
    sx2 sx n];

vekb = [sx2y; sxy; sy];
Determination of the curve parameter
The matrix K consists of the parameters - a, b and c, that we sought after. Simply multiply the inverse of A and vekb, both gained from the previous step.
K = inv(A)*vekb;
Generation of new data points
By using the gained parameters in K, new points can now be plotted.


yneu = K(1)*x.*x + K(2)*x + K(3);

Plotting

The displaying of the result.

M-Script code:
MV_Blatt_1_Aufgb5.m
p/s: just in case that you're not using MATLAB or Octave, that file can also be viewed in normal text editor =P

Thursday, September 13, 2012

Mission: Get them to study in Hessen



On the last Sept. 3, 2012 I was invited to deliver a talk to the Germany A-Level Preparatory Program (GAPP) students at the German-Malaysian Institute (GMI) in Bangi, Selangor.

My presentation's intro slide


I prefer to refer the GAPP students as the Redshirts - because of their uniform, which I also wore once as I was one too from 2003 to 2005 there.

Here I would like to apologize for putting too much German terms on my presentation slides. Many of the words were too new for them. My intention was only to introduce them those words that they WILL eventually come by again, if they are to study in Germany.

So, as a friendly gesture, I hereby release the Powerpoint file online for the Redshirts to download. It has been added another slide in the end - a list of the German words which were used in the presentation slide with their similars in English.

Studieren in Hessen - Ein Vortrag von Hafiz Jaafar.

I wish you all the best, Redshirts.

Sunday, August 19, 2012

Image Processing with FPGA




Typical solutions of image processing, which are always seen in university laboratories, are run fully with the CPU of the computers which apply them. Those solutions, usually of real-time type, require a large memory capacity of each computer’s RAM. Hence the burden on both the CPU and RAM is high, which will slow down the computer and in the worst case: it will crash or cause a hang. Therefore FPGA – field -programmable gate array, is increasingly applied as an extra hardware to the computer to assist the task of running the image processing solutions. This article discusses a recent laboratorial test for image processing with FPGA, which was conducted by Mr. J.P. Bernecker and the writer, two postgraduate students of University of Applied Sciences of Darmstadt (Hochschule / HS Darmstadt). The test result showed that a real-time solution can be easily executed on a low performance computer with the help of FPGA.

NOTE: This article is written as a translated simple excerpt from the test report which was produced by two students mentioned above and was originally written in German language. Among the sources are named in the end.

During the Summer Semester 2012 at the HS Darmstadt in Germany, the students of the postgraduate course Optical Engineering and Image Processing (Optotechnik und Bildverarbeitung) had to run different laboratorial tests for the subject Industrial/Applied Image Processing (Angewandte Bildverarbeitung). The writer was paired with his lab partner to run 2 tests for image processing which used FPGA.

The other tests available to those students were such as inspection of liquid mixture using infra red camera, observation of the Venus transit etc.

Figure 1 - Linescan camera Basler Sprint spL4096 - 70 km
The test was conducted using two main instruments – a linescan camera (Zeilenkamera) and a frame grabber card, which comes with the field-programmable gate array (FPGA). The linescan camera has only 1 row, hence 1-dimensional, of pixel, which is different than conventional cameras which use CCD or CMOS chip with 2 dimensional array of pixel. The linescan type is mainly utilized in barcode reader, fax, scanner etc. In the following Figure 1 the camera which was used for this task is depicted along with its sensor. This is a model of Basler Sprint spL4096 – 70 km, with 4096 pixel along its column.

FPGA
FPGA is an integrated circuit, into which a logical circuit can be programmed. Alternatively it can be understood as a reuseable silicon chip. To program an FPGA , high languages such as VHDL (Very high speed integrated circuit Hardware Description Language) are used. The FPGA has diverse, prefabricated logic blocks, of which the purposes are to comprise the logical connection of conditions of the input signals to the output signals and to inquire as well as to set the conditions in periphery elements over specific I/O blocks.

With the logic blocks such chips can be so configured that they implement certain hardware functions. The configuration files originate from the compilation of digital algorithms that are developed into softwares.

Framegrabber
Figure 2 - Frame grabber Spartan XC2S 600 E-FPGA
The FPGA chip which was used in this test is a type of Spartan XC2S 600 E-FPGA, a product of the firm Xilinx Inc. This chip is mounted onto a frame grabber MicroEnable III-XL (see Fig. 2), which is produced by the firm SiliconSoftware. A frame frabber is an intelligent card/electronic device for high quality image acquisition and processing. The frame grabber sets up the connection between the camera and the computer.




Why Image Processing with FPGA?
FPGAs are used to reduce the large data streams from hardware into frame grabber. In FPGA-assisted image processing, the necessary computing power for image analysis is significantly decreased. This is the result of less work processes that fall to the CPU/processor, which does not have to partake in the procedures of image analysis. Therefore the latency/time delay from the image acquisition at the input until the output after the processing is notably recduced. Examples of image pre-processing with the help of FPGA are image transformationss, corrections of shadow effects and binary morphology.

The Test: Oscillating String
Figure 3 - Setup of the test
The test which was given to this 2-man groupd consists of 2 parts: Static image of a rotating roller and the swinging string. The former’s purpose is to teach students about the parameterization of linescan camera.

However this article will only discuss more of the latter, as it is directly about the application of FPGA as image processor. The objective of this test part is to detect the oscillation of a guitar string via the linescan camera (see Fig. 3)





Figure 4 - Oscillation of the guitar string
- an inverted gray level image
In the process of detecting the oscillation, the center of gravity (COG) of every image row and the instantaneous position of the string will be determined (see Fig. 4). With those determined COGs, an audio file of WAV-format will be generated, which replicates or recreates the detected oscillation of the guitar string. This WAV-file can be easily played on conventional media players. Audacity, an open source software, was used in this test.






Figure 5 - The VisualApplet design
which was used to detect the oscillation

The following image (Fig. 5) shows a design – a program which is developed on the platform VisualApplets. This design was a work of a previous group (students Mr. U. Häberle and Mr. Klöß) and was allowed to be used in this test to ease the current group’s jobs. The programming on VisualApplets is quite complex and requires more time than the allocated for this test, especially for beginners. One can notice that the interface in VisualApplets is similar to those of MATLAB-Simulink and LabVIEW.

This design consists of the following steps – loading the images in the buffer, inverting, converting to binary images and the generation of a WAV-file.

Due to some problems, the design above has been synthesized – i.e. a C++ source code is generated from the design and the program is run from Visual Studio, instead of the proper platform microDisplay, which comes along with VisualApplets in the complete package.

The outputs of every execution of this program are always the same -  a TXT-file which lists all the calculated COGs and the expected WAV-file.

With Audacity, the oscillation or displacement of the guitar string is visualized and further deductions can be drawn (see Fig. 6).

Figure 6 - The playback of the oscillation via Audacity
From this image, one can easily notice that the guitar string was plucked five times during the period of image acquisition.

Conclusion
This test has served as a platform to deliver a good insight into the possibilities and problems that are associated with FPGA technology. The C++ program which was run from Visual Studio has yielded comparable and good results. Apart from that, the execution of the software caused frequent crash, hence the frequent restart of the computer. Such tests should use only prepared applets, as the developing of one’s own applet is too extensive for an experiment which must be done in only two period blocks (90 minutes each) per session/week.

Sources

  1. National Instruments Tutorium: Einführung in die FPGA-Bildverarbeitung mithilfe des NI LabVIEW FPGA Module (Jan 04, 2012)
  2. National Instrumens Tutorium: Einführung in die FPGA-Technologie: Die 5 größten Vorteile (May 20, 2012)
  3. SiliconSoftware - Official website http://www.silicon-software.de/
Nisi Dominus Frustra.

Sunday, June 10, 2012

Studying at the Hochschule Darmstadt, Germany


A brief introduction to Hochschule Darmstadt


Starting from Summer Semester 2012, I am pursuing a Master's degree in Optical Engineering and Image Processing at the Hochschule Darmstadt (another Hessian public university of applied sciences).


HS Darmstadt [1]
HS Darmstadt, or 'h_da' as the college uses it commercially, is situated in the city Darmstadt, just south of the metropolis Frankfurt am Main.


As usual, students here are entitled to use the transportations of the RMV within its region. From Darmstadt in the south, up to Marburg in the north of Hesse, as well as from Hanau in the east to Mainz (in the state Rheinland-Pfalz) in the west. In other words, just like the rest of the students in Hesse, mobility is easy for them.


Malaysian students at the h_da


Currently there are 3 Malaysian students at this college, including me myself. The other 2 (ladies) are students under the scholarship of Yayasan Telekom Malaysia, a foundation of Malaysian telecommunication consortium. Both are studying electrical engineering.

So far there has been only 1 known Malaysian graduate from this college, who has studied mechanical engineering and was a scholar of the JPA/PSD.


Courses available at the h_da


Under this adress one can find the whole list of courses taught at the h_da:
Studienangebot der HS Darmstadt

Optotechnik und Bildverarbeitung at the h_da


Here I would like to highlight the course which I am currently taking. Firstly I will tell you, how I jumped into this field due to my experiences during my undergraduate studies.

I am a graduate of mechatronics engineering and during the last phases of my studies in mechatronics, I took an elective subject - Industrialle Bildverarbeitung (industrial image processing). From that subject I took a keen interest in this field, hence agreed to take a project (Projektarbeit), which was compulsory and of which the theme was a simple image analysis (Bilderkennung). From this project I looked further to search a theme with digital image processing for my final thesis (Diplomarbeit), which landed me an attachment at the German firm Werth Messtechnik GmbH in Giessen. At the end of my thesis I had realized that I need proper trainings, lessons or courses in image processing, if this field is what I want to do for my professional job, hence the master course in the h_da.

This course is an engineering discipline in the industrial and research field in optical technologies. The Optotechnik (optical engineering) covers optical metrology, laser technology and classical technical optics including its modern elements such as microoptics, illuminations and fiber optics. Meanwhile, Bildverarbeitung (image processing), also known as machine vision, combines illuminations, image acquisition and the processing of image datas for technical and scientifical applications. [2]

I can name a few examples of the application of image processing, used in scenes in 2 Hollywood films:

1) letters/pattern recognition which was featured in the recently released film Mission Impossible IV (Ghost Protocol): the early scene involved face recognition.

2) length/height measurement - featured in the film The Italian Job (2003): from the traffic camera at the streets, the tyres of the security trucks with the gold are measured from the captured images.

Applying for a placement

Generally among the uni. of applied sciences in Germany, for the intake Summer Semester (SS) every year, usually the closing date of applications is July 15, whereas for Winter Semester (WS) it is January 15.

Those closing dates may seem to cause a predicament for applicants who will get their test results (A-Levels, Test DaF, DSH etc.) AFTER the dates. Nevertheless, to my knowledge, applicants CAN still send their forms for courses, which are NOT classified as Numerus Clausus (NC). NC-courses, such as medicine, are considered critical for Germany and applications for them are strictly limited.

Should you prefer to apply ahead of the deadline, I would recommend you to prepare your documents with some support/statement letter(s), which states that your test result (e.g. German language test) is pending. I would say, your applications might be accepted and you get your placement, but eventually you MUST show your original test result/certificate upon immatriculation/registration day. Immatriculation or registration day does NOT mean the first day of the lectures.

At this link, you can find your way to apply online for a placement at h_da:

Online application for Hochschule Darmstadt







Sources/Quellen:


[1] Brigitte Zypries [SPD], Darmstadt - Studieren in Darmstadt
[2] Optotechnik und Bildverarbeitung, Fachbereich MN, HS Darmstadt

Tuesday, June 5, 2012

Studying at the TH Mittelhessen





Technische Hochschule Mittelhessen (Uni. of Applied Sciences Mittelhessen)


Having been among the earliest MARA students to enroll in and to graduate from the Technische Hochschule Mittelhessen or THM (formerly known as Fachhochschule Giessen-Friedberg), I feel obliged to promote this college to other fellow MARA as well as others (JPA, YTM etc.) to study here.


THM with campuses in Giessen (main campus), Friedberg and Wetzlar, is the largest public university of applied sciences in the state Hesse.


For the undergraduate courses - the courses which are taken by us MARA students are mechatronics and mechanical engineering.
THM's website


However many more courses are available, such as E&E, EIT, ICT etc.


THM's official website is http://www.thm.de/site/ .

Under 'Fachbereiche', one can find the list of the faculties of THM.


The mechanical engineering courses - with different majors, are divided into both campuses Giessen and Friedberg.


Mechatronics engineering course falls under the latter faculty 'FB 12'.


As of now, in the Summer Semester 2012, there are three JPA students who are undergoing Master's course in THM Campus Friedberg. Certain Master courses like their's are conducted in English.


Malaysian graduates from TH Mittelhessen


Until now, as of Summer Semester 2012:-



  • Mechanical engineering (Friedberg): 2 MARA students (Diplom)
  • Mechatronics engineering (Friedberg): 1 MARA student (Diplom)
  • Medical engineering (Giessen): 1 MARA student (Diplom)
  • Biotech/Biomedical (Giessen): 1 private student (Diplom)
  • Information and Communication engineering (Friedberg): 1 private student (Master)



The town Friedberg


Friedberg is situated between Germany's financial hub city Frankfurt am Main and Giessen.
Both cities are easily reachable via railway transports.


Enrolled students in the state Hesse usually have the 'RMV-Semesterticket' - which is also counted in the semester fees, and allows students to freely ride public transports like buses, trams, regional and subway trains within the region covered by the consortium RMV. So the question of mobility for students in Hesse is hardly a big issue here.


To be able to reach the large and hectic Frankfurt for shoppings, weekend hangouts etc while living peacefully, with relatively low living costs in Friedberg - is what the town Friedberg does have to offer to us students.


Applying for a placement?


Simply go to the section 'Bewerbung + Immatrikulation' at the website.


On behalf of the students in Friedberg, I would like to urge Malaysian students, who are aiming to study in Hesse especially in the town Friedberg or Giessen, to approach us, if our asssistance is needed.


- Vivat academia, vivant professores -