CS1674: Homework 5

Due: 10/11/2023, 11:59pm

This assignment is worth 50 points.


Part I: Circle detection (30 points)



In this problem, you will implement a Hough Transform circle detector that takes an input image and a fixed radius, and returns the centers of any detected circles of about that size. You are not allowed to use any built-in Matlab functions for finding edges or circles!

The following function is provided on Canvas:
Include the following in your submission:
  1. [20 pts] function [centers] = detectCircles(im, edges, radius, top_k) -- A function to find and visualize circles given an edge map.

    Inputs:
    Output:
    Tips:

  2. [10 pts] Demonstrate the function applied to the provided images jupiter.jpg and egg.jpg. Display the images with detected circle(s), label the figure with the radius, save your image outputs, and include them in your submission. You can use impixelinfo to estimate the radius of interest manually.

Part II: Image segmentation with K-means (20 points)

For this problem, you will "quantize" a color space by applying k-means clustering to the pixels. You will map each pixel in the input image to its nearest k-means center. That is, you will replace the R,G,B value at each pixel with the average R,G,B value in the cluster to which that pixel belongs. This reduces the amount of information carried by the image, since pixels that had different colors now have the same color. It is also a form of segmentation, since there is only a small number of colors, and the ID of the cluster to which an image pixel belongs is the same as the pixel's color. Note that the RGB values should be treated jointly as the 3-dimensional representation of your pixel.

Include the following in your submission:
  1. [15 pts] function [outputImg, meanColors, clusterIds] = quantizeRGB(origImg, k) which performs clustering in the 3-dimensional RGB space, and "quantizes" the image. Use the built-in Matlab function kmeans (and read the documentation to see how to use it, including what data types it expects). At the end of your function, show the (1) original and (2) quantized image, in a 1x2 subplot. Make sure to label the figure with the value of k that was used.

    Inputs:
    Outputs:
    Tip: If the variable origImg is a 3d matrix (numrowsxnumcolsx3) containing a color image with numpixels pixels (first two dimensions) in each color channel (third dimension), then X = reshape(origImg, [numpixels, 3]); will yield a matrix with the RGB features as its rows. It is in this space (samples = rows, features = columns) that you want to apply k-means.

  2. [5 pts] Run your function on the provided image fish.jpg. Use three different values of k; display and submit the results. For example, if you set k=2, you might get the following as part of your subplot:




Submission:
Acknowledgement: This assignment was adapted from Kristen Grauman's original assignment.