Wednesday, August 28, 2013

The curious one



When all the brain-washed look to one direction, the curious one looks the other way.

Thursday, August 15, 2013

Struggling to survive


Vega Omer's famous black and white photo, "Struggling to survive". Very powerful message.

Wednesday, June 5, 2013

Understanding aperture: The 3 types, when to use them, and why

Aperture can feel like a tricky beast at first. But once you have a sense of what it is — the idea of depth of field — it’s time to look at how to put these tools to use for your own vision with photography.
Even though f-stops number from f/1.4 to upwards of f/22, aperture can be divided into three major sections, each with its own distinct use. Which section and corresponding f-stop you choose becomes up to you, and your vision.


Storytelling
What it is: Storytelling aperture is considered to be f/13 and up, as high as f/22, or f/29 on some lenses. If you can recall, the higher the f-stop, the smaller the aperture, and the greater depth of field. This means the image should have front-to-back sharpness.
Uses: This is often used in landscape photography, where you want the foreground just as much in focus as the background. If you’re telling a story, then you need a foreground object, a middle ground, and a background, all of which “lead” your viewer through the image. This could be a dirt road (foreground) leading up to a barn (middle) with puffy white clouds behind (background). It could be a jagged rock (foreground) in a calm, clear lake (middle) backing into the Grand Tetons (background).
Alternative uses: Higher f-stops are often used at night because the tiny pin-hole aperture makes any point of light (i.e., a streetlamp) turn into a starburst. To compensate though, the shutter speed needs to be long and therefore a tripod is necessary.
Do not use for: Faces. Higher f-stops are simply not flattering on the human face.
Drawbacks: When everything is in focus, you need to make sure your viewer knows exactly what your subject is. If it’s not going to be the object most in focus, then you have to use leading lines, composition, and/or light to reveal the subject of the image.
Remember: The higher the f-stop, the less the light. Therefore you need to lower your shutter speed (or use Av and the camera will do it for you), which could mean that you need a tripod if it goes under 1/50. Alternatively, you can boost your ISO, but this adds noise to the image.
Best lens: A wide angle lens (roughly 10mm-20mm) will allow you to fit the whole story into the scene.


The sweet spot
What it is: The range is roughly f/7.1 – f/11. It is said, and overall believed to be true, that f/9 or f/11 are the “sweet spots” on any given lens. That means they have optimum sharpness, contrast, colour, and least amount of lens distortion or aberration.
Uses: These stops are great for street photography and shooting on the move. Overall they are sharp, usually give nice contrast, and generally maximize the optics of the lens in use. They can be put to use for landscapes, street scenes, scenes with people in them, or any other situation in which your “subject” might change quickly (say from a purple door, to a man pushing a cart, with little time to change settings).
Alternative uses: Sunrises and sunsets, where you want overall sharpness and contrast. Also, night scenes where you’re not looking for starbursts but want good sharpness.
Don’t use for: Faces. Even f/7.1 still isn’t the most flattering for portraits.
Remember: Both “storytelling” and “sweet spot” apertures will be hard to work with inside, under shade, or any time the light starts to drop. Same as with “storytelling,” it is up to you to make sure the viewer knows what the subject of the image is, using techniques other than isolation.
Best lens: If you are aiming for street photography, a semi-zoom is the best bet (e.g., 24mm-70mm or 18mm-200mm) to allow you to pull out and back in, as your subjects change. However, in terms of shooting at f/9 or f/11, it’s the sweet spot on nearly any lens.
Isolation
What it is: Apertures under f/5.6, all the way down to f/1.2. The lower the f-stop, the more wide open the aperture, the more shallow the depth of field.
Uses: The main use of a wide aperture is to isolate a subject. When you focus in on your subject — say, a person’s face — the background will blur. This blur can range from slightly out of focus (e.g., f/4) to completely unrecognizable (e.g., f/1.4). When the subject is isolated, it’s very clear to the viewer what the subject of the photo is, which can make for very strong images. It is flattering on faces because of the softer focus, but be sure to focus on the eyes!
Other uses: Lenses that are 2.8 and under are called “fast” lenses. This is because when you have the ability to drop down to f/2.8, f/2, f/1.4, or even f/1.2, your shutter speed can remain high enough to ensure sharpness and clarity. This comes in especially handy in low-light situations: Where kit lens users (often stuck at f/4) will have to attach a flash, boost their ISO (and increase noise), or whip out a tripod, those with “fast glass” can drop down to f/2.8 or f/1.4 and continue shooting (to an extent).
Another use is to create a lovely “bokeh” behind your subject — points of light which become pretty ovals when out of focus. Lastly, it’s useful for shooting situations which require the fastest possible shutter speed, such as macro, sports, or wildlife, so a fast lens is necessary to ensure sharpness, focus, and clarity.
Don’t use for: Landscapes or any scene requiring overall sharpness.
Remember: When opening up to f/2.8, or especially f/1.8 or f/1.4, your focal area — where there is sharpness — becomes very, very small. Even on a face, you can have sharp eyes, but lose sharpness on the mouth or hair (which can look lovely when done creatively). You therefore need to be very accurate that you are nailing your focus on your subject (especially if a face). A portrait with one blurry eye is never a good thing. Another thing to note is that you can create extra blur / bokeh by putting distance between your subject and the background (the closer the background, the more in focus; the farther away, the less in focus).
Best lens: Depends on the end goal. If you’re into travel portraits — where sometimes there is a bit of distance between you and a subject — a fast lens with a bit of zoom is handy, such as 24mm-70mm f/2.8. If you’re really into intimate portraits, the 50mm f/1.8 or f/1.4 is beautiful on faces, though you will have to move your feet to get the right composition.
For shooting wildlife, you need both zoom and a fast aperture, so things start to get pricey. Still, if it’s your thing, a 70-200mm f/2.8 is the way to go (which is also good for travel / street portraits, but overall it’s best to ask rather than try to sneak a shot).

