lab mathlab
TRANSCRIPT
-
7/21/2019 Lab Mathlab
1/14
1) Image processing Program of Gauge
%To determine the Gauge
>> %Image Acquisition>> I1=imread('gauge.JPG');>> figure,imshow(I1)
>> %Cropping the image>> I2=imcrop(I1, [230 160 320 250]);>> figure, imshow(I2)
>> %Convert into grayscale image>> I3=rgb2gray(I2);
>> figure,imshow(I3)
>>% To show gray histogram
>> figure,imhist(I3)
-
7/21/2019 Lab Mathlab
2/14
>> %Convert into binary image>> I4=im2bw(I3,73/255);>> figure,imshow(I4)
>> %To compliment the image>> I5=imcomplement(I4);>>figure,imshow(I5),title('Compliment
image');
>> %To fill the hole>> I6=imfill(I5,'holes');>> figure,imshow(I6)
>> %To fill the hole>> I7=bwareaopen(I6,4000);>> figure,imshow(I7)
>> %Measure the diameter>> I8=regionprops(I7,'basic');>> A=[I8.Area];>> D= sqrt(4*A/pi);
Area =4319
Diameter = 74.1561
-
7/21/2019 Lab Mathlab
3/14
2) Image processing Program of Gauge on block
>> %To determine the gauge on block
>> %Image Acquisition>> I1=imread('gauge on block.JPG');
>> %Cropping the image>> I2=imcrop(I1, [210 180 320 250]);>> figure, imshow(I2)
>> %Convert into grayscale image>> I3=rgb2gray(I2);
>> figure,imshow(I3)
-
7/21/2019 Lab Mathlab
4/14
>>% To show gray histogram
>> figure,imhist(I3)
>> %Convert into binary image>> I4=im2bw(I3,80/255);>> figure,imshow(I4)
>> %To compliment the image>> I5=imcomplement(I4);
>>figure,imshow(I5)
>> %To fill the hole>> I6=imfill(I5,'holes');>> figure,imshow(I6)
-
7/21/2019 Lab Mathlab
5/14
>> %To filter the unwanted area>> I7=bwareaopen(I6,4000);>> figure,imshow(I7)
>> %Measure the diameter>> I8=regionprops(I7,'basic');>> A=[I8.Area];>> D= sqrt(4*A/pi);
Area =4319
Diameter = 74.1561
3) Image processing Program of 5 cents
>> %To determine the diameter
of 5 cents
>> %Image Acquisition>> I1=imread('5-2.JPG');>> figure,imshow(I1)
>> %Cropping the image>> I2=imcrop(I1, [180 160 320
250]);>> figure, imshow(I2)
-
7/21/2019 Lab Mathlab
6/14
>> %Convert into grayscale
image>> I3=rgb2gray(I2);>> figure,imshow(I3)
>>% To show gray histogram
>> figure,imhist(I3)
>> %Convert into binary image
>> I4=im2bw(I3,73/255);>> figure,imshow(I4)
>> %find the unwanted noise
I5=imfill(I4,'holes');>> figure,imshow(I5)
-
7/21/2019 Lab Mathlab
7/14
>> %To remove unwanted noise
from image 4>> I6=I5-I4;>> figure,imshow(I6)
>> %MOrphological process>> I7=bwareaopen(I6,100);>> figure,imshow(I7)
>> %Measure the diameter>> I8=regionprops(I7,'basic');>> A=[I8.Area];>> Dia = sqrt(4*A/pi);
Area = 12171
Diameter = 124.4853
4) Image processing Program of 10 cents
>> %To determine the diameter
of 10 cents
>> %Image Acquisition>> I1=imread('10-2.JPG');>> figure,imshow(I1)
-
7/21/2019 Lab Mathlab
8/14
>> %Cropping the image>> I2=imcrop(I1, [210 100 300
250]);>> figure, imshow(I2)
>> %Convert into grayscale
image>> I3=rgb2gray(I2);>> figure,imshow(I3)
>>% To show gray histogram
>> figure,imhist(I3)
>> %Convert into binary image>> I4=im2bw(I3,88/255);>> figure,imshow(I4)
-
7/21/2019 Lab Mathlab
9/14
>>%To compliment the image>> I5=imcomplement(I4);>> figure,imshow(I5)
>> %To fill the hole>> I6=imfill(I5,'holes');>> figure,imshow(I6)
>> %To remove unwanted area>> I7=bwareaopen(I6,100);>> figure,imshow(I7
>> %Measure the diameter>> I8=regionprops(I7,'basic');>> A=[I8.Area];>> Dia = sqrt(4*A/pi);
Area = 14391
Diameter = 135.3632
-
7/21/2019 Lab Mathlab
10/14
5) Image processing Program of 20 cents
>> %To determine the diameter of 5
cents
>> %Image Acquisition>> I1=imread('20-2.JPG');
>> figure,imshow(I1)
>> %Cropping the image>> I2=imcrop(I1, [150 100 300
250]);>> figure, imshow(I2)
>> %Convert into grayscale image
>> I3=rgb2gray(I2);>> figure,imshow(I3)
-
7/21/2019 Lab Mathlab
11/14
>>% To show gray histogram
>> figure,imhist(I3)
>> %Convert into binary image>> I4=im2bw(I3,77/255);>> figure,imshow(I4)
>> %To compliment the image>>I5=imcomplement(I4);
>>figure,imshow(I5);
>> %To fill the hole>> I6=imfill(I5,'holes');>> figure,imshow(I6)
-
7/21/2019 Lab Mathlab
12/14
>> %To remove unwanted area>> I7=bwareaopen(I6,10000);>> figure,imshow(I7)
>> %Measure the diameter>> I8=regionprops(I8,'basic');>> A=[I8.Area];>> Dia = sqrt(4*A/pi);
Area = 22394
Diameter = 168.8577
4) Image processing Program of 50 cents
>> %To determine the
diameter of 50 cents
>> %Image Acquisition>> I1=imread('50-2.JPG');>> figure,imshow(I1)
>> %Cropping the image>> I2=imcrop(I1, [150 70
300 250]);>> figure, imshow(I2)
>> %Convert into grayscaleimage>> I3=rgb2gray(I2);>> figure,imshow(I3)
-
7/21/2019 Lab Mathlab
13/14
>>% To show gray histogram
>> figure,imhist(I3)
>> %Convert into binary
image>> I4=im2bw(I3,83/255);>> figure,imshow(I4)
>> %To compliment the image>> I5=imcomplement(I4);>> figure,imshow(I5)
>> %To fill the hole>> I6=imfill(I5,'holes');>> figure,imshow(I6)
>> %To remove the unwanted
area>> I7=bwareaopen(I6,10000);>> figure,imshow(I7)
>> %Measure the diameter>> I8=regionprops(I7,'basic');>> A=[I8.Area];
Area = 30023
Diameter = 195.5159
-
7/21/2019 Lab Mathlab
14/14