Philippine Geoportal System

May 6, 2013 Leave a comment

I’ve been into geographic information systems (GIS) lately and I found out that there is an ongoing project by the Philippine government to create a national GIS for the country. The project is called the Philippine Geoportal: One Nation, One Map. It started year 2012 under the collaboration of the National Mapping and Resource Information Authority (NAMRIA) and DOST – Advanced Science and Technology Institute (ASTI). This web-based geospatial platform is on its beta version and is publicly viewable at

This electronic map contains information on infrastructure, roads, lands and bodies of water. It has a search feature that allows you to easily locate the place you are looking for.


Though the buttons and links aren’t fully functional yet, I can see the zooms and pans are working fairly fast (even for slow connections).


I’ve spoken with a few people from NAMRIA and they said they are working on adding more geospatial data and creating smart functionalities on the geoportal. One is related to traffic, which will be extracted from geo-tagged status updates on Twitter, real-time. So next time you tweet about “traffic” on the network, try to get your geo-locator “on” – you might be able to share this info not just with your followers, but also with the users of the Philippine Geoportal.

Working with Time on Oracle

March 29, 2013 Leave a comment

As I’ve mentioned in my previous post, we were working on a hospital database for our case study, and that includes storage of Appointments (that’s future date + time). I noticed it odd for Oracle that it doesn’t display time, by default. And it doesn’t have a datatype specialized for time. So I found this tweak using SQL, which you might consider helpful as well.

Let’s say my APPOINTMENT table looks like this:




You may need to enter this before every session, because Oracle’s default setting doesn’t include time at all. HH24 means you will be using a 24-hour time setting – that’s less troublesome than having to deal with AM/PM texts, which you need to parse (I think).

INSERT INTO appointment (appt_no, appt_date, confirm_status, cpt_code, patient_no, prov_no, room_no)
VALUES('APT0011', TO_DATE('05-Feb-2013 14:30', 'DD-MON-YYYY HH24:MI'), 'T', '97810', 'P00019', 'PR0008', '102');
SELECT appt_no, TO_CHAR(appt_date, 'DD-MON-YYYY HH24:MI') appt_date, patient_no
FROM appointment;

Notice that I used the TO_DATE() function to store the time data and the TO_CHAR() to retrieve/display it.


NOTE: The Time data will be displayed only upon query (via TO_CHAR()), not in the Object Browser. Well, at least we know it’s stored.

Let me know if it worked for you (or not).

Categories: Machine fix Tags: , ,

Correcting optionalities at MS Visio

March 29, 2013 3 comments

The past month, I was studying the basics of databases, and among the things I had to learn along the way are Entity Relations (ER). Databases are composed of tables (called entities) that are to be connected based on their dependencies towards each other. Our instructor introduced us Microsoft Visio as a good tool to make Entity Relationship Diagrams.

In an ERD, each table has its own columns (called attributes) with at least one of them set as primary key to identify uniquely to that table. Depending on the relationship between entities, a table can inherit the primary key of another table as foreign key, and thus become a child to the table (parent) it is referencing to. Out-bound parent links can be set as mandatory or optional, and the child link cardinalities can be set such that parent-to-child relationships are:



1 TO 0 or more

0 or 1 TO 0 or more
1 TO 1 or more

0 or 1 TO 1 or more
1 TO 0 or 1

0 or 1 TO 0 or 1
1 TO 1

0 or 1 TO 1
1 to Range [at least N, at most M]

0 or 1 to Range [at least N, at most M]

In visual representation, the entity closest to the crow’s feet is the child.

When we were doing our case study on a hospital database, I had trouble trying to create a mandatory link from the parent entity (which should be displayed as two straight lines, instead of just a line and a ring). (Shown below)


In this scenario, ROOM is the parent entity and MEDICAL_SERVICE is the child entity and we need to fix their relation (highlighted below).


Under Miscellaneous > Child has parent, what we are supposed to do is to uncheck Optional.


The problem (the problem!) is that it’s grayed out (disabled). So …

Here’s the workaround:
Under Definition, disconnect associated relations. Make sure the key you choose is the one being inherited (in this case, Room_No)


Go back to Miscellaneous > Relationship type, make sure it’s set to Non-identifying. Under Child has parent, you can now (finally) uncheck Optional.


and voila!


There’s the mandatory relation right there.

