Solving the 2048 tile game

Shreesh Katyayan:

Ahh!! This has a solution too :o All I tried was brute force :p

Originally posted on Interstellar Overdrive:

I have working pretty hard on multiple projects recently, and that’s why I haven’t got the time to document my experiments with Cubieboard 2, but rest assured a good number of blog posts are coming up on that front.  However, I picked up this game from the internet called the 2048-tile game. Its a pretty neat (and addictive game) you can find the link here.

Here is the jist of what the game is – you have a 4*4 tile board and begins with 2 tiles with the number “2” on them. You can use the arrow keys to move all the tiles on the board in the 4 directions. Two tiles with the same number with combine to form a new tile with the next power of two, when they move in the direction you want them to.

Also, with every direction move, the game spawns a random…

View original 566 more words


Simple Guide to ISO Settings

Have you ever connected your earphones to an amplifier? Try this once. Connect you earphone to an amplifier rather than directly connecting it to your laptop or MP3 player. Now, keeping the volume low on the source (laptop or MP3 player), gradually increase the volume from the controls on the amplifier. You would notice a slight hiss kind of sound. This sound goes on increasing as the volume is increased.

Very similar to this is the relation between ISO setting of camera and image noise. But before moving on to it, just recollect the old cameras/SLRs. Those days, films were used in the cameras on which image negative was developed. Depending on the requirements of the photographer, he used to choose films of different sensitivity. After the arrival of digital sensor in the cameras, this concept was termed as ISO. The ISO setting controls the sensitivity of the image sensor towards the falling light. Hence we choose proper ISO setting under any given lighting condition in combination with the aperture and shutter speed to get proper effect. But, increasing ISO also produce image noise. This noise can be seen pretty easily after the ISO settings of 400. After 1600, depending on the camera sensor, either image noise and/or color noise becomes too much to recover a sharp image.

If ISO gives noise in the image, why do we use high ISO at all?

The answer is very simple. There are situations when you cannot reduce shutter speed beyond a certain limit else you get motion blur. Neither can aperture be reduced too much every time, because then depth of field is reduced significantly. In such cases, the only option is increasing the sensitivity of the digital sensor. Or even in cases where a part of the subject is under shadow, you have to use higher ISO so that entire image seems evenly exposed.

So, the question: When to use a low ISO?

One should always try to use the lowest possible ISO to retain the details in the image after post-processing attempts. In cases where there is plenty of light, use ISO as low as 100-200. This will result into images with nearly zero noise in most of the dSLRs. Even in low light conditions, try to shoot with a tripod, so that you can afford slower shutter speeds and hence can reduce ISO. Also, try to use reflectors to even out the lighting in the areas where shadows are more prominent.

When to use a high ISO then?

Most beginners don’t buy a monopod/tripod for beginning. It is one of the most essential tools which one should always have. Otherwise, you can go for higher ISO settings under low light to compensate for the under-exposed conditions. A few times, using higher ISO becomes necessary:

  • While shooting star trails.
  •  A relatively higher ISO would be needed when you want to freeze motion.
  • While shooting Indoor sports

and so on so forth…

Technical Note – Why higher ISO deteriorates the image quality: A camera sensor stores data as pixels. When using higher ISO settings, each of these pixels are more sensitive towards the incoming light. This works fine in increasing the overall exposure, but the higher light sensitivity causes problems. Higher the sensitivity, more is the tendency to gather the reflected light from atmosphere. This includes even the light being reflected from the dust particles hanging around in the atmosphere. That is why we encounter Gaussian as well as Salt-pepper noise in images shot at higher ISO.


Vibrance vs. Saturation

As a beginner myself, there was a time when I was too confused between the terms Vibrance and  Saturation. Both of them seem to be doing quite similar things. Both of them are used to enhance the color of the image. But there is a catch. This short article is just about that.

Saturation:

