Exp 6

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Medical Instrumentation Technology Engineering

Experiment No.6

Prepared BY:
Taha Ghassan Adnan

Supervised BY: Mrs. Marwa Mofak


Experiment No.6
Area

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;

Original Image Binary Image

Labeled Image Colored Image

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 =

4×1 struct array with fields:

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

1. Area of each element


info(1).Area
info(2).Area
info(3).Area
info(4).Area
Areas=cat(1,info.Area)
ans =

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 =

28.5000 147.5000 103.0000 117.0000

ans =

36.5000 42.5000 78.0000 79.0000

ans =

164.5000 36.5000 88.0000 89.0000

ans =

167.5000 169.5000 97.0000 97.0000

BoundingBox =

28.5000 147.5000 103.0000 117.0000


36.5000 42.5000 78.0000 79.0000
164.5000 36.5000 88.0000 89.0000
167.5000 169.5000 97.0000 97.0000 216.1216
217.8550

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

7. Main diameter length


I=imread('E:\Image Process\image(10).jpg');
level=graythresh(I);
bw=im2bw(I,level);
[labeled,numObjects]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Major_Axisl=info(1).MajorAxisLength
Major_Axis2=info(2).MajorAxisLength
Major_Axisl =

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

9. The angle between the main diagonal and the horizon


I=imread('E:\Image Process\image(10).jpg');
level=graythresh(I);
bw=im2bw(I,level);
[labeled,numObjects]=bwlabel(bw,4);
info=regionprops(labeled,'all');
Orientationl=info(1).Orientation
Orientation2=info(2).Orientation
Orientationl =

-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. Find edges


m=imread('E:\Image Process\image(1).jpg');
figure,imshow(m);
level=graythresh(m);
bw1=im2bw(m);
imshow(bw1)
bw2=bwperim(bw1,4);
figure, imshow(bw2)

11 | P a g e

You might also like