Saturday, 18 June 2011

Just the basics in Image Processing

Basic commands used for images in matlab:

To load a single(non-DICOM/common format) image...  we use:

A = imread(<insert filename here>);

This returns a matrix of (pixel size)x(pixel size) onto the matlab variables list or as matlab calls it your workspace.

In this matrix, (supposing you've loaded a color image), each value represents the grey level value when you later try to display the image in matlab. For example, if you type down this:

B = [ 10 8 6 ; 6 10 8; 6 8 10] ; % followed by
figure;image(B);colormap(gray(16));%To display the image
and display it as an image in matlab, then you'd get an image like this:

So basically any number based matrix on matlab can be represented as an image.Its also easy to understand that as gray values increase, the picture gets darker. So by multiplying an image matrix by a number > 1, we get a much darker image. If your grayscale value exceeds 16  however in this image for example then it will be taken as a value of grayscale value - 16.

Increasing the total number of grays also has an effect on your image. For example, if you change the number of graylevels to 32, it will make your image parts which are > 8 darker and <8 lighter, simply because there are more shades of gray to represent them.

Something that is always useful in image processing with gray levels is a  histogram of frequencies of the gray levels. This can be obtained pretty easily in matlab.
Just type:
B = imhist(matrix); %and then
plot(B);


No comments:

Post a Comment