Background Segmentation and Edge Detection in Matlab
The week of March 3, 2019 I worked on background segmentation and edge detection in Matlab. Below is a copy of code, which almost entirely relies on Matlab examples[1], to segment the background from a gray scale image.
zoom on I = imread('coins.png'); imshow(I) title('Original Image') title('Original Image') mask = zeros(size(I)); mask(25:end-25,25:end-25) = 1; figure imshow(mask) title('Initial Contour Location') bw = activecontour(I,mask,300); figure imshow(bw) title('Segmented Image')
Here is a copy of code, which almost entirely relies on Matlab examples[3] to find the edges of a color image after turning it to a gray scale image. It utilizes the sobel and canny algorithms.
zoom on RGB = imread('solo1.jpg'); imshow(RGB) I = rgb2gray(RGB); figure imshow(I) BW1 = edge(I,'sobel'); BW2 = edge(I,'canny'); figure; imshowpair(BW1,BW2,'montage') title('Sobel Filter Canny Filter');
[1]https://www.mathworks.com/help/images/ref/activecontour.html
[2]https://www.mathworks.com/help/matlab/ref/zoom.html
[3]https://www.mathworks.com/help/matlab/ref/rgb2gray.html
[4]https://www.mathworks.com/discovery/edge-detection.html
Comments