All All 'Pepper - JPG': For For
All All 'Pepper - JPG': For For
clc;
clear all;
close all;
a=imread('pepper.jpg');
a=double(a);
[r,c]=size(a);
i=1;
j=1;
c=zeros(r/2,c/2);
for x=1:2:r
for y=1:2:r
c(i,j)=a(x,y);
j=j+1;
end
i=i+1;
j=1;
end
figure('name','nitesh');
subplot(121);
imagesc(a/255);
title('orginal');
subplot(122);
imagesc(c/255);
colormap(gray);
title('reshaped');
size(c);
impixelinfo;
output:
15bec1157
T5
Convert actual image to mirror image
clc;
clear all;
close all;
a=imread('lady.jpg');
h=rgb2gray(a);
[r c]=size(h);
for i=1:1:r
for j=1:1:c
b(i,j)=a(i,(c-j+1));
end
end
figure();
subplot(1,2,1);
imagesc(h), title('Actual image');
subplot(1,2,2);
imagesc(b),title('Mirror image');
output-
15bec1157
T6 convert a image in to black white image .
Program
clc;
clear all;
close all;
a=imread('lady.jpg');
b=rgb2gray(a);
subplot(131);
imshow(a);
title('rgb image1157');
subplot(132);
imshow(b);
title('Grayscale image');
[r c]=size(b);
for i=1:1:r
for j=1:1:c
if(b(i,j)<128)
N(i,j)=0;
else
N(i,j)=1;
end
end
end
subplot(1,3,3);
imshow(N);
title('Black&white');
imwrite(N,'nites.jpg');
output:
15bec1157
T7
Introduction to histogram
clc;
clear all;
close all;
a=imread('lady.jpg');
subplot(131);
imshow(a);
title('rgb image57');
y=rgb2gray(a);
subplot(132);
imshow(y);
title('Grayscale image');
subplot(133);
imhist(y);
title('Histogram of image data');
output
15bec1157
T8
clc;
clear all;
close all;
a=imread('cameraman.png');
c=double(a);
c0=mod(c,2);
c=floor(c/2);
subplot(251);
imshow(c0);
title('lsb1 nitesh');
c1=mod(c,2);
c=floor(c/2);
subplot(252);
imshow(c1);
title('lsb2');
c2=mod(c,2);
c=floor(c/2);
subplot(253);
imshow(c2);
title('lsb3');
c3=mod(c,2);
c=floor(c/2);
subplot(254);
imshow(c3);
title('lsb4');
c4=mod(c,2);
c=floor(c/2);
subplot(255);
imshow(c4);
title('lsb5');
c5=mod(c,2);
c=floor(c/2);
subplot(256);
imshow(c5);
title('msb1');
c6=mod(c,2);
c=floor(c/2);
subplot(257);
imshow(c6);
title('msb2');
c7=mod(c,2);
c=floor(c/2);
subplot(258);
imshow(c7);
title('msb3');
nk=((2^0*c0+2^1*c1+2^2*c2+2^3*c3+2^4*c4+2^5*c5+2^6*c6+2^7*c7)/256);
subplot(259);
imshow(nk);
title('combined image')
15bec1157
output
15bec1157