Professional Documents
Culture Documents
Exp 6
Exp 6
Exp 6
Experiment No.6
Prepared BY:
Taha Ghassan Adnan
The Code P1
I=imread('E:\Image Process\image(1).jpg');
imshow(I)
level=graythresh(I);
bw=im2bw(I,level);
figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);
figure, imshow(labeled)
pseudo_color = label2rgb(labeled,@spring, 'c', 'shuffle');
figure, imshow(pseudo_color)
numObjects;
1|Page
The Code P2
I=imread('E:\Image Process\image(1).jpg');
imshow(I)
level=graythresh(I);
bw=im2bw(I,level);
figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);
figure, imshow(labeled)
pseudo_color = label2rgb(labeled,@spring, 'c', 'shuffle');
figure, imshow(pseudo_color)
numObjects;
info=regionprops(labeled,'all')
Common Window P2
info =
14×1 struct array with fields:
Area
Centroid
BoundingBox
SubarrayIdx
MajorAxisLength
MinorAxisLength
Eccentricity
Orientation
ConvexHull
ConvexImage
ConvexArea
Circularity
Image
FilledImage
FilledArea
EulerNumber
Extrema
EquivDiameter
Solidity
Extent
PixelIdxList
PixelList
Perimeter
PerimeterOld
MaxFeretDiameter
MaxFeretAngle
MaxFeretCoordinates
MinFeretDiameter
MinFeretAngle
MinFeretCoordinates
2|Page
The Code P3
I=imread('E:\Image Process\image(1).jpg');
imshow(I)
level=graythresh(I);
bw=im2bw(I,level);
figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);
figure, imshow(labeled)
pseudo_color = label2rgb(labeled,@spring, 'c', 'shuffle');
figure, imshow(pseudo_color)
numObjects;
info=regionprops(labeled,'all')
info(1).Area
Common Window P3
ans = 192249
The Code P4
I=imread('E:\Image Process\image(1).jpg');
imshow(I)
level=graythresh(I);
bw=im2bw(I,level);
figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);
figure, imshow(labeled)
pseudo_color = label2rgb(labeled,@spring, 'c', 'shuffle');
figure, imshow(pseudo_color)
numObjects;
info=regionprops(labeled,'all')
info(1).Area
Areas=cat(1,info.Area)
Areas=cat(2,info.Area)
Common Window P4
Areas =
192249
3
11
1
2
1
2
994
1
10
3|Page
2
2
7
2
Areas =
Columns 1 through 8
192249 3 11 1
2 1 2 994
Columns 9 through 14
1 10 2 2
7 2
The Code P5
I=imread('E:\Image Process\image(7).jpg');
figure,imshow(I);
level=graythresh(I);
bw=im2bw(I,level);
[labeled.numObjects]=bwlabel(bw,4);
info=regionprops(labeled.numObjects,'all')
Common Window P5
info =
Area
Centroid
BoundingBox
SubarrayIdx
MajorAxisLength
MinorAxisLength
4|Page
Eccentricity
Orientation
ConvexHull
ConvexImage
ConvexArea
Circularity
Image
FilledImage
FilledArea
EulerNumber
Extrema
EquivDiameter
Solidity
Extent
PixelIdxList
PixelList
Perimeter
PerimeterOld
MaxFeretDiameter
MaxFeretAngle
MaxFeretCoordinates
MinFeretDiameter
MinFeretAngle
MinFeretCoordinates
>> 2
6157
ans =
6162
5|Page
ans =
6130
ans =
6126
Areas =
6157
6162
6130
6126
2. Engineering Center
info(1).Area
info(2).Area
info(3).Area
info(4).Area
Areas=cat(1,info.Area)
ans =
80.2509 225.2436
ans =
75.5000 82.0000
ans =
208.3250 80.8077
ans =
216.1216 217.855
6|Page
Centroids =
80.2509 225.2436
75.5000 82.0000
208.3250 80.8077
216.1216 217.8550
3. The frame
info(1).BoundingBox
info(2).BoundingBox
info(3).BoundingBox
info(4).BoundingBox
BoundingBox=cat(1,info.BoundingBox)
ans =
ans =
ans =
ans =
BoundingBox =
7|Page
4. Euler
I=imread('E:\Image Process\image(10).jpg');
figure,imshow(I);
level=graythresh(I);
bw=im2bw(I,level);
[labeled]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Euler_Number1=info(1).EulerNumber;
NumHoles1=1-Euler_Number1
Euler_Number2=info(2).EulerNumber;
NumHoles2=1-Euler_Number2
NumHoles1 =
NumHoles2 =
5. Extent
I=imread('E:\Image Process\image(10).jpg');
level=graythresh(I);
bw=im2bw(I,level);
[labeled,numObjects]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Extentl=info(1).Extent
Extent2=info(2).Extent
Extentl =
0.6874
Extent2 =
0.8070
8|Page
6. The area of the item after filling the holes
I=imread('E:\Image Process\image(10).jpg');
level=graythresh(I);
bw=im2bw(I,level);
[labeled,numObjects]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Object_Areal=info(1).Area;
Object_Filled_Areal=info(1).FilledArea;
Object_Area2=info(2).Area;
Object_Filled_Area2=info(2).FilledArea;
Object_Filled_Area2=
166871
Object_Filled_Areal=
111462
392.1707
Major_Axis2 =
473.7121
9|Page
8. Length of secondary diameter
I=imread('E:\Image Process\image(10).jpg');
level=graythresh(I);
bw=im2bw(I,level);
[labeled,numObjects]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Minor_Axisl=info(1).MajorAxisLength
Minor_Axis2=info(2).MajorAxisLength
Major_Axisl =
392.1707
Major_Axis2 =
473.7121
-30.7541
Orientation2 =
31.7922
10 | P a g e
10. Delete an item
v=imread('text.png');
figure,imshow(v);
bw2=bwareaopen(v,50);
figure,imshow(bw2)
11 | P a g e