ECSE4540: Homework#6 solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (1 vote)

1. (15 points.) Write a Matlab function that calls the superpixels command with a number of superpixels K to show (1) a figure with the K superpixel boundaries superimposed on the original image, and (2) a figure where each of the K superpixels is replaced with the average color inside the region, creating a “stained glass” effect. Hint: doc superpixels describes the necessary process. Now apply your function to the glass.png image. Include with your homework plots and correspondingvaluesofK thatresultin“toomany”superpixels(i.e.,oversegmentation),“toofew” superpixels(i.e.,undersegmentation)and“justright”.
2. (15 points.) Use the Matlab Image Segmenter to investigate the performance of active contour based segmentation on the images elk.png and fish.png. For each image, first draw a freehand initial contour that roughly segments the object of interest (without trying to get too close to the actual boundary). Then apply both the edge-based segmentation algorithm with 600 iterations (click on the “Method” area at upper left to change it) and the region-based segmentation algorithm with 300 iterations (the default). For each of the images, include a picture of your initial contour, the edge-based segmentation, and the region-based segmentation. Critically discuss the behavior of each technique for each image. What was the overall speed? Where did each segmentationalgorithmworkwell,andwherediditfail(andwhy)?
3. (25points.) Loadtheimagetomatoes.png. Thegoalinthisproblemistotrytogetagoodestimate of the number of tomatoes using image processing. You can see that almost every tomato has a singleglintofwhiteonitssurfacefromthereflectionoflight. Writeanimageprocessingalgorithm todetectandcountthesewhitespots. Hint: byusingtheDataCursorintheMatlabfigurewindow (or a Paint program), you can look at the color values of the white pixels (generally high values of R, G, and B) as well as the color values of the tomatoes (generally very high values of R, middle values of G, low values of B). You can create a binary image by thresholding the color channels at different values to isolate just the white pixels. Adjust your threshold so you visually get a white spot on each tomato. On the other hand, you probably will need to use regionprops to find and remove spurious detections that only contain a small number of pixels. Finally, use regionprops andplottofindthecentroidsoftheremainingblobsandplottheselocationsasbiggreendotson topoftheoriginalimage. Howmanytomatoesdidyoufindwithyouralgorithm? Forfullcredit,be sure to include full details about your algorithmic process, including the values of any thresholds youused.
4. (25 points.) Load the image buttons.png. The goal inthis problem istouseoperations on binary imagestoextractthecoloredbuttonsonthecards. Here’stheroughprocessyoushoulduse:
• FindthewhitecardsbycreatingabinaryimagebyfindingpixelswhoseR,G,andBvaluesare all above a high threshold. This step will also pick up the white shelves in between the racks ofbuttons. • Usethe bwfill commandtofillintheholesintheimage(i.e.,thelocationsofthebuttons). • Determine the logical operation on the previous two images that will result in an image with justthebuttonlocations(andsmallareasofextrajunk). • Use regionprops to isolate only those binary regions that are (1) sufficiently large and (2) sufficiently circular (e.g., using the Eccentricity or MajorAxisLength/MinorAxisLength options).
Provide an image and some discussion for each intermediate step of your process, including the valuesofanythresholdsyouused. Whichbuttonsdidyouralgorithmmissateachstepandwhy?
5. (20points.)
(a) Use strel tocreateastructuringelement d3,adiskofradius3. (b) Apply d3 to erode the binary image in drink.png using imerode. Describe what happened andwhy. (c) Apply d3 to dilate the result of part (b) using imdilate. Describe what happened and why. Note that the result is what you would have gotten by applying imopen to the original image withstructuringelement d3. (d) Nowsupposeweweretoreversetheorderoferosionanddilation(i.e.,morphologicalclosing insteadofmorphologicalopening). Explainwhatyousee,anddiscusswhythetworesultsare different.