Friday, March 26, 2010

3D from Structured Light

posting some progress...

grade (0-10): 6 na:)






Stereometry

posting progress...
grade so far (0-10): 4 haay naku:)





High Dynamic Range Imaging

posting some results (need to complete later on)
grade so far (0-10): 8.5, malapit na!:)


This is a Plasma Image seen thru a viewing Window:
These are Plasma Images taken with the same camera but with different exposure times per picture:


For each image, 5 pixel locations were chosen within the viewing window,(row, col) =
800,600
600,900
1000,900
1000,370
600,370

these locations were chosen so that we have some locations which are dark and some which are bright to capture a wide range of possible pixel values.

and for each of these pixel locations, we have varying pixel values as we change from different images(i.e. varying exposure times)



But, for each exposure time, we can get the log of delta T (T=exposure time), and plot the pixel values (same mark = same pixel location) as we change exposure times as shown below:

These points can actually make up the new "transfer function" to increase the dynamic range of our camera by calculating a best fit for the group of points above and combining all "sub_groups" into one smooth function that "extends" both ranges of the pixel values and the exposure times.

Camera Calibration

just posting the outputs first...
self-grade so far (0 - 10) : 8, wait lang:)











Sunday, March 7, 2010

A Freeman's Silhouette




The Freeman Code has garnered a number of applications in image processing. Some Malaysians (http://paper.ijcsns.org/07_book/200911/20091132.pdf) have used the Freeman Chain Code for car plate number recognition. Filipinos (http://people.ee.duke.edu/~qh/classes/spring2007/ece635/index_files/papers/curve_spread.pdf) have used the Freeman Vector Code for Silhouette Processing for use in frontal human gait recognition (apparently, we can also recognize people just by the way they walk:) <-- how true in my HS barkada!)

Sample Freeman Transformation / Encoding

The Freeman Code is a shape representation of a boundary of connected pixels(4-connected or 8-connected) where each pixel is numbered according to it's relative position. This representation scheme is very powerful since (1) it preserves the information of interest(the outline/edge), (2) it permits compact storage(just an array of numbers!!), and (3) facilitates processing.

So for the Gait Silhouette, the Freeman Code looks like:

From this Freeman-coded representation, we can even get concavities just by applying a simple gradient running average onto the freeman code array which results in some + / - or 0 values that is indicative of whether there is a convex or concave curve or none at all:)

Now, for this activity, I chose to look at race tracks.:) Why?? well, i was studying some mobile robot tracks and google earth images at this time(with some roads) :) I guess this is what came first into my mind then when I heard: edge + curve + image. hehehe

and so here are some race tracks, clean, ideal, made from paint!

I chose to process the 2nd one. The one with a thinner outline so that i do not have to do any edge detection anymore.



I used the freeman transformation shown above(Sample Freeman Encoding) which Soriano et al also used in their Curve Spread work.

Now, let's see if we can also get the curvature information:)



Notice how the values swing from + to - to zero. The signs indicate whether the curve is convex or concave, and zero means straight.



Grade for this Activity: 1.25 ... or from 0-10, 9.5 i think i could have done this sooner and without being so messy:)

Hough Tough on my Laf-tof


This image is a picture of Eden Nature Park's Greenhouse Hydroponic Vegetable Garden:) Where else can you find such a wonderful agricultural wonder but in Davao City, Philippines:)

We were asked to choose an images with lines to use the Hough Transform with, I chose the image above:)

The Hough Transform is a useful tool for shape identification in images. Commonly used to identify basic shapes, such as lines, the Hough transform can be invoked for a variety of applications: road mapping, surveying, structure analysis, etc.. Hough operates on binary images (white/'1'-valued and black/'0'-valued), where black = background, so before using the technique, make sure that the image has been pre-processed so that the pixels of interest are white.:)



The image below is a B&W version of a cropped section of the Eden Pic.
The way I understand Hough is not that it ain't that tough.:) For me, it's a mere transformation /"transposition" into the polar coordinate system("circular" system as opposed to the Cartesian "flat" system). By this, I mean that we can represent an image in terms of each pixel having a specific radius and angle from a fixed point. So, instead of saying (x,y), we have (r, theta), gets?:)

(refer more to this for a review of polar coordinates: http://csdt.rpi.edu/na/shoban/polar/polar.html)


The advantage of having to represent our image in (r,theta), as what the Hough transform does, is that we can then identify which pixels actually lie on the same line!:) How??