Sunday, May 5, 2013

Numerical Solution to Ordinary Differential Equations

Ordinary differential equations (ODEs) are commonly encountered in scientific and engineering analysis. The simplest form of ODEs is the 1st order ODEs:

y' = f(y, x)

Here, y(x) is the function dependent on x, and it is the function that we want to solve for. X is the independent variable. The left hand side of the equation is the first order derivative of the function y, while the right hand side of the equation is a function that links the derivative to some combination of y and x. Function y is also known in ODEs as the solution function, while function f(y, x) is known as the flow function.

In generally, ODEs can be more than 1st order. It can be readily shown that, any ODEs (of any order) can be rewritten as a system of 1st order ODEs. Take the motion equation for the harmonic oscillator as an example:

x(t)'' = -k/m*x(t)

This equation can be rewritten as two 1st order ODEs:

 x' = F1(x,v,t) =v
v' = F2(x,v,t)=-k/m*x

Here, the harmonic oscillator 2nd order ODE is rewritten as a system of two 1st order ODEs, where there are two solution variables, x and v, two flow functions, F1 and F2, and one independent variable, t.

Numerical solutions to ODEs are readily achievable through discreet integration. The idea is that given an initial condition, i.e. y(x=x0), one can approximately compute the value of y at the next step, i.e. y(x=x0+h), assuming h is sufficiently small. The most straightforward solution is the Euler method. Takes the simplest, 1st order ODE as an example, at any given step, one can approximate the next step as:

y(n+1) = y(n) +h*f(y(n),x(n))

The essence of the Euler equation shown above is that, the next y value can be approximated by the current y value y(n), plus the step size times the derivative (slope) of the current x location, x(n). This is quite a crude estimation, because the derivative of y could change as x changes from x(n) to x(n+1). However, as a first order approximation, sometimes the Euler method is good enough, and its advantage is that it's easy to understand.

The Euler method can be easily extended to solve any ODEs with more than 1st order. As shown earlier, any ODE can be rewritten as a system of 1st order ODEs:

Y' = F(Y, x)

Here, vector notion is used to simplified the presentation of an ODE system. Y is a vector of all the solution variable in the system, while F is the vector of all the flow functions in the system. Therefore, Y is also known as the solution vector, while F is known as the flow vector. For example, in the harmonic oscillator example, Y=(x,v), and F=(F1(x, v, t), F2(x, v, t)).      

