Saturday, February 22, 2014

Image Processing Example in Matlab!


Example: Write Matlab script to arbitrary Clip a segment (sub image) from a given source image as illustrated in the two figures below, and compare image sizes before and after. This procedure is to be repeated as long as user needs:
 Solution:
%===========================================
%= Program Script to arbitrary selecting Sub image =
%= From a source image by defining area to clip!    =
%===========================================

key=1;
while key ==1
    clc
    clear all
    IS=imread('MechaTron.jpg');
    figure;
    imshow(IS);
    input ('Enter x1: ');
    x1=ans;
    input ('Enter x2: ');
    x2=ans;
    input ('Enter y1: ');
    y1=ans;
    input ('Enter y2: ');
    y2=ans;
    Iss=IS(y1:y2,x1:x2,1:3);
    figure;
    imshow(Iss);
    s1=size(IS);
    s2=size(Iss);
    display ('==============================')
    display ('Size of Original image '); s1
    display ('Size of Sub image '); s2
    input ('Hit any Return key to End or 1 to Continue!');
    key =ans;
    close all
end
close all

0 Comments:

Post a Comment

السلام عليكم...سارد بعد قرائتي للتعليق...شكرا

<< Home