Description
For this problem, handin Matlab .m files for the functions described by the headers below. Note that one of these is a driver which creates inputs for each function and runs the
function on those inputs to obtain the output.
Some notes:
• Indent headers correctly (5 spaces indented lines)
• Do not exceed 72 characters per source line
• CS4640 A6 driver: should show that each function works
None of the functions should write to the interpreter, draw, etc.
function D = CS4640_Hough_model(im)
% CS4640_Hough_model – create a Hough shape model
% On input:
% im (MxN array): binary image with shape
% On output:
% D (kx2 array): Hough model (offsets to anchor point)
% Call:
% S_model = CS4640_Hough_model(S_im);
% Author:
1
%
% UU
% Spring 2018
%
function [H,H2] = CS4640_Hough_detect(im,D)
% CS4640_Hough_detect – detect a Hough shape model
% On input:
% im (MxN array): binary image with shape
% D (kx2 array): Hough offset model
% On output:
% H (M1xN1 array): Hough accumulator array (note it is bigger
% than MxN
% since it has to allow for the largest offset
% H2 (MxN array): part of accumulator overlapping with original
% image
% Call:
% [H,H2] = CS4640_Hough_detect(im,D);
% Author:
%
% UU
% Spring 2018
%
function [lines_im,lines] = CS4640_lines(im,mag_thresh,ori_thresh)
% CS4640_lines – produce straight line setgments for image
% On input:
% im (MxN array): binary line image
% mag_thresh (float): edge magnitude threshold
% ori_thresh (float radians): max distance for similar
% orientations
% On output:
% lines_im (MxN array): image of lines (they are numbered)
% lines (kx3 array): line segments
% col 1: row value
% col 2: col value
% col 3: line index
% Call:
% [line_im,lines1] = CS4640_lines(im,1.5,0.96);
2
% Author:
%
% UU
% Spring 2018
%
function segs = CS4640_kmeans(im,k)
% CS4640_kmeans – segment image using kmeans
% im (MxNxP array): input image
% k (int): number of clusters
% On putput:
% segs (MxN array): segmented image
% Call:
% s = CS4640_kmeans(v1,4);
% Author:
%
% UU
% Spring 2018
%
function CS4640_A6_driver
% CS4640_A6_driver – driver for A6 functions
% On input:
% N/A
% On output:
% N/A
% Call:
% CS4640_A6_driver
% Author:
%
% UU
% Spring 2018
%
3