Search

# 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, 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 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');

https://www.mathworks.com/help/images/ref/activecontour.html

https://www.mathworks.com/help/matlab/ref/zoom.html

https://www.mathworks.com/help/matlab/ref/rgb2gray.html

https://www.mathworks.com/discovery/edge-detection.html

1 view

### Recent Posts

See All

#### Matlab Statistics and Machine Learning Toolbox Exploration

This past week I explored the statistics and machine learning toolbox in Matlab. I applied basic statistics concepts I am learning at AACC. For example, I wrote a program that performs linear regressi

#### Get a Grip & Sailbot Sensors

Last week I helped Fred with the prototype 6 Degree of Freedom arm. We Figured out how to connect the transmitter and power to the arm. Now we've been focusing on tuning the controls to have a wider r