Ink caricature via edge detection and morphology

February 25, 2011 4 comments
I’m gonna teach you
how to turn …



into THIS →

In this post, I’ll be showing an algorithm for generating an ink caricature out of a face photograph. Using a series of basic image processing techniques we will extract the features of the human face and then reconstruct them into a black-on-white sketch with details similar to brush (or pen) touches. This is useful for those who wish to avoid the work of manually producing such artworks. In addition, this set of methods can serve as initial groundwork for more intelligent and advanced algorithms in creating digital caricatures.

The overall algorithm can be summarized as follows:

Firstly, we choose a good threshold value to produce a satisfactory binary conversion of the raw image.  The parameter value should be sufficient to capture and preserve the important features of the face (i.e. eyes, brows, facial linings, teeth, etc.).

Applying edge detection using a spot filter would obtain the important linings of these facial aspects.

grayscaled image
binary equivalent
detected edges

Notice however that though we were able to capture the details of the face, due to the limitations of the photo (dark hair against dark background), we were not able to capture the details of the hair.  This is because the dark areas were not acquired/obtained by the chosen threshold value.  This can be resolved by applying value inversion, which changes the brightness of the pixels, but not the color.  We use the built-in method in Scilab, rgb2hsv(), to accomplish this and then revert it back its RGB representation.

img = rgb2hsv(im)
// img (:, :, 1) → HUE
// img (:, :, 2) → SATURATION
// img (:, :, 3) → VALUE

img_value = img (:,:,3);
img (:,:,3) = 1 – img_value;
im = hsv2rgb(img);

After applying the same methods performed above, the following pictures show the captured details of the photo.

grayscaled image
binary equivalent
detected edges

Next, we combine the edges detected for the face and the hair and obtain the overall edges for the face photo.


We remove the pits and holes by applying a simple morphology using a structuring element in a shape of a circle. Note that for a 5×5 matrix this would appear more like a diamond (like the one below), but it is the best shape to approximate the touch of a inkbrush or pen.

After morphology, we invert the processed image into its black-on-white equivalent and finally obtain our ink caricature.

structuring element
resulting image after morphology
inverted value (our ink caricature)

This set of methods also show to be effective for various facial expressions.

Raw images courtesy of DailyMail.

The limitations however are that (1) the methods sometimes need human supervision in choosing threshold values, so to make sure all the valuable features of the face are captured (aesthetic reasons, i.e. eyelashes, dimples, etc.).  (2) The effectiveness would depend on value contrasts, thus the need for value inversions. (3) The caricature detail would depend on the brush/pen size preferred and would greatly affect its accuracy.

[1] Soriano, 2010. Binary operations. Applied Physics 186.
[2] Soriano, 2010. Fourier Transform model of image formation. Applied Physics 186.
[3] Wikipedia, 2010. Caricature.
[4] Portrait Workshop, 2010. Types of Caricatures.

Convert your MP3 bitrates via terminal

November 8, 2010 1 comment

Image courtesy of technabob.

I just had my machine reformatted for a new Ubuntu version and I spent hours the other night reorganizing my files.  I realized that among the ones taking up most of my disk space are my MP3 files.

MP3 is a lossy audio compression scheme, but you can actually take the option to reduce its bitrate (say for your small capacity MP3 player) without losing much of the quality.  Some music files are at 320kbps, but the standard rate is 128kbps.  You will realize that a file has a high bitrate if the size is too large for the song length.

You can calculate the size of an MP3 file using this:

z = (x * y) / 8

x = length of song (in seconds)
y = bitrate (in kilobits per second)
z = resultant file size (in kilobytes) – dividing by 8 gives the result in bytes

So let’s say you have an MP3 of length 3 minutes = 180 seconds.  At 128kbps, your file will be as big as:

z = (180*128)/8 = 2880kb = 2.880Mb

Compared to when you have it at 320kbps:

z = (180*320)/8 = 7200kb = 7.200Mb

Now that’s significant difference when you have thousands of MP3s in your disk.  Most people take the option to convert their MP3 files using a software (e.g. SoundConverter, another FOSS app).  But if you would like to keep things light on your machine, you would wish instead to install the library LAME (a recursive acronym meaning LAME Ain’t an MP3 Encoder).  For more information on this package, run: man lame.

