Saturday, October 18, 2008

Thursday, October 16, 2008

Pixels and image resizing

I came across this document about how pixels are not "little squares", and read it because I was under the impression that pixels were, in fact, little squares. I was wrong, and to summarize the document's point as I understand it: a pixel is more useful to us as a point sample of an image that exists independently of the resolution of the display. More on that in a second.

For me, the idea that pixels ARE little squares is an easy one to believe because of low-res video games where assets are visibly made up of little squares. Mario, for example, doesn't appear on the screen as a miniaturized (photographic) picture of a plumber, but is simply a relatively small number of squares of relatively few different colors arranged to sort of LOOK like a little plumber. The pixels are so big and each one constitutes such a large percentage of the entire image that they have to be considered blocks with which an image is made and not samples representative of a more complex image. If the size of Mario should increase (via zooming in, not via mushroom), then the pixels that form him should increase at the same rate, and not be blended or filtered in any way. Mario IS little square pixels and they should remain in tact.

Pixels in photographs, however, should be too small to consider individually, and should not increase in size as the size of the image increases. Instead the pixels should be spaced farther apart, and the resultant gaps should be filled with colors that would create a smooth transition from one sample to the next. This isn't a perfect solution, of course, and a higher resolution source will probably always look better than a low-res source upscaled to a higher-res, but the idea of resizing by treating the pixels as samples on a continuum of color values is far more useful visually than considering them picture elements which necessarily change in size along with the image.

Here are two examples of a four pixel matrix made up of four different gray scale values. The one on the left is magnified about 20x and each pixel is 20x bigger as well. The one on the right is also magnified 20x, but each pixel was treated as a sample and spaced to the corners of the final image while all the rest of the pixels were filled in using values derived from the four samples.

The derivation is achieved by essentially drawing a circle around the sample, the edge of which abuts the next sample. The center of the circle is the sample color, and the edge of the circle is the closest sample's color, and everything in between is a percentage of both based on a cosine curve. Real image editing software uses a Gaussian filter which uses a more complicated formula, but the shape of the curve is similar to a cosine, so I went with the COS, modified a bit so that COS(0) = 1 and COS(180) = 0. Of course, not every derived pixel will be based on only two samples, and there's a large field in the center of the box that is an average of all four samples. The algorithm I came up with to find each value is:

FOR i = 0 TO 19
FOR j = 0 TO 19
Dist1 = SQR((j - 0) ^ 2 + (i - 0) ^ 2)
Dist2 = SQR((19 - j) ^ 2 + (i - 0) ^ 2)
Dist3 = SQR((j - 0) ^ 2 + (19 - i) ^ 2)
Dist4 = SQR((19 - j) ^ 2 + (19 - i) ^ 2)
IF Dist1 <= 18 THEN
CurPixel = CurPixel + Pixel(0) * (1 + COS((Dist1 * 10 * PI) / 180))
Total = Total + 1
END IF
IF Dist2 <= 18 THEN
CurPixel = CurPixel + Pixel(1) * (1 + COS((Dist2 * 10 * PI) / 180))
Total = Total + 1
END IF
IF Dist3 <= 18 THEN
CurPixel = CurPixel + Pixel(2) * (1 + COS((Dist3 * 10 * PI) / 180))
Total = Total + 1
END IF
IF Dist4 <= 18 THEN
CurPixel = CurPixel + Pixel(3) * (1 + COS((Dist4 * 10 * PI) / 180))
Total = Total + 1
END IF
IF Total > 0 THEN
PSET (50 + j, i), CurPixel / 2
END IF
CurPixel = 0
Total = 0
NEXT j
NEXT i

And looking it over again, it's a little bloated, but it works by counting from 0 to 19 twenty times to consider each of the pixels on the final 20x20 image. For each iteration of this loop, the four distances between the current pixel to the four samples (the corners) is found. Then, if the distance to a corner is less than or equal to 18 (the edge of the circle drawn around each sample), then the color of that corner is considered in the current pixel's value, and that color is defined as a percentage of the original color determined by the cosine of the distance from the corner multiplied by 10. That way at a distance of 0, the color will be 1*Original (COS(0*10)*Original), and at a distance of 18, the color will be 0*Original (COS(18*10)*Original). Each of the applicable colors is added together and divided by 2 (to be honest, I'm not exactly sure why 2. It doesn't represent an average since every value is divided by 2 even in the places where there are 4 samples, but I like how it looks) and then drawn in that position.

