Roberts Cross Edge Detection and Implementing in Matlab

Görkem
3 min readFeb 14, 2021

--

If you are reading this article I think it’s quite possible you’ve heard something about edge detection and Roberts Cross Operator. But if you are looking for a brief explanation about what is the math behind Roberts Operator and how to use it in Matlab, you are at the right place.

Edge detection is a process in order to find some regions where the image has boundaries. It measures the rate of change in brightness in an image. What we are doing here with edge detection algorithms is the process for find the amount of the difference between pixels in the matrix. Here we have a gray-level matrix.

As you can see some neighborhood pixels have strong signs of change in the matrix.

Using Roberts Operator we are going to be able to highlight changes in intensity.

How It Works

Roberts Cross Edge Detection is actually a convolution. Therefore in order to perform Roberts operator we are gonna convolve the original image with the kernels below firstly:

After we perform convolution gradient magnitude can be obtained. The gradient magnitude is given by:

It was a really brief explanation. If you want to it out in more details you can learn from wikipeadia.

How to Detect Edges with Roberts Operator in Matlab

Event though i didn’t use a built in function to perform Roberts Operator, usage is really simple.

im = imread('image.jpg');im_d = im2double(im);
im = rgb2gray(im_d);
hx = [+1 0; 0 -1];
hy = [0 +1; -1 0];
Gx = imfilter(im, hx);
imshow(Gy); figure;
Gy = imfilter(im, hy);
imshow(Gx); figure;
Gm = sqrt(Gx.^2 + Gy.^2);
imshow(Gm);

Here is the original image;

When we perform hx and hy masks over the image we get Gx and Gy like below;

After gradient magnitude is performed we get the result image which we have all the edges.

Thanks for reading.

--

--

Görkem
Görkem

No responses yet