Task 1 (35 points)
Figure 1: Example inputs and outputs of the remove_holes function.
Write a Matlab function that takes in as argument a binary image A (not a filename), and returns another binary image B, which is the result of removing all holes from A. We will use this (somewhat artificial) definition: A hole is a black 4-connected component that does not include pixel (1,1). If pixel (1,1) in A is black, then we use the term “background” for the 4-connected component of all black pixels to which pixel (1, 1) belongs. If pixel (1,1) is white, then the result of your function should be an all-white image.
You should assume that the input image is a grayscale image (single-channel, not containing three RGB channels), whose values are of type uint8. You should further assume that pixels in the input image can only have two values: 0 (black) or 255 (white). Your function will only be tested on images that satisfy these assumptions. The output image should also be a single-channel grayscale image, whose values are of type uint8. The result should satisfy these specs:
If a pixel is white in the input image, it should be white in the result image.
If a pixel belongs to a hole in the input image (according to the definition of a hole given above), it should be white in the result image.
If a pixel is black in the input image and it belongs to the background (according to the definition of “background” given above), that pixel should be black in the result image.
Your function should be named remove_holes, and should take a single argument, i.e., the binary image that you want to process.
>> result = remove_holes(my_image);
The key idea that makes it easy to identify holes is this: if C is the negation of A (C = ~A, in Matlab), a hole in A is a white connected component in C. The background in A also becomes a white connected component in C, but the label of the background (as returned by bwlabel(C, 4)) will be different than the label of any hole.
The specifications for this function are general and mathematical in nature. Therefore, your function should work for any image, not just the examples provided above. My solution for this task is 16 lines of code. Shorter or longer solutions are also possible.
Task 2 (35 points)
image showing area
of soccer field
image showing locations
of red team players
image showing locations
of blue team players
Write a Matlab function that takes as input the image of a soccer field that is shown above, and produces three images (as shown in the figure above), that illustrate:
In Figure 1: the area of the soccer field.
In Figure 2: the locations of the red players.
In Figure 3: the locations of the blue players.
Your function should be named soccer_analysis, and should take a single argument, the soccer field image that you wish to analyze. Your function will only be tested on the soccer field image shown above. That image is a three-channel RGB image, whose values are of type uint8. As long as your solution works well on that image, you will receive full credit.
The function does not return any values, it simply generate the three figures specified above. To generate multiple figures you can use something like:
Your solution should just consist of images like the ones displayed above. You do not need to output anything else (such as number of players, bounding boxes, or anything like that). You are free to use any thresholds you like, and your solution only needs to work on this image. Your results do not need to match the results shown above pixel-by-pixel, but they should be mostly similar. The results shown above identify correctly the regions of eight red players and eleven blue players.
My solution for this task was 16 lines of code (in addition to code written for task 1). Shorter or longer solutions are also possible.
Task 3 (30 points)
image showing the sky area
image showing the ocean area
Write a Matlab function that takes as input the original image shown above, and produces two images (as shown in the figure above), that illustrate:
In Figure 1: the sky area.
In Figure 2: the ocean area.
Your function should be named ocean_segmentation, and should take a single argument, which will be the original image shown above. The input image will be a single-channel grayscale image, whose values are of type uint8. Your function will only be tested on the image shown above. As long as your solution works well on that image, you will receive full credit.
My solution for this task was 14 lines of code (in addition to code written for task 1). Shorter or longer solutions are possible. Your result images are not expected to be identical pixel-by-pixel to the results shown above, but they should be mostly similar.
Things to note
Input images for tasks 2 and 3, and example input and output images for all tasks can be found at the data directory, and can also be downloaded as a zip file.
For task 1, the solution should work for any binary image.
There is no single unique answer for tasks 2 and 3. Just make sure your solution looks reasonable.
For tasks 2 and 3, your solution only needs to work for the input image specified for each task.
For tasks 2 and 3, feel free to combine any morphological operations, convolutions, thresholding, or any other computer vision-based techniques you can think of to obtain the desired result.
How to submit
Submissions are only accepted via Blackboard. Submit a file called assignment2.zip, containing the following files:
The Matlab source files implementing your solutions to the programming tasks.
Any additional Matlab source files that are needed to run your code. If your code needs any code files available on the course website, please include those files with your submission.
A README.txt file containing the name and UTA ID number of the student. No other information is needed for README.txt.
We try to automate the grading process as much as possible. Not complying precisely with the above instructions and naming conventions causes a significant waste of time during grading, and thus points will be taken off for failure to comply, and/or you may receive a request to resubmit.
Please only include source code in your submissions. Do not include data files.
Code must run in Matlab version 2018b.
The submission should be a ZIP file. Any other file format will not be accepted.