And maybe everyone already knows this, and maybe I'm not writing any of this in a way that makes any sense, but I thought it was interesting how image resizing works, and I thought I'd take a stab at making it work on a small scale and then try to show it to somebody.

Full code on comments.

Obama / McCain: Perspective

Wednesday, October 15, 2008

Rumble in....Long Island (or something)

Say it bitches!

Bob_Schieffer

Zero Punctuation: S.T.A.L.K.E.R. Clear Sky

WoW 3.0 Patch: First Impressions

Realms are finally back up so I had a few hours to play around with the new features in 3.0. What follows is a quick compilation of my first impressions of 3.0 which will obviously be well thought out and exhilaratingly phrased.

Achievements:
3.0 implemented an achievement system (zomg xbox hax) that records, well, achievements. Complete a dungeon on heroic? You get an achievement. Sound stupid? It sure does. But these are surprisingly more compelling than I initially gave them credit for when they were leaked a few months ago. Think of it this way: Conceptually? Yeah, who the hell cares; there is a note in a database somewhere indicating that one owns 50 mounts. Realistically? Achievements are another component of the completionist component of WoW; achievements are something else to collect; Achievements provide new goals. So, there is a compulsion to fulfill these requirements especially when one has "done everything else". The compulsion may not be strong for everyone, but it is there.

Statistics:
Oh my god, statistics. With the achievement system Blizzard added a new statistics system. Do you want to know how much total damage your character has done? Do you want to know how many times you have used a portal, a hearthstone? Do you want to know what your most common enemy killed is? Do you want to know how much money you have spent on flightpaths? Do you want to know how many quests you have done? Do you want to know how much gold you have obtained via looting, quests? Do you want to know more than you've ever wanted to know about your character? I contend that you do. The new statistics interface affords you this opportunity. Though, it must be pointed out that it only records statistics for 3.0 and beyond except in a few cases where it may infer past activity.

Pet / Mount Interface:
With every major update Blizzard fixes a fundamental problem with WoW. Storage has been a steadily increasing problem in the game as there is a finite amount of bag space. So amassing large collections of mounts or novelty pets (each of which took up a storage slot) was simply a waste of space. With the new Pet / Mount Interface all Pets and Mounts are stored in a sort of spellbook. So wherever one is one has access to all of one's Mounts and Pets whereas before one only carried a few mounts and pets with them and the rest were in the bank or never purchased. So while before owning 50 mounts would be a needless waste of space and gold now it is only a needless waste of gold. Additionally, once one obtains 50 mounts they fulfill an achievement which unlocks a pretty sweet looking flying mount.

Barbershops:
Stupid

Currency Window:
Instead of having marks and tokens from various battlegrounds and other areas amass in one's bank they now exist in an incorporeal "currency window". It saves bag space. Also? Before there was always that chance that one would go to a Badge vendor yet forget the badges in one's bank. Now that is not a problem.

Graphic Updates:
Blizzard changed WoW's shading style in 3.0. Even though this is a subtle change it greatly enhances the aesthetics of the gameplay experience. I think philosophy of art is stupid so I can't explain this in any technical way. But the game looks better now. Though, this may only be noticeable for someone who has over 2 months of /played time.

Inscription:
Inscription is the new profession added in 3.0. All I know about it is that there is a Glyph which allows Mages to turn an enemy player into a penguin. By a chance stroke of luck this is also all I need to know, ever, about Inscription.

New Skills / Threat System / Spell Damage itemization:
I dunno. My guess is that the skills are neat and the combat system works. Did I mention that MAGES CAN TURN A PERSON INTO A PENGUIN!? I did? Cause, that's pretty fucking sweet...

Northrend:
Northrend is apparently accessible. It's also very snowy. I haven't been there yet; I hope it has penguins. Oh, speaking of penguins, Mages can now turn an enemy player into a penguin.

