Implement Image compression using IGS.
Program:-
clc;
clear all;
close all;
a=imread('C:\Users\a1\Desktop\rainbow.jpg');
y=rgb2gray(a);
[r,c]=size(y);
sum=dec2bin(0,8);
for i=1:r;
for j=1:c;
if y(i,j)>=240;
t=0;
else
t=[sum(5) sum(6) sum(7) sum(8)];
t=bin2dec(t);
end
sum=y(i,j)+t;
sum=dec2bin(sum,8);
IGS=[sum(1) sum(2) sum(3) sum(4)];
p(i,j)=bin2dec(IGS);
endendsubplot(3,3,1);
imshow(a);
title('original image');
subplot(3,3,2);
imshow(y);
title('grayscale image');
subplot(3,3,3);
colormap(gray)imagesc(p);
title('compressed image');
clear all;
close all;
a=imread('C:\Users\a1\Desktop\rainbow.jpg');
y=rgb2gray(a);
[r,c]=size(y);
sum=dec2bin(0,8);
for i=1:r;
for j=1:c;
if y(i,j)>=240;
t=0;
else
t=[sum(5) sum(6) sum(7) sum(8)];
t=bin2dec(t);
end
sum=y(i,j)+t;
sum=dec2bin(sum,8);
IGS=[sum(1) sum(2) sum(3) sum(4)];
p(i,j)=bin2dec(IGS);
endendsubplot(3,3,1);
imshow(a);
title('original image');
subplot(3,3,2);
imshow(y);
title('grayscale image');
subplot(3,3,3);
colormap(gray)imagesc(p);
title('compressed image');
Output:-
Image compression using IGS |
0 comments:
If you have any doubts,please let me know