Applying the Euler method to an 1st ODE system is very similar to a single 1st order ODE:

Y(n+1) = Y(n) + h*F(Y(n), x(n))

Here, Y and F are both vector, while, h and x are scalar. The equation above in fact represents a set of equations. The vector notation is just to simplify the presentation of them. 
The disadvantage of the Euler method, despite its simplicity and intuitiveness, is that it's quite unstable, and tends to produce large error. In the next blog entry, we will introduce another method, the Runge-Kutter method, which is the work house for most of numerical analysis of ODEs.

Friday, May 3, 2013

Block comment and uncomment codes in VIM

In VIM, it is quite easy to comment/uncomment a block of lines.

To comment a block of lines:
a. Ctrl-V and mark the block of lines to be commented out;
b. shift-I and write the text that you want to prepend to each line, e.g. #
c. press escape.

To uncomment a block of lines:
a. Ctrl-V and go down vertically until the last commented line;
b. press x.

Thursday, April 25, 2013

Memory Segmentation of a Compiled Program

When a program is compiled and executed, it is loaded into the computer memory as binary codes.
Such binary codes of one program is structured in five segments, in the memory space. Each segment represents a special portion of the memory that is set side for a certain purpose.

Figure 1



The five segments of program memory are shown in figure 1. The first segment is called the Text segment, or Code segment. This is where the assembled machine language instructions of the program are located. Once started, the cpu will read and execute these instructions, one at a time. The register EIP always points to the next instruction to be executed. The execution of the instructions is not necessarily linear in the memory space, since the flow of execution is often redirected by control structures and functions.

The Data and Bss segments, are used to stored global and static variables. Specifically, the data segment is filled with initialized global and static variables, whereas the bss segment is filled with their  uninitialized  counterparts. Both data and bss segments are of fixed sizes.

The next segment down in the memory axis is the  Heap segment. It is a segment of memory that a programmer can directly control. Blocks of memory in this segment can be allocated and used. The size of the heap is dynamic, and it can be managed by allocator and deallocator algorithms. This means a programmer using the heap allocation functions can reserve and free memory on the fly. The growth of the heap moves downward toward higher memory addresses.

The last segment, Stack segment, is a very important a unique segment that deserves more explanation. In a modern program where a lots a functions are called by the main function, The flow of the instruction execution is managed by a mechanism call stack frame. When a function is called by the program, the program needs to remember a few things: the address of the next instruction to run after the function call is finished, the set of local variables associated with this function, the parameters passed to this function during this call. All of these information is stored collectively in the block of memory called stack frame. Each function call will create a stack frame in the stack segment. Figure 2 shows the content of one stack frame.

Figure 2


In the stack frame shown in Figure 2. Starting from the bottom of the stack, parameters passed to the functioned called are stored. The address of the instruction that the execution flow will return after the function call finish is stored above the parameters. The next slot up (lower address) is the so-called saved framed pointer, which is the address of the frame pointer of the previous stack frame. The address of this slot is stored in the EBP register, which always stores the frame pointer of the CURRENT stack frame. Above the saved frame pointer, the local variables are stored. The top of the current stack frame is always pointed by another register, ESP. If the function in question is calling another function, then the value in ESP will become the value of the frame pointer in the next stack frame. After the call of the function, the current stack frame will be popped out, and the previous stack frame then becomes the current stack frame.

Monday, April 15, 2013

US Imperialism and China

US imperial dreams, however, are hardly confined to setting the Middle East ablaze. Imperial ambitions—rooted in the capitalist logic of endless expansion—are inherently limitless. Thus, we see the US today readying to propel the greater Middle East into the abyss, while simultaneously “pivoting” to the Asia-Pacific in order to “contain” a rising China.

US imperialism, however, is destined for defeat (and sooner rather than later). The US, after all, can only use its immense military power to keep potential competitors in check for so long. The universal law of change cannot be held at bay by the barrel of a gun in perpetuity. As Lenin asked and answered in his pamphlet Imperialism: “Is it ‘conceivable’ that in ten or twenty years’ time the relative strength of the imperialist powers will have remained unchanged? Absolutely inconceivable.”