Complaints and Grievances:
The statistics / achievement system really needed to have been in effect since day one. There is something about having a "total damage" meter implimented years after the fact which does not sit right with me. Another example is that there is a "total fish caught" stat. Interesting? Yes! Except I've already maxed my fishing skill. So those thousands of fish I caught are completely divorced from my "total fish caught" statistic in the statistics interface. The other problem is that raid/instance progression is inferred from one's current inventory. So, since I have the sword that drops off of Gruul when he dies I have credit for completing Gruul's lair. Someone who ran Gruul's Lair before today but who had no items to indicate this does not have the achievement; they have to run it again to get the achievement. That's kind of lame.

Overall Impressions after playing with 3.0 for 2 hours?
3.0 provides enough *new* to manifest a desire in me to play again which is not based in obligation but rather is based in a compulsion to explore. I have not had that in a while; I appreciate it. Sure, it's still the same game. But it's always only ever been the same game. Except now pets and mounts don't take up bag space and there is a terrific statistics system. Also, there is a new continent. Additionally, warlocks can now turn into demons. Party buffs now affect the whole raid, too.

AND MAGES CAN TURN AN ENEMY PLAYER INTO A PENGUIN!!!!!!!!

Tuesday, October 14, 2008

Amity Shlaes on Daily Show



Amity Shlaes explains why the economy is shitty.

Are we a Free Market Society?
"We live somewhere between and that's the lie. You have to pick"

YEAH.

Monday, October 13, 2008

Semicolon '08

In all of this talk about economics, society, energy, and racism I think the 2008 Presidential Campaign has ignored what I feel is the most important issue affecting average, everyday Americans. Perusing a forum this image sparked my imagination and rekindled my fervor for this most fundamental concern:


HYPHENS SUCK!

The above protestor obviously understand this as he stands in opposition to the slogan "Baby-Murdering Muslims for President". I, too, fundamentally oppose "Baby-Murdering". In what way does that or any hyphen provide clarity? How can one know what is truly communicated by that unruly bastard of grammar and insult to word construction?

No, my friends, the time has come to make a stand; the stand taken by this Ohio man as well as many others. The time has come to declare our grammatical allegiance in this election. And so I unveil my own allegiance with the following hastily made logo:



Semicolon has been our steadfast friend and ally throughout our grammatical lives. Semicolon conjoins related independent clauses which are themselves not conjoined with conjunctions. Semicolon conjoins independent clauses which have been linked with a transitional phrase or a conjunctive adverb. Semicolon stands brazenly between items in a series which themselves contain internal punctuation. Above all else semicolon is used to separate independent clauses which are conjoined with coordinating conjunctions when the clauses have internal commas which might be misread due to the ambiguity of the comma.

Semicolon has no ambiguity! Semicolon does not waver in its meaning, its purpose, its eternal utility in our average and everyday existence as grammatical beings! Now is not the time to waver in our allegiance! Now is not the time to manifest indifference towards our grammatical futures! Now is not the time to be hyphens! Now is the time to be Semicolons! Now is the time to stand strong between the independent clauses of our lives! Now is the time to declare in one unanimous voice our support for Semicolon '08!

Because Fuck Hyphens; That's Why!

Who's Nailin' Paylin

Larry Flynt is both a brilliant visionary and a crass opportunist. But we do not begrudge him this as he provides us with Sarah Palin look-alike porn.

Per TMZ:

The faux Sarah is Lisa Ann, who "will be nailing the Russians who come knocking on her back-door." In another scene -- a flashback -- "young Paylin's creationist college professor will explain a 'big bang' theory even she can't deny!" There's also a threeway with Hillary and Condoleezza look-alikes.

And if that didn't sell you on it perhaps this will:
PALIN: (seductively) You're in luck. I fully support off-shore and on-shore drilling.

Or

PALIN: Fuck me harder! HARDER! Pound me until my head is so empty that I can't even remember the name of the one Supreme Court case I actually know! I want it to burn. Burn like a banned book. Oh God, Oh God, OH MY GOD! MAKE ME SEE RUSSIA FROM HERE!

This is not downloadin' porn. This right here? This is buyin' porn.

NSFW Screenshots. They aren't that kind of NSFW, but they are still NSFW.

Sunday, October 12, 2008

Barack Roll'd



Amazing.

Truly. Amazing.

McCain Defends Obama...to boos