Senin, 28 April 2008

Convert RGB image to Grayscale Image

Actualy, there is a built up function in Matlab to convert RGB image to grayscale image. This function is RGB2GRAY. For example, we have RGB image (rgb.jpg) and grayscale image named by gray.jpg, so we have this code:

x=imread('rgb.jpg');
y=rgb2gray(x);
imwrite(y,'gray.jpg');


It's so easy. But...just for fun..i made user defined function in Matlab to do it. Very simple...conversion is done by get the average RGB component.

g=imread('lampu.jpg');
gb=double(g);
[b,kl,rgb]=size(gb);
gbrgb=zeros(b,kl);
for i=1:b
for j=1:kl
gbrgb(i,j)=round((gb(i,j,1)+gb(i,j,2)+gb(i,j,3))/3);
end
end
gbrgb1=uint8(gbrgb);
figure, imshow(g);
figure, imshow(gbrgb1);

Output from this code is :

Selasa, 22 April 2008

Image Compression with Quantization Method

Last time I try to compressed image file with quantization method. Why quantization? Because this method is more easily than other….he…he… I try with two kind of image file. First is grayscale image and the second is RGB image. Grayscale image have a simple digital data, that consist grayscale degree in each pixels (2D matrix). With quantization method we can decrease bit that represent grayscale degree. For example we have 6x6 pixel grayscale image, and each pixel represent with 8 bit. We want to decrease from 8 bit to 4 bit to represent each pixel. So we made a table that convert each value of initial grayscale degree to compressed grayscale degree. We change each value with other value according this table. If we have a RGB file it’s similar with grayscale image. But from RGB image we have 3D matrix that represent width, height and RGB factor. We can consider it as three matrix 2D, namely for R factor, G factor and B factor. Each of matrix consist of R or G or B degree of image. If in initial image three kind of matrix represent with 256 bit and we want to reduce it into 128 bit, so we do it same with in grayscale image. I implemented that method in matlab. I also compare image histogram before an after compression that give in above.
Image and histogram before and after compression in RGB image

Image and histogram before and after compression in grayscale image

Senin, 21 April 2008

Read an image file with Java

This script is used to read image file and show image file in a frame. To read image file, I use imageio. Image will be wrote and saved to image variable. Image variable consist of any information about our image, for example: resolution, color model etc.
Output from those script is :

And than it is an information that consist in image variable.

Other information that I want to know is, how to get information about value of pixels that arrange our image. So…in grayscale image, we can get grey degree and in RGB image we can get RGB degree. In Matlab it can be get easily, but in Java???? I read any online paper about it, but I still confuse…he…he…

Jumat, 11 April 2008

Programming

I'm very like in computer programming. Unfortunately, I must study more in it, because I feel, i don't know much about it. Early, I learn about Pascal in Math and Natural Science at Gadjah Mada University(GMU) in 1993. I choose Computer Science Department at GMU. Beside Pascal, I also learn about C (not C++). Others...? Nothing. But learning about programming concept, it must do. We will use Pascal, C or others it isn't a big problem. Because all of programming language have similarity.
In this time, i must study more because my jobs much relate on it. I learn about Object Oriented Programming, web programming, database programming, image processing and more. There are much topics, that i want to learn, but there aren't much times. All right...slowly but surely.

Rabu, 09 April 2008

They are sick.

I have two sons. The first is Mamat. He is 9 years old and the second is Kori. Kori is 2 years old. We're a happy family. My sons always give me the miracles. But unfortunately, this time their daddy go to Brebes. Brebes is one city at Central Java. So... our happines isn't complete without their daddy.
As mother...I'm very sad because all of my kids were sick. My first son, Mamat couldn't go to school two days ago. But this day he is going to school. Although, I'm worry. Fortunately, grandma and grandpa always give me a suport, so...I must have been strong mother.

Selasa, 08 April 2008

My first post

Hi... I'm Krisna. Live in Jogjakarta Indonesia. A mother with 2 sons. Now..... i want to learn about english. So in this media, i want to write about everything in english.
I think....i start to learn about english when i am in SMP. Because...it's not be excercise so... there aren't significant grow.
Everyones are laugh if read it. But nevermind.... I must learn...learn and learn. Please give me a comment for it, to correct about this post. Thank's....