Features Extraction May 22
Features Extraction May 22
Standard Deviation of 𝑚
It is used to measure the average
Edge (ESD) 1 contrast of an image Boundary
√ ∑(𝑦𝑖 − 𝑦̅)2
𝑚
𝑖=1
Shape Index (SI) 𝑃𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟 It is relates to curved states of an
( )
2 ∗ 𝑀𝐴𝑋_𝑅 image
To find Centroid:
• Find the row and column having pixel value one.
Eg.[row,column]=find(label==1)
Row=[ 1 2 2 2 3 1 2 3]
Column=[ 1 1 2 3 3 4 4 4]
• Find the mean of the row and column having pixel value one.
Mean of Row=2 and mean of column= 2.75
• For instance, calculate the distance between the two points (1,1) and (2,2).
distance=sqrt((2-1).^2+(2-1).^2)=1.41
• Similarly, the distance is computed for all the pixel positions.
• The perimeter for the given example is 10.2426
MATLAB CODE:
%Measure Basic Image Properties without using 'regionprops' function
%Measure Area, Perimeter, Centroid , Equvidiameter, Roundness and Bounding Box
clc
%Read Original Image
I=imread('coins.png');
%Convert to Binary
B=im2bw(I);
sx=min(col)-0.5;
sy=min(row)-0.5;
breadth=max(col)-min(col)+1;
len=max(row)-min(row)+1;
BBox=[sx sy breadth len];
display(BBox);
%Refer:http://angeljohnsy.blogspot.in/2011/06/how-to-draw-in-matlab.html
figure,imshow(I);
hold on;
x=zeros([1 5]);
y=zeros([1 5]);
x(:)=BBox(1);
y(:)=BBox(2);
x(2:3)=BBox(1)+BBox(3);
y(3:4)=BBox(2)+BBox(4);
plot(x,y);
%Find Area
Obj_area=numel(row);
display(Obj_area);
%Find Centroid
X=mean(col);
Y=mean(row);
Centroid=[X Y];
display(Centroid);
plot(X,Y,'ro','color','r');
hold off;
%Find Perimeter
BW=bwboundaries(Label==num);
c=cell2mat(BW(1));
Perimeter=0;
for i=1:size(c,1)-1
Perimeter=Perimeter+sqrt((c(i,1)-c(i+1,1)).^2+(c(i,2)-c(i+1,2)).^2);
end
display(Perimeter);
%Find Equivdiameter
EquivD=sqrt(4*(Obj_area)/pi);
display(EquivD);
%Find Roundness
Roundness=(4*Obj_area*pi)/Perimeter.^2;
display(Roundness);
9 Standard 𝜎𝑥 = √𝜎𝑥2 & 𝜎𝑦 = √𝜎𝑦2 It is used to calculate to quantify the amount of variation
Deviation or dispersion of a set of data values