3.1 Image Segmentation
(a) Hand calculation: Apply Hough transform to the following image to detect the straight line.
Assumption: use polar parameterization of lines and treat the lower left pixel (0,0) so the line is
xcos9 ysing d. where dis the perpendicular distance from line to the origin and 0 angle the
perpendicular makes with the horizontal axis.
Algorithm for hand calculation
1) Initialize matrix M(d,9) zeros.
2) For each non- zero point l(x.y)in the given image
For 0 [0°. 45° 90°,135°]
Compute d= xcost ysinf
Update M(d, 0 M(d,0) +
4) he detected line is xcost ysin0 d'
Show two results: (1) your M(d.8 (2) The detected line (expression simplified).
(b) Write programs: Pixel classification clustering is powerful tool for image segmentation Use
image: duck jpg. Implement an image segmentation scheme as follows: (1) Flatten the image
where each pixel is described by five features i.e. the red. green, blue, horizontal
location and vertical location, denoted as F. In this case should be 50,589 by 5. (2) Cluster
classic means algorithm given =2. Display two images in subplot: (1) The original image (2)
The cluster index image. Notes: Make sure in [R.G.B.X,Y] space each column is normalized to [0,1].
Helpers: meshgrid, reshape, kmeans.
3.2 Image Representation
(a)Hand Calculation: Run length coding. Give the run length coding of each row.
(b) Hand Calculation: Medial axis transform. Give the medial axis transform in format [x, y, r]
(sorted with value) of the following image, treat the upper left corner as (1,1), horizontal andy
is vertical axis.
(c) Write programs: Connected component analysis. Use the image: coins.png Normalize to [0,1])
Steps: (1) Threshold the image to binary with threshold 0.35. (2) Obtain the centroid, the major and
minor axis length for each coin. (3) compute the radius by the arithmetic mean of the major and
minor axis length for each coin. (4) Draw circles on the original image. Display the image with a
circle surrounding each coin. Helpers: mat2gray, im2bw. regionprops, viscircles.
3.3 Mathematical Morphology
(a) Hand calculation: Refer to HW3R, compute binary dilation and erosion for the given binary
image. The kernel is 3x ones origin at the center. Treat element outside the border as "false"
(a) Hand calculation: Refer to HW3R, compute gray-scale dilation and crosion for the given gray-
scale image. The kernel is 3 x 3 of ones origin at the center. Treat element outside the border as
negative infinity when computing dilation and positive infinity when computing crosion
(c) Write programs: Basic morphology and its gradients. Use the image: cameraman. tif. Generate
and display six images in subplot: (1) The original image. (2) Dilation of the image with kernel 3
x 3 of ones origin at the center. (3) Erosion of the image with the sarne kernel. (4) Basic gradient:
subtract the erosion from the dilation (5) External gradient: subtract the original image from its
dilation. (6) Inner gradient: subtract the crosion from the original image. Helpers: imdilate, imerode.
3.4 Distance Transform
(a) Hand calculation: hand calculates the two-step algorithm in Image Representation as follows for
the city-block (4-connectivity) distance transform on the image data below Treat the pixels outside
the image boundary to be zeroes. Treat the value zeros in the image as the seeds. Show the two
outputs data after the first step and the second step.
(0)+1 if Pes
(b) Write programs: implement the two-step algorithm for the chessboard (8-connectivity) distance
transform Test on the same image data. Treat the pixels outside the image boundary to be zeroes.
Treat the value zeros in the image as the seeds. Show the program and two output data after the first
step and the second step by the program. Helpers: padarray
3.5 Global Thresh
(a) Hand calculation: Apply the Global thresholding method on the following image. What is the
best threshold value in this case?
Write programs: Global threshold. Use the image: coins png ( Normalize to [0,1]). Implement
the global threshold algorithm to determine the threshold value. what the value (answer with
digits)? Display two images in subplot: (1) The original image. (2) The binary image obtained with
the original image and the computed global threshold value.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
clear; clc; close all;
th=[0 pi/4 pi/2 3*pi/4];%Theta bins
r=linspace(0,max(img_width,img_height),nbin_r);%For r bins, the index i shows bin r(i-1)<d<=r(i) range