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

Friday, April 20, 2012

Bakteri Titanic


Kanada (AFP/ANTARA) - Dalam waktu kurang dari 30 tahun, mungkin tidak akan ada yang tersisa dari kapal Titanic kecuali "rusticle,” formasi karat yang mirip stalaktit, kata penelilti Henrietta Mann, yang menghabiskan empat tahun untuk mempelajari bakteri yang menggerogoti kapal karam tersebut.

Ekspedisi penelitian pada 1991 ke bangkai kapal yang terletak sekitar 12.400 kaki (3.780 meter) di dasar laut itu mengungkapkan formasi gugusan karat yang serupa dengan es atau stalaktit menggatung di kapal besar tersebut. Mereka biasanya terjadi di bawah air ketika besi tempa teroksidasi.
Mann, seorang pakar biologi dan geologi dari Universitas Dalhouseie di Halifax, memperoleh sempel dari Institut Oceanografi Bedford dan menelitinya dengan mikroskop elektronik. Dia menemukan fakta kalau bakteri itu, bukan karena proses kimia, menjadi alasan terbentuknya formasi yang terjadi di perairan dalam tesebut.


Peneliti Kanada itu mengidentifikasi puluhan bakteri, termasuk satu yang tidak pernah terlihat sebelumnya, yang ia juluki sebagai Halomonas titanicae, telah "mengunyah" lambung baja kapal tersebut dan mengubahnya, atom per atom, menjadi "rusticle," beberapa bahkan setinggi pria dewasa.
Tak terlihat dengan mata telanjang, berukuran hanya 1,6 mikrometer panjangnya, bakteri ini berkembang biak menjadi miliaran selama bertahun-tahun.


"Titanic terdiri dari 50.000 ton baja," kata Mann kepada AFP. "Jadi, ada banyak makanan untuk bakteri saya."
Bakteri itu juga memakan jendela, tangga, dan gerbang – semuanya yang terbuat dari besi kasar - serta tungku besi. "Mereka makan itu juga," kata Mann. Hanya kuningan yang tidak disentuh.
"Saya tidak tahu kecepatan mereka memakan besi," tapi membandingkan foto-foto awal dari bangkai itu dengan foto yang terbaru, jelas terlihat perubahan yang cepat telah terjadi.

"Mungkin dalam 20 atau 30 tahun dari sekarang bangkai kapal ini akan runtuh (menjadi) tumpukan karat," katanya.
Mann mancatat 27 bakteri yang hidup di rusticle, beberapa memiliki tentakel, serta cacing tabung dan makhluk kecil lainnya, bergerak dalam "koloni yang bersimbiosis."
Bakteri pertama mungkin diciptakan oleh diatom (ganggang uniseluler) dalam "salju laut" - kotoran dari permukaan.


Salah satu bakteri kemudian menghasilkan bakteri lain dan bersama-sama mereka membentuk rantai dan kemudian jaring, lebih banyak bakteri tumbuh pada jaring dan mengisi lubang-lubang dan akhirnya mengeras menjadi struktur rusticle dengan di dalam sirkulasi air. "Struktur bakteri ini seperti spons," jelas Mann.
Kehancuran Titanic sudah pasti akan menjadi kerugian besar warisan dunia, kata Mann. Tapi pada saat yang sama penemuannya menawarkan harapan: semua kapal tua, rig minyak dan kargo yang jatuh ke dasar laut tidak akan menumpuk seperti sampah.
Bakteri akhirnya akan menghancurkan semuanya.


Just collecting notes and sharing..
Sumber: id.berita.yahoo.com (AFP)

Sunday, April 1, 2012

3D Object Graphic Modelling on Google Search

Hi.. After accidentally looked at Google pages in Facebook, I found something interesting, wonderful and exciting. It is about the formula : sqrt(x*x+y*y)+3*cos(sqrt(x*x+y*y))+5 from -20 to 20

Try copy and paste it on your google search and see what it comes.
Actually I realize it is a formula to creating a 3D object. (yet need a confirmation from experts :D )

Anyway, it is only run on browser or system that support WebGL technology rendering.

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

Friday, March 30, 2012

Processor Governers & Disk I/O Schedulers in Android

I found the article from great kernel developer Neo3000 posted in forum.xda-developer.com, Samsung Galaxy SII thread.
I think is really useful for me and anyone who still confuse or dont know about "governors" processor in ARM architecture and I/O or disk schedulers in Android.
Hope this article reproduction is helpful.


Governors

1) Ondemand
2) Lulzactive (default)
3) Performance
4) Lagfree
5) Conservative
(module)
6) Lazy
(module)

7.)Lionheart (tweaked version of Conservative governers)

I/O Schedulers

1) BFQv3-R1 (Budget Fair Queuing) 2) Noop
3) SIO
4) VR (default)
5.) CFQ (complety Fair Queuing)
Governors Guide:
1) Ondemand
Default governor in almost all stock kernels. Simply put, Ondemand jumps to maximum frequency on CPU load and decreases the frequency step by step on CPU idle. No suspend/wake profiles. Even though many of us consider this a reliable governor, it falls short on battery saving and performance on default settings.

