Saturday, 25 June 2011

Some useful books for image processing :coding...

For MATLAB I found the book:


An Introduction to Digital Image
Processing with Matlab
Notes for SCM2511 Image
Processing 1
Alasdair McAndrew
School of Computer Science and Mathematics
Victoria University of Technology

Pretty good and concise....

For C there is the very obvious:

Image Processing in C by Dwayne  Phillips

http://www.amazon.com/Image-Processing-Analyzing-Enhancing-Digital/dp/087930443X/ref=sr_1_2?ie=UTF8&s=books&qid=1309069509&sr=8-2

is the link if you want to buy it. Pretty good and probably one of the few books worth buying on the subject.

Repositioning an image

Re-positioning an image in matlab may seem confusing at first but is actually very simple.

The algorithm is as follows:

1) Read the image into an array A using imread or other inbuilt reading functions.
2) If you want to shift to the right by 5 pixels, add 5 columns of 0's to your array A and store that in array B.
3) Write this into another array C of size same as array A.
4) 4 columns of image information will be lost and you will find your picture moved by 5 pixels.

If you want to shift the image to the left, it might be a tad trickier.

1) Read the image into an array A using imread or other inbuilt functions.
2) If you want to shift to the left by 5 pixels, write the elements of array A after 5 columns(in the for loop start the column iterations from 5 instead of 1) and store this in a pre-initialized array of zeros. This will add columns of zeros(dark) to the left of your image.. and the image will appear shifted to the left when it is displayed.

An important thing to note is that before using any of these techniques, we should add zeros all around the image so that no image information is lost.




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);