+ All Categories
Home > Documents > 1 Artificial Int Lab Manual

1 Artificial Int Lab Manual

Date post: 31-Dec-2015
Category:
Upload: adnan-alam-khan
View: 22 times
Download: 0 times
Share this document with a friend
Description:
Artificial Intelligence Lab Manual
Popular Tags:
36
Institute of Business & Technology Developed by:Adnan Alam Khan([email protected]) Department of Computer Science & Information Technology Artificial Intelligence
Transcript
Page 1: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Artificial Intelligence

Page 2: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

LIST OF EXPERIMENTS

1. To learn how to select coins from groins.

2. To learn how to identify round objects.

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 3: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

INDEX

S.NO. NAME OF THE EXPERIMENT

PERFORMEDDATE

SUBMITTEDDATE

PAGE NO. REMARKS

__________________________ SIGNATURE OF FACULTY

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 4: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

EXPERIMENT NO. 01

Title: - To learn how to select coins from groins. Objective: - To learn how to select coins from different coins in Matlab. It’s simple Matlab program which selects and display a single circle of an original coin.

(I) Competency Skill: - generic & hence should be repeated in several experiments. (II) Experiment Objective: -

1. To learn basic variables declaration in Matab for Artificial Intelligence and computer visions.2. To learn how objects will be selected in Matlab.3. Convert intensity image to binary image.

(III) Theoretical Background: - 1-Vision.Autothresholder: Convert intensity images to binary images. Autothresholding uses Otsu's method, which determines the threshold by splitting the histogram of the input image to minimize the variance for each of the pixel groups.Syntax: H= vision.Autothresholder returns a System object, H, that automatically converts an intensity image to a binary image.Algorithm: This object implements the algorithm, inputs, and outputs described in the Autothreshold upcoming example. The object properties correspond to the block parameters, except: You can only specify a value of Ignore or Saturate for the InputRangeViolationAction property of the System object. The object does not support the Error and Warn and Saturate options that the corresponding when data range is exceeded block parameter offers.Example:>>X=imread('peppers.png');>>imshow(X);>>img = im2single(rgb2gray(imread('peppers.png')));>>figure, imshow(img);>>hautoth = vision.Autothresholder;>>bin = step(hautoth,img);>>pause(2);>>figure;imshow(bin);

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 5: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

2-Step : Play video or image sequence. Syntax: step(H,I)Description: step(H,I) sends one frame of a multidimensional video I, or image sequence to the video player.3-Find():The find function determines the indices of array elements that meet a given logical condition. In its simplest form, find returns a column vector of indices. Transpose that vector to obtain a row vector of indices.

(IV) Matlab Experiment Code: - % selecting coin from goins hautoth = vision.Autothresholder; hboundtrace = vision.BoundaryTracer; % Read in the image x = imread('coins.png'); imshow(x); % othresholding to binarize the image. bw = step(hautoth,x); % Derive the start points [row, col]= find(bw,1); startpts = [row-2;col]; % Determine the boundaries y = step(hboundtrace,bw,startpts); y(y == 0) = []; % Display the results figure, imshow(bw); hold('on'); plot(y(2:2:end,:)+1,y(1:2:end, :)+1,'r','Linewidth',2);

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 6: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(V) Resource required: - Matlab version 7 Release 14 or advance version

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 7: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(VI) Precautions: -

1. It’s case sensitive software.2. For scripting use Ctrl+N and for rendering press F5.3. Semi colon is necessary after each line but not in the middle of the loop.4. Ctrl+R is used for comments.

(VII) Procedure: -1. Write a program as per mentioned in the lab.2. Ctrl+N for new Matlab program.3. F5 for compilation and execution.4. Required image is as follows.5. Following is the main menu of Matlab.

(VIII) Observation or Calculations: -1. Type your observation =…………………………….2. ________________________________________________________________________________

________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 8: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

___________________________________________________________________________________________________________________________________________________.

(IX) Result: -1. Student must type the result or output of the program=……………………………………..2. ____________________________________________________________________________________

____________________________________________________________________.

(X) INTERPRETATION OF RESULT: -

(XI) CONCLUSION: -

(XII) Experiment Related Que.-1. Define the following terms and write your answers in observation.

vision.Autothresholder; vision.BoundaryTracer; imread();imshow();step();find();figure; plot(); hold('on');

2. Define computer vision.3. Why we use images in computer vision/Artificial Intelligence.

(XIII) Assessment:-S.No. Experiment Max.Mark Obtained

Process

1 Sample code 2

2 Algorithm 2

3 Flow chart 2

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 9: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

4 Syntax 2

5 Team Leadership 2

Product

1 Desired Result 2.5

2 Interpretation of Result 2.5

3 Matlab handling 2.5

4 Viva 2.5

(XIV)Desired Output:-

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 10: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

EXPERIMENT NO. 02

Title: - To learn how to identify round objects. Objective: - To learn how to identify round objects from different shape objects in Matlab. It’s simple Matlab program which selects and display round objects.

(I) Competency Skill: - generic & hence should be repeated in several experiments. (II) Experiment Objective: -

4. To learn basic variables declaration in Matab for Artificial Intelligence and computer visions.5. To learn how objects will be selected in Matlab.6. Convert intensity image to binary image.

(III) Theoretical Background: - 1-Vision.Autothresholder: Convert intensity images to binary images. Autothresholding uses Otsu's method, which determines the threshold by splitting the histogram of the input image to minimize the variance for each of the pixel groups.Syntax: H= vision.Autothresholder returns a System object, H, that automatically converts an intensity image to a binary image.Algorithm: This object implements the algorithm, inputs, and outputs described in the Autothreshold upcoming example. The object properties correspond to the block parameters, except: You can only specify a value of Ignore or Saturate for the InputRangeViolationAction property of the System object. The object does not support the Error and Warn and Saturate options that the corresponding when data range is exceeded block parameter offers.Example:>>X=imread('peppers.png');>>imshow(X);>>img = im2single(rgb2gray(imread('peppers.png')));>>figure, imshow(img);>>hautoth = vision.Autothresholder;>>bin = step(hautoth,img);>>pause(2);>>figure;imshow(bin);

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 11: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

2-Step : Play video or image sequence. Syntax: step(H,I)Description: step(H,I) sends one frame of a multidimensional video I, or image sequence to the video player.3-Find():The find function determines the indices of array elements that meet a given logical condition. In its simplest form, find returns a column vector of indices. Transpose that vector to obtain a row vector of indices.4. rgb2gray():Convert RGB image or color map to grayscale.I = rgb2gray(RGB) converts the true color image RGB to the grayscale intensity image I. rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.Algo: rgb2gray converts RGB values to grayscale values by forming a weighted sum of the R, G, and B components:0.2989 * R + 0.5870 * G + 0.1140 * B

E.g.1.>> I= imread('board.tif');>>J = rgb2gray(I);>>figure, imshow(I), figure, imshow(J);E.g.2.Convert the colormap to a grayscale colormap. >>[X,map] = imread('trees.tif');>>gmap = rgb2gray(map);>>figure, imshow(X,map), figure, imshow(X,gmap);5. graythresh():Global image threshold using Otsu's method. level = graythresh(I) computes a global threshold (level) that can be used to convert an intensity image to a binary image with im2bw. Level is a normalized intensity value that lies in the range [0, 1].E.g.1.>>I = imread('coins.png');>>level = graythresh(I);>>BW = im2bw(I,level);>>imshow(BW)

(IV) Matlab Experiment Code: - % Step 1: Read Image% Read in pills_etc.png.RGB = imread('pillsetc.png');imshow(RGB);% Step 2: Threshold the Image% Convert the image to black and white in order to prepare for boundary tracing using bwboundaries.

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 12: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

I = rgb2gray(RGB);threshold = graythresh(I);bw = im2bw(I,threshold);figure,imshow(bw);% Step 3: Remove the Noise% Using morphology functions, remove pixels which do not belong to the objects of interest.% remove all object containing fewer than 30 pixelsbw = bwareaopen(bw,30);% fill a gap in the pen's capse = strel('disk',2);bw = imclose(bw,se);% fill any holes, so that regionprops can be used to estimate% the area enclosed by each of the boundariesbw = imfill(bw,'holes');figure,imshow(bw);% Step 4: Find the Boundaries% Concentrate only on the exterior boundaries. Option 'noholes' will accelerate the processing by preventing bwboundaries from searching for inner contours.[B,L] = bwboundaries(bw,'noholes');% Display the label matrix and draw each boundaryfigure , imshow(label2rgb(L, @jet, [.5 .5 .5])),figure , imshow(label2rgb(L, @jet, [.5 .5 .5]));hold onfor k = 1:length(B) boundary = B{k}; plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)end% Step 5: Determine which Objects are Round% Estimate each object's area and perimeter. Use these results to form a simple metric indicating the roundness of an object:% metric = 4*pi*area/perimeter^2.% This metric is equal to one only for a circle and it is less than one for any other shape. The discrimination process can be controlled by setting an appropriate threshold. In this example use a threshold of 0.94 so that only the pills will be classified as round.% Use regionprops to obtain estimates of the area for all of the objects. Notice that the label matrix returned by bwboundaries can be reused by regionprops.stats = regionprops(L,'Area','Centroid');threshold = 0.94;% loop over the boundariesfor k = 1:length(B) % obtain (X,Y) boundary coordinates corresponding to label 'k' boundary = B{k}; % compute a simple estimate of the object's perimeter delta_sq = diff(boundary).^2; perimeter = sum(sqrt(sum(delta_sq,2))); % obtain the area calculation corresponding to label 'k' area = stats(k).Area; % compute the roundness metric metric = 4*pi*area/perimeter^2; % display the results metric_string = sprintf('%2.2f',metric); % mark objects above the threshold with a black circle if metric > threshold

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 13: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

centroid = stats(k).Centroid; plot(centroid(1),centroid(2),'ko'); end text(boundary(1,2)-35,boundary(1,1)+13,metric_string,'Color','y',... 'FontSize',14,'FontWeight','bold');endtitle(['Metrics closer to 1 indicate that ',... 'the object is approximately round']);

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 14: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(V) Resource required: - Matlab version 7 Release 14 or advance version

(VI) Precautions: -5. It’s case sensitive software.6. For scripting use Ctrl+N and for rendering press F5.7. Semi colon is necessary after each line but not in the middle of the loop.8. Ctrl+R is used for comments.

(VII) Procedure: -

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 15: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

6. Write a program as per mentioned in the lab.7. Ctrl+N for new Matlab program.8. F5 for compilation and execution.9. Required image is as follows.10. Following is the main menu of Matlab.

(VIII) Observation or Calculations: -3. Type your observation =…………………………….4. ________________________________________________________________________________

________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 16: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

___________________________________________________________________________________________________________________________________________________.

(IX) Result: -3. Student must type the result or output of the program=……………………………………..4. ____________________________________________________________________________________

____________________________________________________________________.

(X) INTERPRETATION OF RESULT: -

(XI) CONCLUSION: -

(XII) Experiment Related Questions.4. Define the following terms and write your answers in observation or in Quiz.

vision.Autothresholder; vision.BoundaryTracer; imread();imshow();step();find();figure; plot(); hold('on'); rgb2gray();graythresh(); im2bw();bwareaopen(); strel(); imclose();imfill();bwboundaries();label2rgb();regionprops();

5. Define computer vision.6. Why we use images in computer vision/Artificial Intelligence.

(XIII) Assessment:-S.No. Experiment Max.Mark Obtained

Process

1 Sample code 2

2 Algorithm 2