Saturation ~ Saturation in day-to-day life means being full of something. In photography too, it is more or less the same. Saturation tool is used in places where one has to enhance the overall colorfulness of an image to make it stand out of the subject. This can be used in places where the color of image is washed out due to excessive lighting or poor image quality. This operation increases the net area under the histogram of the image.

Vibrance:

Vibrance ~ Most of the guides on web define vibrance as the milder form of saturation. But that is not the case. Vibrance is used to enhance the colors that seem bleached without affecting the properly developed hues and shades. This comes handy when due to improper lightning, color in a few part seem to be washed out. In such cases, manually increasing the saturation of individual colors also cannot help, because it would saturate the colors in those areas too where the color seem fine in the original image. Hence, in such places, increasing vibrance is the best option hence balancing the overall color content of the image.

Original image of Ramnagar Fort

The image was taken near noon, thus the color of the building is too washed out than the original building.

After increasing the vibrance slightly, the color of the building was restored to what is looked like in real life, without affecting other shades. Hence the color of all other parts were restored.

After increasing the vibrance slightly, the color of the building was restored to what is looked like in real life, without affecting other shades. Hence the color of all other parts were restored.

On the other hand, increasing the saturation of the image by a similar value added orange tint to the building along with the yellow, hence making it appear artificial and hard to the eyes. Also notice that the colorfulness of the other parts of the image has also significantly increased

On the other hand, increasing the saturation of the image by a similar value added orange tint to the building along with the yellow, hence making it appear artificial and hard to the eyes. Also notice that the colorfulness of the other parts of the image has also significantly increased.

Technical detail: An image is nothing but a matrix of data(in form of HSL/RGB etc.) If the data is saved in the HSL format, then

  • H = Hue (Which color should that pixel represent)
  • S = Saturation (How colorful shall the pixel be seen)
  • L = Luminance (What should be the intensity of light being released from the pixel)

Now considering a sub-matrix out of this large matrix of the image, various editing operations are performed. Saturation increases the color content of the entire matrix. This is done by increasing the numerical data corresponding to the S data field in the matrix of image. On the other hand, Vibrance enhances color content of all those pixels whose color saturation is less than the neighboring pixels in the matrix. In simpler words, Vibrance is a constricted Saturation operator.


And so was ICPC!

Had a flight on 2:30 pm,  reached I.I.T. Kharagpur.

Had ICPC Asia Regional the next morning.

Damn! You should be excited about it!!(n number of exclamations) That’s what so many of us dream about!

Believe me, we were! With our semester exams still going on, another-low-grade-semester fear haunting us, we were still busy with CodeChef and CLRS. Ahh! :’) Wish those days never ended! Most of you would be expecting it to be a treat from our experiences, some expecting it to be a guide to Do’s and Don’ts. Sadly, this ain’t that! I just blabber.

The fun was knowing for certain that the semester is already screwed up, and that you could still save it if you try just a bit too hard…. And then on the other thought, you have to practice for those GREEDY algorithms, and for various data structures, the GRAPHS, TREES and blah blah, which you aren’t yet done with….. And you watch 3 Idiots instead! :’) ON LOOP that is! Was that all?

No, memories begin to clot when I think of the time, sitting with my team-mate in his room, planning endlessly on what all was important for the “Showdown” and what could we safely omit for this time. For sudo_random, ICPC 2013 was not about winning, it was about accumulating experience, giving a tough fight and then coming back with a satisfaction that We will surely be tough competition next time.

  1. NEVER go to an such events last moment. We reached Kharagpur mere 4 hours before the event was to start, post-midnight. Although full of excitement, we were too tired. A bit too much. It took its toll when our seemingly perfect algorithms failed in implementation. We did lack practice, owing to our laziness, but being tired made us miserable.
  2. PRACTICE makes perfect. If you are not Petr Mitrichev, don’t just practice thinking for solutions, code for any encountered problem statement. It doesn’t just improve your thinking capabilities, it enhances how you implement what you think, and certainly your debugging and typing skills, which certainly do matter on a close call.
  3. Have a team of 3 people, who although are average in coding, but form a great team together, rather than having a team of 3 genius who can’t work as team. TEAMWORK is the key to success. A team with great spirits and lots of practice, and certainly knowledge of limits of his/her teammates does have greater chances of winning than a loosely knit team.
  4. Always think as team, NOT as individuals. It’s the team that has to perform in the event, not the individual!