But imperial powers are always dangerously deluded by the strength of their power—impervious to its ultimate limits. As a George W. Bush administration official once remarked to the journalist Ron Suskind: “’We’re an empire now, and when we act, we create our own reality. And while you’re studying that reality—judiciously, as you will—we’ll act again, creating other new realities, which you can study too, and that’s how things will sort out. We’re history’s actors…and you, all of you, will be left to just study what we do.”
(One would be mistaken to believe that such hubris is not as present in the Obama White House as it was in the Bush administration.)

Such arrogance from the power elite—indicative of imperial rot—is but a byproduct of the imperialist imperative of endless expansion and conquest. And it is this very imperative that today compels US imperialism towards igniting a military conflagration in the Middle East threatening to ensnare the global powers. “A great cemetery,” as Luxemburg warned nearly a century ago, awaits such a triumph of barbarism."

A few months ago, James Baker remarked on the Charles Rose show that America is Greece if the dollar were not a reserve currency. Yet the US refuses to reduce Pentagon expenditure even though investment on infrastructure construction is much more productive. Obama's current strategy is that the US could pursue its war policies indefinitely as long as no Americans are killed. That is the reason why drones are extensively used all over the world. However, I firmly believe that this empire building policy is unsustainable and sooner or later the US will follow the Soviet Union as the next country that collapses economically due to military overspending.

Here is what Paul Craig Roberts (an editor of the Wall Street Journal and an Assistant Secretary of the U.S. Treasury) wrote recently:  "Why is Washington ramping up a new cold war?

The answer begins with President Eisenhower’s warning to the American people in his last public address about the military/industrial complex in 1962. I won’t quote the warning as it is available online. Eisenhower pointed out to Americans that unlike previous wars after which the US demilitarized, after World War II the cold war with the Soviet Union kept the power and profits flowing into the military/industrial complex, now known as the military/security complex. President Eisenhower said that the flow of power and profit into the military/industrial complex was a threat to the economic wellbeing and liberty of the American people.

No one paid any attention, and the military/security complex was glad to be rid of the five-star general war hero president when his second term expired."

"In other words, the problem with hot wars is that the need not to win them in order to keep them going (Korea, Vietnam, Iraq, Afghanistan are all long-term wars never won) in order that the profits and power continue to flow to the military/security complex demoralizes the US military and creates the world-wide impression that the “world’s sole superpower” cannot even defeat a few thousand insurgents armed with AK-47s, much less a real army.

In Iraq and Afghanistan more US soldiers have died from demoralization and suicides than from combat. In Iraq, the US was humiliated by having to end the war by putting the Sunni insurgents on the US military payroll and paying them to stop killing US troops. In Korea the US was stopped by an army of a backward third world country that lived on rice. What would happen today if the US “superpower’s” militarily confronted China, a country with an economy on which the US is dependent, about equal in size to the US economy, operating on its home territory? The only chance the evil in Washington would have would be nuclear war, which would mean the destruction of the entire world by Washington’s hubris.

Fortunately, profits are more important to Washington than ending life on earth. Therefore, war with China will be avoided, just as it was avoided with the Soviet Union.

However, China will be presented by Washington and its prostitute media, especially the New York Times, Washington Post, and Murdoch’s collection of whores, as the rising threat to America. The media story will shift the importance of America’s allies from Europe to countries bordering the South China Sea. American taxpayers’ money, or newly printed money, will flow into the “new alliance against China.”

China’s rise is a great boon to the US military/security complex, which governs america in which there is a pretense of “freedom and democracy.” China is the profitable replacement for the “Soviet threat.” As the days go by, the prostitute media will create in the feeble minds of Americans “The CHINA Threat.”

Soon whatever little remains of the US living standard will be sacrificed to Washington’s confrontation with China, along with the seizure of our pensions and personal savings in order to deter “the China threat.”
If only Americans were an intelligent people. Then they might have some prospect of holding on to their incomes, remaining wealth, and liberty. Unfortunately, Americans are so thoroughly plugged into the Matrix that they present as a doomed people, incapable of thought, reason, or ability to comprehend the facts that the rest of the world sees clearly."

All this hype about Iran, China, etc. is all designed to ensure that the Pentagon does not get hit by budget cuts!!!