IMAGE PROCESSING

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Image Arithmetic in MATLAB with example

Image Arithmetic

An image is represented in a matrix format.
To perform image arithmetic the size of the two matrices should be same.
The operation on two images results in a new image.
Consider two images A and B with same size.

In a RGB image, the addition of two images can be done using the ‘+’ operator. C=A+B;
Here, the minimum value of A+B and 255 is taken.

(i.e) C(i,j,1)=min(A(i,j,1)+B(i,j,1),255) where (i,j) represents the pixel position.
Image addition can be used to add the components from one image into other image.

Image Subtraction

A new image is obtained as a result of the difference between the pixels in the same location of the two images being subtracted.
C=A-B; ie. Maximum value of A-B and zero.
C(i,j,:) =max(A(i,j,:)-B(i,j,:),0).

Image subtraction is widely used for change detection.
For detecting the missing components in product assembly,
Example:To detect the defects in the PCB.

Image subtraction is most beneficial in the area of medical image processing called mask mode radiography.

Image Multiplication

Image multiplication is used to increase the average gray level of the image by multiplying with a constant.
It is used for masking operations.
C=A.*B;

Image Division

Image division can be considered as multiplication of one image and the reciprocal of other image.
C=A.\B;

Logical Operations:

Logical operations are done on pixel by pixel basis.
The AND and OR operations are used for selecting subimages in an image .
This masking operation is referred as Region Of Interest processing.

Logical AND

To isolate the interested region from rest of the image portion logical AND or OR is used. Consider a mask image L for the image A.
To obtain the interested area, D= and(L,A) ;
We can use L&A also.
The resulting image will be stored in D which contains the isolated image part.

Logical OR

Syntax: D=or(L,A). We can also use L|A

%Both A and B are of same size
object=A+B;

background=imresize(background,[size(object,1) size(object,2)]);
Im3=uint8(zeros(size(object)));
whiteImg=uint8(ones(size(object)));
%Array right division. A./B is the matrix with elements A(i,j)/B(i,j). A and B must
%have the same size, unless one of them is a scalar.
%Image Division
%Logical AND
%Array multiplication. A.*B is the element-by-element product of the arrays A and B.

%Image multiplication
%Multiply the background and the mask image
%And the result with the foreground image to obtain the final Image.
finalImg=(background.*im3)+object;
figure,imshow(finalImg);

Example:2
 img61.jpg

 Sample_Image.jpg

D=imresize(D,[size(E,1) size(E,2)]);
A=double(E);
C=uint8(zeros(size(A)));
F=E;

[x,y]=find((A(:,:,1)+A(:,:,2)+A(:,:,3))>650);

for i=1:size(x,1)
C(x(i),y(i),:)=1;
F(x(i),y(i),:)=0;
end

C=C.*D;

C=C+F;
imshow(C);

Like "IMAGE PROCESSING" page