Still, ICPC == fun :D If you love coding, do dirty your hands… ICPC certainly is the platform to test your skills, but nonetheless, it even is a great experience to learn.

Hope next time, this blabbering would be about ICPC World Final!

Saiko no koun!!


#Sonnet 116

Let me not to the marriage of true minds
Admit impediments. Love is not love
Which alters when it alteration finds,
Or bends with the remover to remove:
O no! it is an ever-fixed mark
That looks on tempests and is never shaken;
It is the star to every wandering bark,
Whose worth’s unknown, although his height be taken.
Love’s not Time’s fool, though rosy lips and cheeks
Within his bending sickle’s compass come:
Love alters not with his brief hours and weeks,
But bears it out even to the edge of doom.
If this be error and upon me proved,
I never writ, nor no man ever loved.

- William Shakespeare

 


Lightroom 5.0 Guide: Basics Interface

One of the leading product in the field of post-processing of photographs, Adobe Photoshop Lightroom is the leading seller in the field. What makes the software so widely accepted? Why should any photographer use it? What is it’s stronghold? Before I move on to these topics, I would like to discuss something more important than this, which arises in anyones mind, when you are new to this field:

Why not PHOTOSHOP?

Adobe Photoshop is one of the most feature rich applications of this time, no doubt about that. But it has its own set of limitations too. For example, it uses layers to save any form of edits, thus increasing the file size significantly. Also, any operations are performed on the raw file itself, and any accidental failure to take backup may lead to the loss of the original image itself. Photoshop doesn’t allow you to manage multiple files at a time, so you have to import every single image, edit and export it before moving on to the next one. This can be a tedious task if editing images after some event photography, a wedding or Live show of your favorite band, where you would be having some 100-150 odd pics to sort out and enhance. SO? IS THAT THE END?? This is where Adobe Photoshop Lightroom comes into the picture.

Lightroom 5.0: Intro

Lightroom 5.0 Intro

Adobe Photoshop Lightroom is one of the leading sellers in the series of softwares available in the field of post-processing. It is not just another image manager like Adobe Bridge, it is in itself an image management application which allows the user to access and edit the images and also various added features like creating a slideshow gallery or a web gallery etc. which make it stand out of the crowd and be a state-of-art software. Cutting short on this part, this is how the initial screen of Lightroom looks like:

Library view
The interface of Lightroom is pretty simple. Some important components of the interface are as follows:

  • Navigator : This shows the preview of the image and any edits which are to be made to it, when we hover over any of the properties or the presets.
  • Histogram : This shows the histogram for the selected image. For more details, go through this article.
  • Filmstrip : The lower ribbon which shows all the imported images in form of collections.
  • Module Picker : The top ribbon that lets user choose between different modules like library (which shows all the imported images), develop (which provides the editing tools for post-processing) etc.
  • Toolbar : The strip of tools right under the main frame which holds tool set for displaying image in various formats which show the original unaltered image along with the edited image, thus making it easy to notice the changes in the image.
  • Identity Plate : The top-left plate which holds the logo of Lightroom. The user can use custom text there for “customized” feel.

So much is good enough to explore the workspace of the software, you will know more about the interface as you go on experimenting.

*Tip: How to change the identity plate :-

Go to Edit–>Identity Plate Setup.. and select any one of the option in graphical or textual identity plate. Bingo!! Here you are!

Next one up about basic editing using Lightroom 5.0 and advantages of using Lightroom 5.0 over previous versions!

 


Histogram Demystified!!

histogram comparison

