0% found this document useful (0 votes)
23 views8 pages

Matlab Programs

matlab programs

Uploaded by

sri.srikarthi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views8 pages

Matlab Programs

matlab programs

Uploaded by

sri.srikarthi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

display 4 images:

Program:

img1=imread('p4.jpg');
img2=imread('p5.jpg');
img3=imread('p6.jpg');
img4=imread('chips.jpg');
subplot(2,2,1);imshow(img1);title('First Image');
subplot(2,2,2);imshow(img2);title('Second Image');
subplot(2,2,3);imshow(img3);title('Third Image');
subplot(2,2, 4);imshow(img4);title('Fourth Image');
output:

2.converting color image to gray image

Program:

c=imread('p5.jpg');
gray=rgb2gray(c);
imshow(gray);
subplot(2,1,1);imshow(c);title('Color Image');
subplot(2,1,2);imshow(gray);title('Gray Image'); output:
3.spliting color channels

Program:

img1=imread('rgb.png');

r1=img1(:,:,1);
g1=img1(:,:,2);
b1=img1(:,:,3);
subplot(2,2,1);imshow(img1);title('Orginal Image');
subplot(2,2,2);imshow(r1);title('Red Image');
subplot(2,2,3);imshow(g1);title('Green Image');
subplot(2,2,4);imshow(b1);title('Blue Image');
output:
4. Arithmetic Operation

Program:

img=imread('tree2.jpg');
a1=imadd(img,50);
a2=imsubtract(img,31);
a3=immultiply(img,1);
a4=imdivide(img,2);
subplot(3,2,1);imshow(img);title('Orginal Image ');
subplot(3,2,2);imshow(a1);title('Adding Image ');
subplot(3,2,3);imshow(a2);title('Subtracting Image ');
subplot(3,2,4);imshow(a3);title('Multiplying Image ');
subplot(3,2,5);imshow(a4);title('Dividing Image ');

output:
5.Bit Operations:

Program:

close all
clear all
x=imread('star.jpg');
y=imread('star1.jpg');
xs=size(x);
y=resize(y,[xs(1),xs(2)]);
z1=bitand(x,y);
z2=bitor(x,y);
z3=bitxor(x,y);
z4=imcomplement(x);
subplot(3,2,1); imshow(x);title('Original Image 1');
subplot(3,2,2);imshow(y);title('Original Image 2');
subplot(3,2,3);imshow(z1);title('AND Operation');
subplot(3,2,4);imshow(z2);title('OR Opearion');
subplot(3,2,5);imshow(z3);title('XOR Operation');
subplot(3,2,6);imshow(z4);title('Complement Image');

Output:
6.Merge Operation

Program:

img1=imread('p7.jpg');
img2=imread('p6.jpg');
a1=imresize(img1,[64,64]);
b1=imresize(img2,[64,64]);
for i=1:1:size(b1)
for j=1:1:size(b1)
img3=a1+b1;
end
end
subplot(2,2,1);imshow(img1);title('First Image');
subplot(2,2,2);imshow(img2);title('Second Image');
subplot(2,2,3);imshow(img3);title('Merging Image');

Output:
7. Constrast stretching

Program:

img=imread('t1.jpeg');
a1=rgb2gray(img);
a=imadjust(a1);
subplot(2,2,1);imshow(img);title('Original');
subplot(2,2,2);imshow(a);title('Adjust');
subplot(2,2,3);imshow(a1);title('gray image')

output:

8.Noise

Program :

img=imread('p6.jpg');
a=imnoise(img,'salt & pepper',0.1);
subplot(2,1,1);imshow(img);title('Original Image');
subplot(2,1,2);imshow(a);title('Noise Image');
output:

9.illumination

Program:

close all
clear all
i=imread('rice.jpg');
se=strel('disk',15);
bg=imopen(i,se);
img=i-bg;
im=rgb2gray(img);
eimg=imadjust(im);
subplot(3,2,1);imshow(i);title('Original');
subplot(3,2,2);imshow(bg);title('background img');
subplot(3,2,3);imshow(img);title('background romove');
subplot(3,2,4);imshow(eimg);title('illuminate image');

output:
10

You might also like