2) Lulzactive
This new find from Tegrak is based on interactive & smartass governors and is one of our favorites.
Old Version: When workload is greater than or equal to 60%, the governor scales up cpu to next higher step. When workload is less than 60%, governor scales down cpu to next lower step. When screen is off, frequency is locked to global scaling minimum frequency.
New Version: Three more user configurable parameters: inc_cpu_load, pump_up_step, pump_down_step. Unlike older version, this one gives more control for the user. We can set the threshold at which governor decides to scale up/down. We can also set number of frequency steps to be skipped while polling up and down.
When workload greater than or equal to inc_cpu_load, governor scales CPU pump_up_step steps up. When workload is less than inc_cpu_load, governor scales CPU down pump_down_step steps down.
Example:
Consider
inc_cpu_load=70
pump_up_step=2
pump_down_step=1
If current frequency=200, Every up_sampling_time Us if cpu load >= 70%, cpu is scaled up 2 steps - to 800.
If current frequency =1200, Every down_sampling_time Us if cpu load < 70%, cpu is scaled down 1 step - to 1000.

3) Performance
Sets min frequency as max frequency. Use this while benchmarking!

4) Lagfree
Lagfree is similar to ondemand. Main difference is it's optimization to become more battery friendly. Frequency is gracefully decreased and increased, unlike ondemand which jumps to 100% too often. Lagfree does not skip any frequency step while scaling up or down. Remember that if there's a requirement for sudden burst of power, lagfree can not satisfy that since it has to raise cpu through each higher frequency step from current. Some users report that video playback using lagfree stutters a little.

5) Conservative
A slower ondemand which scales up slowly to save battery. Simply put, this governor increases the frequency step by step on CPU load and jumps to lowest frequency on CPU idle.

6) Lazy
This governor from Ezekeel is basically an ondemand with an additional parameter min_time_state to specify the minimum time cpu stays on a frequency before scaling up/down. The Idea here is to eliminate any instabilities caused by fast frequency switching by ondemand. Lazy governor polls more often than ondemand, but changes frequency only after completing min_time_state on a step. Lazy also has a screenoff_maxfreq parameter which can be configured to specify screen-off max frequency.

I/O Schedulers Guide:
Q. "What purposes does an i/o scheduler serve?"
A.
  1. Minimize hard disk seek latency.
  2. Prioritize I/O requests from processes.
  3. Allocate disk bandwidth for running processes.
  4. Guarantee that certain requests will be served before a deadline.

So in the simplest of simplest form: Kernel controls the disk access using I/O Scheduler.

Q. "What goals every I/O scheduler tries to balance?"
A.
  1. Fairness (let every process have its share of the access to disk)
  2. Performance (try to serve requests close to current disk head position first, because seeking there is fastest)
  3. Real-time (guarantee that a request is serviced in a given time)

Q. "Description, advantages, disadvantages of each I/O Scheduler?"
A.

1) Noop

Inserts all the incoming I/O requests to a First In First Out queue and implements request merging. Best used with storage devices that does not depend on mechanical movement to access data (yes, like our flash drives). Advantage here is that flash drives does not require reordering of multiple I/O requests unlike in normal hard drives.

Advantages:
  • Serves I/O requests with least number of cpu cycles. (Battery friendly?)
  • Best for flash drives since there is no seeking penalty.
  • Good throughput on db systems.

Disadvantages:
  • Reduction in number of cpu cycles used is proportional to drop in performance.

2) BFQ
Instead of time slices allocation by CFQ, BFQ assigns budgets. Disk is granted to an active process until it's budget (number of sectors) expires. BFQ assigns high budgets to non-read tasks. Budget assigned to a process varies over time as a function of it's behavior.

Advantages:
  • Believed to be very good for usb data transfer rate.
  • Believed to be the best scheduler for HD video recording and video streaming (because of less jitter as compared to CFQ and others)
  • Considered an accurate i/o scheduler.
  • Achieves about 30% more throughput than CFQ on most workloads.
Disadvantages:
  • Not the best scheduler for benchmarking.
  • Higher budget assigned to a process can affect interactivity and increased latency.

3) SIO
Simple I/O scheduler aims to keep minimum overhead to achieve low latency to serve I/O requests. No priority quesues concepts, but only basic merging. Sio is a mix between noop & deadline. No reordering or sorting of requests.

Advantages:
  • Simple, so reliable.
  • Minimized starvation of requests.

Disadvantages:
  • Slow random-read speeds on flash drives, compared to other schedulers.
  • Sequential-read speeds on flash drives also not so good.

4) VR

Unlike other schedulers, synchronous and asynchronous requests are not treated separately, instead a deadline is imposed for fairness. The next request to be served is based on it's distance from last request.

Advantages:
  • May be best for benchmarking because at the peak of it's 'form' VR performs best.

Disadvantages:
  • Performance fluctuation results in below-average performance at times.
  • Least reliable/most unstable.


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