(Warning: geeky part here...) [Reference: http://www.cogs.susx.ac.uk/users/davidy/teachvision/vision4.html ]

Representing each pixel as (r, theta) enables us to plot the image in an r-theta graph which gives us some cyclic patterns (since we are traversing the image not from left to right, top to down, but rather from -90 to +90 degrees). In this graph, each "sinusoidal strand" represents one cycle and in each cycle, we mark out only those where pixels are present (valued '1' / colored white).
Hence, when we are able to represent the whole image in terms of these sinusoidal strands, we find that there are more intense points which correspond to pixels lying on the same line!:) (remember the equation of a line: y=mx+b; theta will be related to slope; and since one line=1 slope, you'll get the same theta values for pixels on the same line)


I tried the Hough Transform in scilab using this original image:

and came out with this "polar" graph:

I really didn't know what to do after that but i decided to shift to Matlab (hehehehe) since i know this tool better:)


Shown below is a figure with 2 subplots. The top plot is the Original cropped Truss image and the bottom plot is the r-theta graph produced by the hough transform.
Notice how this Hough transform is in "Hot" colormap with the most intense pixels being yellow, or bright orange or white. The x axis is theta and the y axis is r. we limit theta to -90 to 90 but the r can go negative of positive which then tells us simply that the span of this hough space covers the entire 360-degree possibility for the allowed radius, r of the image.

Shown below is the same Hough Transform plot in r-theta but without the colormap. This image was generated using the houghpeaks function in Matlab. Marked in white squares are the top 20 most intense locations. The r-theta information of these locations are potential lines.:)
Using the houghlines function in Matlab, the figure below is generated. This shows the overlay of the potential lines as investigated through the houghpeaks function and we see the possible lines with the blue line as the longest line detected using the hough transform.

Notice that the lines detected were those that were thin (edges) not the broad ones:)

Grade I give for this activity: 1.25, or from 0-10, 9.5 - i could have done this faster...

Sunday, November 22, 2009

Image Segmentation using Histogram Backprojection


Can you spot the difference? Clue: RGB. nyargh! hehe the left pic is the Red Channel of the original image(see below for the orig true color pic), and the right pic is the Green Channel. What about the Blue Channel? sorry, i'm from U.P., blue=ateneo:) haha joke.:)

and there you have it!:) haha, read on so that you get why this post is entitled as such.

We were given an activity that would enable us to do some tracking from images. The end-goal: object tracking in videos using chromaticity as main feature. Why chromaticity? Well, it's because our skin (everybody's) only falls within a small locus of the chromaticity region (whoa! that's how i understand it) and that the difference in skin "color" is actually just a function of brightness/intensity.

Face detection is one cool application (for webcams, videocams, digicams, cellphone cams, etc...) that should use this "chromaticity-as-skin-info" concept.:)

As an exercise, last friday (Nov 20, 2009), we had an image segmentation lab activity:

- Select an Image where you have an object you wish to detect/identify (and eventually segment from the rest of the image). Note: better start with objects that are easily identifiable:)

For my selection: Davao Eden Nature Park Jump Shot with Friends!:)


- Crop a Sample of the Region of Interest (ROI) from the image(say, for my selected image, i wanted to segment the shirt of Kim GuanHing)

So i got a kim shirt sample:


- Get the Histogram of the Sample. Now, we have the representative feature that we want to detect in the original image and in future images (with the sample being kim's shirt - which is the object that we will detect and later on "track")



- Load the Image that you want to segment/detect/identify IF the sample(object to be tracked) exists in the image(and where in the image it is).

- Run the the Histogram Backprojection code which does this: for each pixel in the loaded image, get the chromaticity value (red and green channels) and look-up the new_value of the pixel using the Sample's(Kim's shirt) histogram as your "re-mapper" (i.e. for a given r and g, you can get the new_value) Note that the values in the histogram of kim's shirt will be high for those pixels that are "like" kim's shirt and low for those un-like kim's shirt:)

Segmented Kim Shirt (creepy?):)


side comment: interesting app for baduy-colored shirts worn in malls?:) hehe i actually want to run this algorithm for cars in the carpark of malls and integrate with the parking payment system:) suuuuuuppppppppppeeeeeeeeeeeeer cheap sol'n to an intelligent car park system:)

to do: try other kim shirt pics and see if the algo can detec kim's shirt in those pics!:)

hopya-layk-eat!:)

-------
Self Grade: Uno:) or from 0-10: 10!:) kasi naman from zero scilab experience ito:) and then ang laki ng learning leap sa chromaticity plus the backprojection implementation (Apir!):)

-------

lochinvar's note to self: must try python implementation (use your openCV webcam, for face detection!)