1. Homepage
  2. Programming
  3. [2022] UNSW - COMP9517 Computer Vision - Lab4 Image Segmentation

[2022] UNSW - COMP9517 Computer Vision - Lab4 Image Segmentation

Engage in a Conversation
UNSWCOMP9517Computer VisionPythonJupyter NotebookOpenCVImage SegmentationMeanShiftWatershedScikit-learnScikit-image

COMP9517: Computer Vision 2022 T2 Lab 4 Specification Maximum Marks Achievable: 2.5 CourseNana.COM

This lab is worth 2.5% of the total course marks. CourseNana.COM


CourseNana.COM


CourseNana.COM

Objective: This lab revisits important concepts covered in the lectures of Week 5 and aims to make you familiar with implementing specific algorithms. CourseNana.COM


CourseNana.COM

Materials: The sample images and template code to be used in the tasks of this lab are available in WebCMS3. You are required to use OpenCV 3+ with Python 3+. CourseNana.COM


CourseNana.COM

Submission: The tasks are assessable after the lab. Submit your source code as a Jupyter notebook (.ipynb) with output images (.png) in a single zip file by the above deadline. The submission link will be announced in due time. CourseNana.COM

The sample image Eggs.png is to be used for all tasks. CourseNana.COM


CourseNana.COM


CourseNana.COM

Image Segmentation CourseNana.COM

The goal of image segmentation is to assign a label to each pixel in an image, indicating whether it belongs to an object (and which object) or the background. It is one of the key research topics in computer vision and there are many different approaches: interactive segmentation, semantic segmentation, instance segmentation, and more. CourseNana.COM


CourseNana.COM

In this lab the MeanShift clustering algorithm and the Watershed algorithm will be used to solve unsupervised image segmentation. CourseNana.COM


CourseNana.COM

MeanShift is a clustering algorithm that assigns pixels to clusters by iteratively shifting points towards the modes in the feature space, where a mode is a position with the locally highest number of data points (highest density). A visualisation can be seen here. CourseNana.COM


CourseNana.COM

Watershed is a transformation that aims to segment the regions of interest in a grayscale image. This method is particularly useful when two regions of interest are close to each other (that is, their edges touch). It treats the image as a topographic map, with the intensity of each pixel representing the height. For instance, dark areas are considered to be ‘lower’ and act as troughs, whereas bright areas are ‘higher’ and act as hills or a mountain ridge. CourseNana.COM

CourseNana.COM

Visualising the Watershed: The left image can be topographically represented as the image on the right. Adopted from Agarwal 2015. CourseNana.COM

  CourseNana.COM

Task 1 (0.5 mark): Use the MeanShift algorithm for image segmentation. CourseNana.COM

Hint: Use MeanShift clustering from Scikit-learn. CourseNana.COM


CourseNana.COM

Step 1. Once you have read the image into Numpy arrays, extract each colour channel (R, G, B) so you can use each as a variable for classification. To do this you will need to convert the colour matrices into a flattened vector as depicted below. CourseNana.COM

CourseNana.COM

Step 2. Then you can use the new flattened colour sample matrix (e.g. 10,000 x 3 if your original image was 100 x 100) as your variable for classification. CourseNana.COM

Step 3. Use the MeanShift fit_predict() function to perform a clustering and save the cluster labels, which we want to observe. CourseNana.COM

Submit the segmented image. CourseNana.COM


CourseNana.COM


CourseNana.COM

Task 2 (1 mark): Use Watershed transformation for image segmentation. CourseNana.COM

Hint: Use Watershed segmentation from Scikit-image. CourseNana.COM


CourseNana.COM

Step 1. Convert the image to grayscale. Then use an appropriate threshold value to convert the grayscale image into a binary image (objects versus background). Hint: Use built-in functions for thresholding. CourseNana.COM

Step 2. Calculate the distance transform of the binary image. Note: Visualising this step may help you understand how the algorithm works. Plot the result of the distance transform to see what is happening under the hood. CourseNana.COM

Step 3. Generate the Watershed markers as the ‘clusters’ furthest away from the background. This can be syntactically confusing, so make sure to check the example code on CourseNana.COM

the page linked above. Hint: Experiment with different local search region sizes in this step and the threshold value in Step 1 above for good segmentation results. CourseNana.COM

Step 4. Perform Watershed on the image. This is the part where the image is ‘flooded’ and the water level increases in the ‘catchment basins’ based on the markers found in Step 3. CourseNana.COM

Submit the segmented image.
CourseNana.COM


CourseNana.COM


Task 3 (1 mark): Compare MeanShift and Watershed segmentation results. CourseNana.COM


CourseNana.COM

For this task you will need to use the provided MaskX.png (X = 1...6) images which contain the ‘true’ (manually annotated) binary masks of the objects in Eggs.png. CourseNana.COM


CourseNana.COM

CourseNana.COM

Step 1. For each mask, compute the Dice similarity coefficient (DSC) (see the lecture slides) for each region (label) of the MeanShift segmented image, and report the largest DSC. The segmented region that yields the largest DSC has the largest overlap with the given mask. Repeat this for all masks and report the average DSC. CourseNana.COM

Step 2. Repeat Step 1 but for the Watershed segmented image (follow the hints provided in Task 2 to get a reasonable segmentation result). Altogether this allows you to complete the following table, to be created and shown in your notebook (the precise table format in your notebook does not matter, as long as it is easily readable like here): CourseNana.COM


CourseNana.COM

CourseNana.COM

DSC CourseNana.COM

MeanShift CourseNana.COM

Watershed CourseNana.COM

Mask1 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Mask2 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Mask3 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Mask4 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Mask5 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Mask6 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Average CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Step 3. Based on these results, briefly discuss in your notebook which method performs best and what could be the explanation for this based on the theory. Also make suggestions which pre/post-processing methods could improve the segmentation results. CourseNana.COM


CourseNana.COM


CourseNana.COM

Coding Requirements and Suggestions CourseNana.COM

In your Jupyter notebook, the input images should be readable from the location specified as an argument, and all output images and other requested results should be displayed in the notebook environment. All cells in your notebook should have been executed so that the tutor/marker does not need to execute the notebook again to see the results. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
UNSW代写,COMP9517代写,Computer Vision代写,Python代写,Jupyter Notebook代写,OpenCV代写,Image Segmentation代写,MeanShift代写,Watershed代写,Scikit-learn代写,Scikit-image代写,UNSW代编,COMP9517代编,Computer Vision代编,Python代编,Jupyter Notebook代编,OpenCV代编,Image Segmentation代编,MeanShift代编,Watershed代编,Scikit-learn代编,Scikit-image代编,UNSW代考,COMP9517代考,Computer Vision代考,Python代考,Jupyter Notebook代考,OpenCV代考,Image Segmentation代考,MeanShift代考,Watershed代考,Scikit-learn代考,Scikit-image代考,UNSWhelp,COMP9517help,Computer Visionhelp,Pythonhelp,Jupyter Notebookhelp,OpenCVhelp,Image Segmentationhelp,MeanShifthelp,Watershedhelp,Scikit-learnhelp,Scikit-imagehelp,UNSW作业代写,COMP9517作业代写,Computer Vision作业代写,Python作业代写,Jupyter Notebook作业代写,OpenCV作业代写,Image Segmentation作业代写,MeanShift作业代写,Watershed作业代写,Scikit-learn作业代写,Scikit-image作业代写,UNSW编程代写,COMP9517编程代写,Computer Vision编程代写,Python编程代写,Jupyter Notebook编程代写,OpenCV编程代写,Image Segmentation编程代写,MeanShift编程代写,Watershed编程代写,Scikit-learn编程代写,Scikit-image编程代写,UNSWprogramming help,COMP9517programming help,Computer Visionprogramming help,Pythonprogramming help,Jupyter Notebookprogramming help,OpenCVprogramming help,Image Segmentationprogramming help,MeanShiftprogramming help,Watershedprogramming help,Scikit-learnprogramming help,Scikit-imageprogramming help,UNSWassignment help,COMP9517assignment help,Computer Visionassignment help,Pythonassignment help,Jupyter Notebookassignment help,OpenCVassignment help,Image Segmentationassignment help,MeanShiftassignment help,Watershedassignment help,Scikit-learnassignment help,Scikit-imageassignment help,UNSWsolution,COMP9517solution,Computer Visionsolution,Pythonsolution,Jupyter Notebooksolution,OpenCVsolution,Image Segmentationsolution,MeanShiftsolution,Watershedsolution,Scikit-learnsolution,Scikit-imagesolution,