3 Flow chart 2

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 17: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

4 Syntax 2

5 Team Leadership 2

Product

1 Desired Result 2.5

2 Interpretation of Result 2.5

3 Matlab handling 2.5

4 Viva 2.5

(XIV)Desired Output:-

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 18: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

EXPERIMENT NO. 03

Title: - To learn how to detect cancer cell. Objective: - To learn how to detect cancer cell of different shape objects in Matlab. It’s simple Matlab program which selects and display cancer cell as an object. This example shows how to detect a cell using edge detection and basic morphology. An object can be easily detected in an image if the object has sufficient contrast from the background. In this example, the cells are prostate cancer cells.

(I) Competency Skill: - generic & hence should be repeated in several experiments. (II) Experiment Objective: -

7. To learn basic variables declaration in Matab for Artificial Intelligence and computer visions.8. To learn how objects will be selected in Matlab.9. Convert intensity image to binary image.

(III) Theoretical Background: - 1-Vision.Autothresholder: Convert intensity images to binary images. Autothresholding uses Otsu's method, which determines the threshold by splitting the histogram of the input image to minimize the variance for each of the pixel groups.Syntax: H= vision.Autothresholder returns a System object, H, that automatically converts an intensity image to a binary image.Algorithm: This object implements the algorithm, inputs, and outputs described in the Autothreshold upcoming example. The object properties correspond to the block parameters, except: You can only specify a value of Ignore or Saturate for the InputRangeViolationAction property of the System object. The object does not support the Error and Warn and Saturate options that the corresponding when data range is exceeded block parameter offers.Step 1: Read ImageRead in the cell.tif image, which is an image of a prostate cancer cell.

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 19: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

%Step 1I = imread('cell.tif');figure, imshow(I), title('original image');text(size(I,2),size(I,1)+15, ... 'Prostate cancer cell', ... 'FontSize',7,'HorizontalAlignment','right');text(size(I,2),size(I,1)+25, .... 'Adnan Computer Vision', ... 'FontSize',7,'HorizontalAlignment','right');

% Step2[~, threshold] = edge(I, 'sobel');fudgeFactor = .5;BWs = edge(I,'sobel', threshold * fudgeFactor);figure, imshow(BWs), title('binary gradient mask'); se90 = strel('line', 3, 90);se0 = strel('line', 3, 0); BWsdil = imdilate(BWs, [se90 se0]);figure, imshow(BWsdil), title('dilated gradient mask');

%Step 4BWdfill = imfill(BWsdil, 'holes');figure, imshow(BWdfill);title('binary image with filled holes');

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 20: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

%Step5BWnobord = imclearborder(BWdfill, 4);figure, imshow(BWnobord), title('cleared border image');

%Step 6seD = strel('diamond',1);BWfinal = imerode(BWnobord,seD);BWfinal = imerode(BWfinal,seD);figure, imshow(BWfinal), title('segmented image');

%Step 7BWoutline = bwperim(BWfinal);Segout = I;Segout(BWoutline) = 255;figure, imshow(Segout), title('outlined original image');

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 21: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(IV) Matlab Experiment Code: - %Step 1I = imread('cell.tif');figure, imshow(I), title('original image');text(size(I,2),size(I,1)+15, ... 'Prostate cancer cell', ... 'FontSize',7,'HorizontalAlignment','right');text(size(I,2),size(I,1)+25, .... 'Adnan Computer Vision', ... 'FontSize',7,'HorizontalAlignment','right');% Step2[~, threshold] = edge(I, 'sobel');fudgeFactor = .5;BWs = edge(I,'sobel', threshold * fudgeFactor);figure, imshow(BWs), title('binary gradient mask'); se90 = strel('line', 3, 90);se0 = strel('line', 3, 0); BWsdil = imdilate(BWs, [se90 se0]);figure, imshow(BWsdil), title('dilated gradient mask'); %Step 4BWdfill = imfill(BWsdil, 'holes');figure, imshow(BWdfill);title('binary image with filled holes'); %Step5BWnobord = imclearborder(BWdfill, 4);figure, imshow(BWnobord), title('cleared border image'); %Step 6seD = strel('diamond',1);BWfinal = imerode(BWnobord,seD);BWfinal = imerode(BWfinal,seD);figure, imshow(BWfinal), title('segmented image'); %Step 7BWoutline = bwperim(BWfinal);Segout = I;Segout(BWoutline) = 255;figure, imshow(Segout), title('outlined original image');

(V) Resource required: - Matlab version 7 Release 14 or advance version

(VI) Precautions: -9. It’s case sensitive software.10. For scripting use Ctrl+N and for rendering press F5.11. Semi colon is necessary after each line but not in the middle of the loop.12. Ctrl+R is used for comments.

(VII) Procedure: -

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 22: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

11. Write a program as per mentioned in the lab.12. Ctrl+N for new Matlab program.13. F5 for compilation and execution.14. Required image is as follows.15. Following is the main menu of Matlab.

(VIII) Observation or Calculations: -5. Type your observation =…………………………….6. ________________________________________________________________________________

___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________.

(IX) Result: -5. Student must type the result or output of the program=……………………………………..6. ____________________________________________________________________________________

____________________________________________________________________.

(X) INTERPRETATION OF RESULT: -

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 23: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(XI) CONCLUSION: -

(XII) Experiment Related Questions.7. Define the following terms and write your answers in observation or in Quiz.

fudgeFactor , edge , strel() , imdilate() , imfill(), imclearborder() , imerode(), bwperim() , segout()8. Define computer vision.9. Why we use images in computer vision/Artificial Intelligence.

(XIII) Assessment:-S.No. Experiment Max.Mark Obtained

Process

1 Sample code 2

2 Algorithm 2

3 Flow chart 2

4 Syntax 2

5 Team Leadership 2

Product

1 Desired Result 2.5

2 Interpretation of Result 2.5

3 Matlab handling 2.5

4 Viva 2.5

(XIV)Desired Output:-

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 24: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

EXPERIMENT NO. 04

Title: - To learn how to measure properties of objects in a grayscale image. Objective: - The function regionprops is very useful for measuring the properties of objects in a binary image. There are documentation examples and product examples showing how to do this. But sometimes you need to process pixel values in the "original" grayscale image. In other words, suppose your process is something like this:1. Segment grayscale image to get a binary image of objects.2. Analyze the original grayscale pixel values corresponding to each object in the binary image.This example shows you how to accomplish this workflow using regionprops.

(I) Competency Skill: - generic & hence should be repeated in biometrics experiments. (II) Experiment Objective: -

1. To learn basic variables declaration in Matab for Artificial Intelligence and computer visions.2. To learn how objects will be selected in Matlab.3. Convert intensity image to binary image.

(III) Theoretical Background: -The function regionprops is very useful for measuring the properties of objects in a binary image. There are documentation examples and product demos showing how to do this.But sometimes you need to process pixel values in the "original" grayscale image. In other words, suppose your process is something like this:1. Segment grayscale image to get a binary image of objects.2. Analyze the original grayscale pixel values corresponding to each object in the binary image.This demo shows you how to accomplish this workflow using regionprops.Step 1: Create Synthetic ImageStep 2: Create a Binary ImageStep 3: Calculate Object Properties Using Pixel Values of Grayscale ImageStep 4: Calculate Custom Pixel Value-Based Properties

(IV) Matlab Experiment Code: - % Step 1: Create Synthetic Image% Create a grayscale image that contains some distinct regions.I = propsSynthesizeImage;imshow(I)title('Synthetic Image');% Step 2: Create a Binary Image% Segment the grayscale image by creating a binary image containing % the objects in the image.BW = I > 0;figure , imshow(BW)

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 25: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

