Code for Erosion operation on the Image

clc;
clear all
a=imread(‘image.jpg’);
a=im2bw(a);
m=ones(11,11); % Taking 11 x 11 structuring element
s=size(a);
for i=1:s(1)
for j=1:s(2)
    sum=0;
    for k=-5:5
        for l=-5:5
            if i+k>0 && i+k<s(1)
                  if j+l>0 && j+l<s(2)
                       sum=sum + m(6+k,6+l).*a(i+k,j+l);
                  else
                       sum=0;
                  end
             else
        sum=0;
        end
        if sum==121
        out(i,j)=a(i,j);
        else
        out(i,j)=0;
        end
    end
end
end
end
imshow(out);

 

Posted on by jajalmehul | Leave a comment

Matlab Code for Histogram Equilisation

clear all;
close all;
img=imread(‘yourimage.png’);
% figure(),imhist(img)

count=zeros(1,256);

a=size(img);

for i = 1:1:a(1)
for j = 1:1:a(2)
% x=img(i,j)
count(img(i,j)+1)= count(img(i,j)+1)+1;
end
end
% stem(count); xlabel(‘pixel’); ylabel(‘Level’);figure();hold on;
pdf=count*(1/(a(1)*a(2)))

add=zeros(1,256);
for i = 1:256
if (i == 1 )
add(i)=pdf(i);
else
add(i) = add(i-1) + pdf(i);
end
end
% plot(add); hold on;
% xlabel(‘Pixel’); ylabel(‘n/N’);

for i = 1:1:a(1)
for j = 1:1:a(2)
x=img(i,j);
img1(i,j)= add(x+1);
end
end
figure(),imhist(img),figure(),imhist(img1)
figure(),imshow(img),figure(),imshow(img1)

Posted in Uncategorized | Leave a comment

Matlab Code for Cropping the Image

close all;
clear all;
a=imread(‘your image.png’);

% Parameter for cropping

x=input(‘Enter value of Row:’)

y=input(‘Enter value of Column:’)
c=size(a)
for i = x:1:c(1)-x
for j = y:1:c(2)-y
b(i+1-x,j+1-y)=a(i,j);
end
end
figure()
imshow(a)
figure()
imshow(b)
size(b)

Posted in Uncategorized | Leave a comment

Matlab Code for creating Mirror Image

close all;
clear all;
a=imread(‘C:\Documents and Settings\pgec\My Documents\P.png’);
c=size(a)
for i = 1:1:c(1)
for j = 1:1:c(2)
b(i,c(2)+1-j)=a(i,j);
end
end
figure()
imshow(a)
figure()
imshow(b)
size(b)

Posted in Uncategorized | Leave a comment

Matlab Code for Rotating Image by 270 degree

close all;
clear all;
a=imread(‘yourimage.png’);
c=size(a)
for i = 1:1:c(1)
for j = 1:1:c(2)
b(c(2)+1-j,c(1)+1-i)=a(i,j);
end
end
figure()
imshow(a)
figure()
imshow(b)
size(b)

Posted in Uncategorized | Leave a comment

Matlab Code for Rotating Image by 90 degree

close all;
clear all;
a=imread(‘Your image.png’);
c=size(a)
for i = 1:1:c(1)
for j = 1:1:c(2)
b(j,i)=a(i,j);
end
end
figure(),imshow(a),figure(),imshow(b)
size(b)

Posted in Uncategorized | Leave a comment

Matlab Code for Rotating image by 180 degree

close all;
clear all;
a=imread(‘your image.png’);
c=size(a)
for i = c(1):-1:1
for j = c(2):-1:1
b(c(1)+1-i,c(2)+1-j)=a(i,j);
end
end
figure()
imshow(a)
figure()
imshow(b)
size(b)

Posted in Uncategorized | Leave a comment

Matlab code for Image Zoom out

close all;
clear all;
a=imread(‘yourimage.png’);
c=size(a)
for i = 1:2:c(1)
for j = 1:2:c(2)
b((i+1)/2,(j+1)/2)=a(i,j);
end
end
figure()
imshow(a)
figure()
imshow(b)

Posted in Uncategorized | 1 Comment

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment