Read the color image SpeedSignjpg into a Matlab Matrix using
Solution
These are commands for the operations that asked in this question
1)A = imread(\'SpeedSign.jpg\');
2)a)BW1 = edge(A,\'Canny\');
To find corners
2)b)corners = detectHarrisFeatures(A);
To plot corners
plot(corners.selectStrongest(50));
2)c)greyscale
rgb2gray(A);
2)d)he = imread(\'SpeedSign.jpg \');
cform = makecform(\'srgb2lab\'); lab_he = applycform(he,cform);
ab = double(lab_he(:,:,2:3)); nrows = size(ab,1); ncols = size(ab,2); ab = reshape(ab,nrows*ncols,2); nColors = 3; % repeat the clustering 3 times to avoid local minima [cluster_idx, cluster_center] = kmeans(ab,nColors,\'distance\',\'sqEuclidean\', ... \'Replicates\',3);
pixel_labels = reshape(cluster_idx,nrows,ncols); imshow(pixel_labels,[]), title(\'image\') ;
segmented_images = cell(1,3); rgb_label = repmat(pixel_labels,[1 1 3]); for k = 1:nColors color = he; color(rgb_label ~= k) = 0; segmented_images{k} = color; end imshow(segmented_images{1}), title(\'objects in cluster 1\');
2)e) binary image
BW = im2bw(A,map,0.4);
2)f)BW = imread(\'SpeedSign.jpg \');
Filter image using this command
BW2 = bwareafilt(BW,[40 50]);
Display original image and filtered image side by side
imshowpair(BW,BW2,\'montage\')
