Tuesday, December 3, 2013

Write a program in MatLab to extract a part of image using without a function .


clc;
clear all;
close all;

A=imread('contrast (3).tif');
r=size(A,1)-1;
i=int32(rand(1,1)*r)+1; % +1 for random value always from 0
j=i+500;
if(j>size(A,1))
    d=j-size(A,1);
    j=j-d;
end
c=size(A,2)-1;
k=int32(rand(1,1)*c)+1; % +1 for random value always from 0
l=k+500;
if(l>size(A,2))
    d1=l-size(A,2);
    l=l-d1;
end
B=zeros(size(A,1),size(A,2));
x=i;
for p=i:j-1
    y=k;
    for q=k:l-1
        B(x,y)=A(p,q);
        y=y+1;
    end
    x=x+1;
end
B1 = mat2gray(B);
figure('Position',[10  50 1400 630]);
subplot(1,2,1),imshow(A),
ylabel('Original Image','Color','r','FontSize', 10,'FontAngle', 'italic');
subplot(1,2,2),imshow(B1),
ylabel('Sub Image','Color','r','FontSize', 10,'FontAngle', 'italic');

1 comment:



  1. After looking over a number of the articles on your web site,
    I really appreciate your way of writing a blog. I saved it to my bookmark
    site list and will be checking back in the near future.
    Also see our wonderful

    LED TV REPAIRING COURSE

    LED TV REPAIRING COURSE IN DELHI

    LED TV REPAIRING INSTITUTE

    ReplyDelete