problem 3 image processing

6
Problem 3 – Image Processing image1.jpg Write an image processing script to find the average length of the sticks in image1.jpg 1. Use imread to read the image from file 'image1.jpg' into matrix I. 2. Convert the 3channel image to grayscale using the mean function. 3. Create a binary mask of the objects in the image by finding an appropriate intensity threshold such that all the sticks are clearly visible as objects. The binary mask should contain ones where there are objects, and zeros everywhere else. 4. From the connected components, the area and length of the objects are extracted using the regionprops function (this has been done for you). Based on the results, remove the lengths of objects which areas are less than 20 pixels. If done correctly, the number of remaining lengths should match the number of sticks in the image. 5. Display the object lengths in a histogram with 5 bins. [Use the Matlab histogram function] 6. Find the mean of the lengths. * You need to use the variable names given in the skeleton code

Upload: others

Post on 27-Mar-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Problem 3 – Image Processing 

 image1.jpg  

Write an image processing script to find the average length of the sticks in image1.jpg 

1. Use imread to read the image from file 'image1.jpg' into matrix I. 

2. Convert the 3‐channel image to grayscale using the mean function.  

3. Create a binary mask of the objects in the image by finding an appropriate intensity threshold such 

that all the sticks are clearly visible as objects. The binary mask should contain ones where there are 

objects, and zeros everywhere else. 

4. From the connected components, the area and length of the objects are extracted using the 

regionprops function (this has been done for you). Based on the results, remove the lengths of 

objects which areas are less than 20 pixels. If done correctly, the number of remaining lengths should 

match the number of sticks in the image.  

5. Display the object lengths in a histogram with 5 bins. [Use the Matlab histogram function] 

6. Find the mean of the lengths.  

 

* You need to use the variable names given in the skeleton code 

    

Reference solution for Problem 3:  

    

Learner template for Problem 3:  

    

Assessment Tests for Problem 3: