MATLAB CODE - Image Cropping


clc;
clear all;
close all;

% Read the Original Image
% Convert it to Grey Image, rescale it to 10 x 10 to reduce
% running time of this program and display it

mycolourimg = imread('colorleaf.jpg');
mygrayimg = rgb2gray(mycolourimg);

subplot(1,2,1);
imshow(mygrayimg);
title('My original Image');

croppedimg = imresize(mygrayimg,[10 10]); 
subplot(1,2,2);
imshow(croppedimg);
title('Cropped Image of size 10 x 10');


% Label the image for extraction of features

labelimage = croppedimg;
labelimage = bwlabel(labelimage);

% Obtain features of the image using regionprops() command
% The parameter all indicates that all the supported features
% to be displayed on screen

featuresimg = regionprops(labelimage,'Area','MajorAxisLength','MinorAxisLength');

% The individual features can be extracted like this 

fprintf('Thre area is %6.2f \n',featuresimg.Area);
fprintf('The MajorAxisLength is %6.2f  \n',featuresimg.MajorAxisLength);
fprintf('The MinorAxisLength is %6.2f  \n',featuresimg.MinorAxisLength);

% Calculate eccenticity

myecc = featuresimg.MajorAxisLength/featuresimg.MinorAxisLength;
fprintf('The eccentricity is %6.2f \n',myecc);


% Calculate pixel statistics
% Convert the matrix to a single vector

newcropimg = croppedimg(:);
pixstat=datastats(double(newcropimg));
disp(pixstat)





MATLAB CODE - Image Cropping MATLAB CODE - Image Cropping Reviewed by Suresh Bojja on 10/21/2015 09:45:00 PM Rating: 5

Subjects & Labs

AC (6) ADS (2) ATMEL (6) AWP (5) C- Language (3) CAO (5) CDAC (1) Cloud Computing (1) CMC (6) CN (10) CONSERVATION & MANAGEMENT Complete Notes (1) Control Sys (2) CVSM (2) Data Analytics (1) DC (5) Digital System Design (3) DIP (17) DLD (10) DLD Lab Manual (1) DS (4) DSD&DICA (9) DSP (6) EDC (45) Electonic Components (2) Embedded (7) EMWTL (6) ENERGY AUDIT (1) Engg. Mechanics (2) Engg.Chemistry (11) Faculty Files (6) Faculty Labs (1) Fuzzy (3) II MID (1) Job Exam Papers (4) LICA (1) Linux OS (1) Materials (1) MATLAB (27) MCU IDE 8051 (1) MEMS (4) MPMC (57) MPMC LAB Manual (3) MTECH (6) MWE (2) OC (1) PDC (9) Projects (8) RADAR (1) Research (9) RVSP (3) SC (1) Softwares (1) SS (2) STLD (19) TCSS (1) TSSN (1) TV Engg (1) VHDL (4) VLSI (8) VLSI Lab manual (1) WCN (1) Wireless Commu. (1) WSN (2)
Theme images by sebastian-julian. Powered by Blogger.