The image above depicts three similar images, along with a graph : Histogram. Before plunging into the details of what a histogram is and what it does, I would like to bring it to your notice that the histograms are something which we do encounter frequently while editing pictures, thus making it necessary to understand the concept of histograms. I would try to explain the technical details in least boring way possible for me, but still pardon if the effort goes hay-wire. The following is the image of Adobe Photoshop Lightroom 5.0 depicting the histogram as an essential past of the software:

histogram

The histogram is a simple graphical representation of intensity of pixels versus the number of pixels of a certain intensity in any given image. This determines if the given image is properly exposed or not. Any photograph may be under-exposed, over-exposed or properly exposed depending on how close the peaks in the histogram are to the mid-tones of the image. First image of this post depicts the same. We would go to details of usage of histogram, but before that, what exactly is a histogram??

Histogram

his·to·gram

/ˈhistəˌgram/

A diagram consisting of rectangles whose area is proportional to the frequency of a variable and whose width is equal to the class interval.

Ehh!! Am I the only one confused? Why would I need the dictionary explanation? What do we do using a histogram? Have a look!!

A histogram is the pictorial representation of each and every pixel in an image with respect to their exposure values. The left side represents the darks or the shadows, while the right side depicts the whites or highlights and the middle section is for mid-tones, the properly exposed zone. The horizontal axis determines the exposure and the vertical height determines the number of pixels in the image of that certain exposure value. The area under the graph would hence determine the total number of pixels in the given image.

Note: A picture might be under-exposed and still look good, that depends totally on the photographer’s artistic instinct. Here exposure means closeness of the image pixels to the mid-tone levels.

We may learn many things about an image just by analyzing the histogram. We can tell if the image is properly exposed or not by checking if the histogram reaches the edges properly without any sudden peaks near any of the edges. If there is a gap on any of the edges, ie, the histogram doesn’t reach the edge itself, we may adjust the histogram such as to touch the edge without losing any significant detail.

Histogram of properly exposed image

The histogram shows that the given image was properly exposed. The peak is concentrated mostly near the midtones area of the histogram (the central part) and decreases smoothly to about 0 as it approaches both the ends.

Histogram of an underexposed image

The peaks of the histogram are concentrated near the left edge of the image, showing majority of the pixels are less exposed than the mid-tone region. The image, of which this histogram is, is as a result underexposed. Also, because towards the right end of the histogram, there is no pixel intensity shown, it would be safe enough to clip that part to average the histogram towards the mid-tones, without losing any significant details.

Histogram of an over-exposed image

The peaks of the histogram are concentrated near the right edge of the image, showing majority of the pixels are much more exposed than the mid-tone region. The image, whose histogram this is, as a result is overexposed. Also, because towards the left end of the histogram, there is no pixel intensity shown, it would be safe enough to clip that part to average the histogram towards the mid-tones, without losing any significant details. This will eventually give a picture that is better exposed.

Histogram of a possibly high contrast image

Then comes a very different sort of histogram, one which you cannot say is under-exposed or over-exposed, just by looking at it. It has peaks on both the ends, and most commonly it denotes any image which has high contrast. Such image have both set of features, bright highlights as well as dark shadows. Thus they yield to a pattern similar to as shown above in the histogram.

There are a few ways to recover this type of loss in detailing due to uneven distribution of pixel exposure in various parts of image, including image blending, HDR photography or editing in software like Lightroom or Photoshop. HDR and image blending usually average outs the range of pixel into a much uniform distribution thus yielding an image with much more details in both shadows and highlights.
Also, most of the cameras usually have the feature of displaying the histogram of image right after processing it. Although not accurate, because it is the histogram of the jpeg format of the image, but it gives a fair idea if the image is properly exposed or not.

I would like to add to this that having an image under-exposed or over-exposed can sometimes be the choice of the photographer himself/herself. I talked about a general term : Histogram. It is totally upto the choice of the photographer if he deliberately chooses the image to be under/over-exposed. Creativity Hold No Bars!!

 

“The best style is the style you don’t notice.”
                               – Somerset Maugham


Follow

Get every new post delivered to your Inbox.

Join 1,253 other followers

%d bloggers like this: