Saturday, May 19, 2012

About Color Banding

Do you know about Color banding?

If you are working in design animation, video rendering, digital coloring and its friends, you must know well about this, otherwise you may unfamiliar with this. The only reason I post about this one because somehow it is interested me.

After read about the newest video encoding in 10bit depth, I accidentally know about what is the color banding is. I get this from watching my favorite anime with 10bit depth encoding. That's how I get know about color banding.

Color Banding sample


Banding happens when video is compressed or decompressed and similar colors get posterized. This undesirable, visible bands of color that can be distracting, and in some cases downright ugly. It can happen in many situation, like video, picture or games. If it is in a small area, we wont notice and nobody got annoyed. But if we see in a large area, a large screen, it will very-very disturbing our eyes.

There are quite a few ways to remove color banding. Everyone seems to have their own formula.And for those kind of matters, I dont have any knowledge to explain it in here.



Just collecting notes and sharing.. Please let me know if there are wrong statements in this article or a copy-paste one.

Thursday, May 17, 2012

Comparing Date in Java


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class HashtableDemo {

    public static void main(String args[]) throws AssertionError, ParseException {

        DateFormat df = new SimpleDateFormat("dd-MM-yyyy");

        //comparing date using compareTo method in Java
        System.out.println("Comparing two Date in Java using CompareTo method");
        compareDatesByCompareTo(df, df.parse("01-01-2012"), df.parse("01-01-2012"));
        compareDatesByCompareTo(df, df.parse("02-03-2012"), df.parse("04-05-2012"));
        compareDatesByCompareTo(df, df.parse("02-03-2012"), df.parse("01-02-2012"));

        //comparing dates in java using Date.before, Date.after and Date.equals
        System.out.println("Comparing two Date in Java using Date's before, after and equals method");
        compareDatesByDateMethods(df, df.parse("01-01-2012"), df.parse("01-01-2012"));
        compareDatesByDateMethods(df, df.parse("02-03-2012"), df.parse("04-05-2012"));
        compareDatesByDateMethods(df, df.parse("02-03-2012"), df.parse("01-02-2012"));

        //comparing dates in java using Calendar.before(), Calendar.after and Calendar.equals()
        System.out.println("Comparing two Date in Java using Calendar's before, after and equals method");
        compareDatesByCalendarMethods(df, df.parse("01-01-2012"), df.parse("01-01-2012"));
        compareDatesByCalendarMethods(df, df.parse("02-03-2012"), df.parse("04-05-2012"));
        compareDatesByCalendarMethods(df, df.parse("02-03-2012"), df.parse("01-02-2012"));

    }

    public static void compareDatesByCompareTo(DateFormat df, Date oldDate, Date newDate) {
        //how to check if date1 is equal to date2
        if (oldDate.compareTo(newDate) == 0) {
            System.out.println(df.format(oldDate) + " and " + df.format(newDate) + " are equal to each other");
        }

        //checking if date1 is less than date 2
        if (oldDate.compareTo(newDate) < 0) {
            System.out.println(df.format(oldDate) + " is less than " + df.format(newDate));
        }

        //how to check if date1 is greater than date2 in java
        if (oldDate.compareTo(newDate) > 0) {
            System.out.println(df.format(oldDate) + " is greater than " + df.format(newDate));
        }
    }

    public static void compareDatesByDateMethods(DateFormat df, Date oldDate, Date newDate) {
        //how to check if two dates are equals in java
        if (oldDate.equals(newDate)) {
            System.out.println(df.format(oldDate) + " and " + df.format(newDate) + " are equal to each other");
        }

        //checking if date1 comes before date2
        if (oldDate.before(newDate)) {
            System.out.println(df.format(oldDate) + " comes before " + df.format(newDate));
        }

        //checking if date1 comes after date2
        if (oldDate.after(newDate)) {
            System.out.println(df.format(oldDate) + " comes after " + df.format(newDate));
        }
    }

    public static void compareDatesByCalendarMethods(DateFormat df, Date oldDate, Date newDate) {

        //creating calendar instances for date comparision
        Calendar oldCal = Calendar.getInstance();
        Calendar newCal = Calendar.getInstance();

        oldCal.setTime(oldDate);
        newCal.setTime(newDate);

        //how to check if two dates are equals in java using Calendar
        if (oldCal.equals(newCal)) {
            System.out.println(df.format(oldDate) + " and " + df.format(newDate) + " are equal to each other");
        }

        //how to check if one date comes before another using Calendar
        if (oldCal.before(newCal)) {
            System.out.println(df.format(oldDate) + " comes before " + df.format(newDate));
        }

        //how to check if one date comes after another using Calendar
        if (oldCal.after(newCal)) {
            System.out.println(df.format(oldDate) + " comes after " + df.format(newDate));
        }
    }
}

Output:

Comparing two Date in Java using CompareTo method
01-01-2012 and 01-01-2012 are equal to each other
02-03-2012 is less than 04-05-2012
02-03-2012 is greater than 01-02-2012
Comparing two Date in Java using Date's before, after and equals method
01-01-2012 and 01-01-2012 are equal to each other
02-03-2012 comes before 04-05-2012
02-03-2012 comes after 01-02-2012
Comparing two Date in Java using Calendar's before, after and equals method
01-01-2012 and 01-01-2012 are equal to each other
02-03-2012 comes before 04-05-2012
02-03-2012 comes after 01-02-2012


Source: roseIndia.net

Just collecting notes & sharing..

Sunday, May 13, 2012

ConcurrentHashMap and hashTable

So what is the difference between hashtable and ConcurrentHashMap , both can be used in multithreaded environment but once the size of hashtable becomes considerable larg,e performance degrade because for iteration it has to be locked for longer duration.

Since ConcurrentHashMap indroduced concept of segmentation , how large it becomes only certain part of it get locked to provide thread safety so many other readers can still access map without waiting for iteration to complete.

In Summary ConcurrentHashMap only locked certain portion of Map while Hashtable lock full map while doing iteration.

Just collecting notes and sharing..
Please let me know if there're wrong statements in this article or copy-paste one.

Monday, May 7, 2012

Tertawa itu sehat dan menguntungkan

Setiap orang pasti akan tertawa beberapa kali setiap hari. Mendengarkan lelucon, menonton film komedi atau membaca cerita lucu dengan mudah membuat kita tertawa.
Tertawa ternyata tak hanya mengungkapkan perasaan bahagia, namun juga membuat tubuh menjadi lebih sehat. Berikut ini beberapa manfaat dari tertawa yang bisa Anda rasakan bagi kesehatan.

1. Tertawa membantu meningkatkan sistem kekebalan tubuh dengan meningkatkan jumlah antibodi yang memproduksi sel T. Sel-sel ini membantu tubuh melawan virus dan tumor.

2. Tertawa membantu penderita hipertensi karena dapat menurunkan tekanan darah. Tertawa juga mengurangi kadar hormon kartisol yang menghalangi proses penyembuhan penyakit dan juga membantu menstabilkan tingkat gula darah.

3. Tertawa merangsang perubahan zat kimia dalam otak yang membantu menahan tubuh terhadap efek kumulatif dari stres.

4. Tertawa membantu membakar kalori. Menurut penelitian, tertawa 10-15 menit setiap hari dapat membakar kalori hingga 40 kalori. Tertawa juga meningkatkan denyut jantung dan mempercepat metabolisme yang memengaruhi berat badan.

5. Tertawa merangsang otak untuk memproduksi hormon endorfin, yang membantu menaikkan suasana hati seseorang dan membuat perasaan bahagia.

6. Tertawa membantu mengurangi peradangan di seluruh tubuh, sehingga baik bagi kesehatan jantung, otak dan peredaran darah.

7. Tertawa menjadi 'pijat' bagi organ internal karena efeknya mirip dengan melakukan olahraga.

8. Tertawa juga memberikan latihan ringan untuk jantung, paru-paru, diagfragma dan bahkan otot-otot perut.

9. Tertawa membantu melepaskan ketegangan di otot-otot wajah, leher, bahu dan perut, dimana semua bagian tubuh ini sering mengalami ketegangan akibat rutinitas sehari-hari.

10. Tertawa itu menular. Orang yang tertawa atau melucu dengan membuat lelucon akan mengundang tawa sehingga meningkatkan semangat dan menciptakan energi positif bagi orang-orang sekitarnya.

Just collecting notes and sharing..
Source: Ghiboo.com