title('Binary Image');% Step 3: Calculate Object Properties Using Pixel Values of Grayscale % Image.The regionprops function supports several properties that can % be used with grayscale images, % including 'WeightedCentroid', % 'MeanIntensity', 'MinIntensity', and 'MaxIntensity'. % These properties use the original pixel values of the objects for % their calculations.s = regionprops(BW, I, {'Centroid','WeightedCentroid'});% To compare the weighted centroid locations with the unweighted % centroid locations, display the original image and then, using the % holdand plot functions, superimpose the centroids on the image.figure, imshow(I)title('Weighted (red) and Unweighted (blue) Centroid Locations');hold onnumObj = numel(s);for k = 1 : numObj plot(s(k).WeightedCentroid(1), s(k).WeightedCentroid(2), 'r*'); plot(s(k).Centroid(1), s(k).Centroid(2), 'bo');endhold off% Step 4: Calculate Custom Pixel Value-Based Properties% You can use the 'PixelValues' property to do custom calculations % based on the pixel values of the original grayscale image. % The 'PixelValues' property returns% a vector containing the grayscale values of pixels in a region.% As an example, calculate the standard deviation of each region.s = regionprops(BW, I, {'Centroid','PixelValues','BoundingBox'});figure, imshow(I);title('Standard Deviation of Regions');hold onfor k = 1 : numObj s(k).StandardDeviation = std(double(s(k).PixelValues)); text(s(k).Centroid(1),s(k).Centroid(2), ... sprintf('%2.1f', s(k).StandardDeviation), ... 'EdgeColor','b','Color','r');endhold off% This figure shows the standard deviation measurement superimposed on each % object in the image. You can also view the results in other ways, for % example as a bar plot showing the standard deviation by label number.figurebar(1:numObj,[s.StandardDeviation]);xlabel('Region Label Number');ylabel('Standard Deviation');% You can use the plot to determine how to partition the data. % For example, the following code identifies objects with a standard % deviation lower than 50.sStd = [s.StandardDeviation];lowStd = find(sStd < 50);imshow(I);title('Objects Having Standard Deviation < 50');hold on;for k = 1 : length(lowStd) rectangle('Position', s(lowStd(k)).BoundingBox, ... 'EdgeColor','y');

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 26: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

endhold off;

(V) Resource required: - Matlab version 7 Release 14 or advance version

(VI) Precautions: -13. It’s case sensitive software.14. For scripting use Ctrl+N and for rendering press F5.15. Semi colon is necessary after each line but not in the middle of the loop.16. Ctrl+R is used for comments.

(VII) Procedure: -16. Write a program as per mentioned in the lab.17. Ctrl+N for new Matlab program.18. F5 for compilation and execution.19. Required image is as follows.20. Following is the main menu of Matlab.

(VIII) Observation or Calculations: -7. Type your observation =…………………………….8. ________________________________________________________________________________

________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

(IX) Result: -7. Student must type the result or output of the program=……………………………………..8. ____________________________________________________________________________________

____________________________________________________________________.

(X) INTERPRETATION OF RESULT: -

(XI) CONCLUSION: -

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 27: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

(XII) Experiment Related Questions.10. Define the following terms and write your answers in observation or in Quiz.

fudgeFactor , edge , strel() , imdilate() , imfill(), imclearborder() , imerode(), bwperim() , segout()11. Define computer vision.12. Why we use images in computer vision/Artificial Intelligence.

(XIII) Assessment:-S.No. Experiment Max.Mark Obtained

Process

1 Sample code 2

2 Algorithm 2

3 Flow chart 2

4 Syntax 2

5 Team Leadership 2

Product

1 Desired Result 2.5

2 Interpretation of Result 2.5

3 Matlab handling 2.5

4 Viva 2.5

(XIV)Desired Output:-

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology

Page 28: 1 Artificial Int Lab Manual

Institute of Business & Technology (Artificial Intelligence)

Developed by:Adnan Alam Khan([email protected])Department of Computer Science & Information Technology


Recommended