So how does it work? To do the bitrate conversion, run on the terminal (as root):

 lame --mp3input -b <bitrate> <file.mp3> <destination.mp3> 

where the bitrate could range from 8 – 320, depending on your need.

If you have more than a handful of MP3 files, you can automate the conversion using the following shell script:

 for f in *.mp3 ; do lame --mp3input -b <bitrate> "$f" <path_to_destination>/"$f" ; done 

Note that leaving the destination parameter as null saves the file in the form file.mp3.mp3 while setting this parameter to your player’s location causes your file to land there.

[1] Wikipedia, 2010. MP3.
[2] Jhollington, 2004. kbps ?. iLounge Forums.
[3] Ubuntu Packages, 2010. Package: lame.
[4] Ubuntu Development Team, 2010. “lame” package. Launchpad.
[5] Vanadium, 2007. Convert MP3 bitrate. Ubuntu Forums.

Mozilla at SFD Philippines 2010

November 8, 2010 Leave a comment

Mozilla had a huge success in this year’s celebration of Software Freedom Day in the Philippines.  In the event participated by about 700 students and technologists, we were able to reach the big crowd about Firefox and the Open Web.

We are glad that other than being a sponsor, we also initiated funwares such as the Mozilla Open Art and the Best Mozilla Description (in five words).  We happily exhausted the Firefox swag package to the excited crowd of students from Metro Manila and a number of provinces.

We would also like to thank Mr. Regnard Raquedan, our Mozilla Community Leader, for giving a talk on Fennec for Mobile at the Breakout Sessions and for the cool trivia information he has shared.  A million thanks also go the the Student Reps who helped man the booth.  At the end of the day, people loved Firefox (and its principles) all the more, like “kickass cool”.

The full SFD Network Event Report is available at the SFDPhils Website.  More of the Mozilla photos are found on my Picasa. The entire event was fully covered by Ms. Charlotte.

On behalf of the SFDPhils Organizing Team, thank you Mozilla for being part of the huge success.  The event would have never been complete without your support.  We hope to continue this endeavor with you in reaching others about freedom and openness in the next years.

Your Mozilla Student Rep,

Theiss ;)

Categories: Events Tags: , ,

14. Image compression

September 24, 2010 2 comments

Image compression has been the means of reducing the size of a graphics file for better storage convenience.  It is also a useful way of reducing the time requirement of sending large files over the Web.  Here we will explore a method in image compression by Principal Component Analysis (PCA).  This technique utilizes the idea that any image can be represented as a superposition of weighted base images.

Suppose we have the following image and its grayscale conversion:

Figure 1. A sample image (characteristically sharp)and its grayscale equivalent.  Courtesy of SuperStock.

We divide image into blocks of 10×10 dimensions and concatenate them.  These sub-blocks are arranged into an nxp matrix, where n is the number of blocks and p the number of elements in each block.

We apply PCA on the matrix with the pca() function in Scilab. which returns a set of eigenvalues, eigenvectors and principal components.

Figure 2. Plot of eigenvalues (A) and principal components (B) of the image.

This produces eigenimages which would be essential elements to the compressed image.

Figure 3. Eigenimages derived from the original image.

Eigenvalues tell how essential a particular set of eigenvectors is to making up the completeness of the image.  Based on these values expressed in percentages we choose the most important eigenvectors and reconstruct the image out of these.  Figure 4 shows the resulting images at 86.7%, 93.4%, 95.5%, and 97.5%.

Figure 4. Compressed reconstructions of the image at different numbers of eigenvectors. 1, 3, 5 and 10 respectively.

We can find out how much of the image has been compressed by counting how much of the eigenvector elements were used in the reconstruction and/or determining the file sizes. Our original image has the dimension 280×340 and is stored at 75.3KB (grayscale).  When compressed with only a certain number of eigenvectors (figure above), becomes reduced to 44.2KB, 51.3KB, 53.9KB, and 60.7KB respectively.

When circumstances do not really require high-definition images, it is often best to compress the images into a good size such that it’s quality is not compromised and information is well-kept.

For this activity, I would rate myself 10 for the job well done. :)

Credits: Jeff A. and Jonathan A.

[1] Soriano, 2010. Image compression. Applied Physics 186.
[2] Mudrova, Prochazka. , 2005. Principal component analysis in image processing.
[3] TechTarget, 2010. What is image compression?


Get every new post delivered to your Inbox.