Part A sobelXImage = conv2(double(myImage), Sx, ‘same’); sobelYImage = conv2(double(myImage), Sy, ‘same’); figure(‘Name’, ‘X gradient’); imshow(uint8(sobelXImage)); figure(‘Name’, ‘Y gradient’); imshow(uint8(sobelYImage)); E(u,v) = sqrt( (Dx(u,v))2 + (Dy(u,v))2 ) Part B threshold = 50; edgeDetectedImage = (uint8(edgeDetectedImage) > threshold) * 255; Requirements: I only need the MATLAB script for to complete the exercise. First thing we’re going to do is learn how to create a sample image that will be useful for this lab. We will do this by using the Matlab command ‘checkerboard’. To give you an idea on how this command works, from the matlab command prompt, type the following:
imshow(checkerboard(20)); imshow(checkerboard(20)); It should create the image shown below: (see fig1.png) The 20 in the command is the number of pixels that each box on the checkerboard will represent. Let’s create an image from this matrix that we can use later. In order to do that, we need to use the ‘imwrite’ command.
imwrite(checkerboard(20), ‘checkerboard.jpg’, ‘JPEG’); imwrite(checkerboard(20), ‘checkerboard.jpg’, ‘JPEG’); To verify the above worked correctly, let’s read in the newly made image and display it:
myImage = imread(‘checkerboard.jpg’);
imshow(myImage); myImage = imread(‘checkerboard.jpg’); imshow(myImage); Now that we have a nice image to use for our edge detection algorithm, let’s begin to implement it. First thing we want to do is create our x and y gradient filters:
Sx = [1 0 -1; 2 0 -2; 1 0 -1];
Sy = [1 2 1; 0 0 0; -1 -2 -1]; Sx = [1 0 -1; 2 0 -2; 1 0 -1]; Sy = [1 2 1; 0 0 0; -1 -2 -1]; Convolve each of the above filters with the checkerboard image. Before we are able to use the convolve function we must convert our image into a double. We do that by using the ‘double’ command and passing it image variable name, in this case ‘myImage’. Let’s go ahead and take a peek at what our images currently look like: Do the gradient images look like you expect them too? Why or why not? What is missing from the above question and how would you fix it? Now that we understand what the gradients are doing and are able to display them properly, let’s continue on with our edge detection. We now need to square each of the X and Y portions, and then take the square root of them to determine the magnitude of our gradients. Enter the appropriate matlab command for the above formula and display the image. You should see something like fig.png Each of the edges are shown in white. Download a sample image from the net. Repeat the above steps and display the original image, the X gradient, and the Y gradient on one form/figure (Note: Don’t forget to convert it to black and white first) . After we sum the squares and take the square root we have the magnitude of our edge strength. We may not want to look at every single edge detected. We can limit which edges we want to see by applying a threshold. We can do this by using the following matlab commands: Create 4 additional figures each with their own respective image on it (using threshold {50, 100, 150, 200} ). Make sure the titles of the figures reflect their contents. Turn in the final matlab script that you used to accomplish part B. It should display 5 figures First thing we’re going to do is learn how to create a sample image that will be useful for this lab. We will do this by using the Matlab command ‘checkerboard’.
To give you an idea on how this command works, from the matlab command prompt, type the following:
imshow(checkerboard(20));
It should create the image shown below: (see fig1.png)
The 20 in the command is the number of pixels that each box on the checkerboard will represent.
Let’s create an image from this matrix that we can use later. In order to do that, we need to use the ‘imwrite’ command.
imwrite(checkerboard(20), ‘checkerboard.jpg’, ‘JPEG’);
To verify the above worked correctly, let’s read in the newly made image and display it:
myImage = imread(‘checkerboard.jpg’);
imshow(myImage);
Now that we have a nice image to use for our edge detection algorithm, let’s begin to implement it. First thing we want to do is create our x and y gradient filters:
Sx = [1 0 -1; 2 0 -2; 1 0 -1];
Sy = [1 2 1; 0 0 0; -1 -2 -1];
Convolve each of the above filters with the checkerboard image. Before we are able to use the convolve function we must convert our image into a double. We do that by using the ‘double’ command and passing it image variable name, in this case ‘myImage’. imshow(checkerboard(20)); imwrite(checkerboard(20), ‘checkerboard.jpg’, ‘JPEG’); myImage = imread(‘checkerboard.jpg’);
imshow(myImage); Sx = [1 0 -1; 2 0 -2; 1 0 -1];
Sy = [1 2 1; 0 0 0; -1 -2 -1]; Let’s go ahead and take a peek at what our images currently look like: Do the gradient images look like you expect them too? Why or why not?
What is missing from the above question and how would you fix it?
Now that we understand what the gradients are doing and are able to display them properly, let’s continue on with our edge detection. We now need to square each of the X and Y portions, and then take the square root of them to determine the magnitude of our gradients. Enter the appropriate matlab command for the above formula and display the image. You should see something like fig.png
Each of the edges are shown in white. Download a sample image from the net. Repeat the above steps and display the original image, the X gradient, and the Y gradient on one form/figure (Note: Don’t forget to convert it to black and white first) .
After we sum the squares and take the square root we have the magnitude of our edge strength. We may not want to look at every single edge detected. We can limit which edges we want to see by applying a threshold. We can do this by using the following matlab commands: Create 4 additional figures each with their own respective image on it (using threshold {50, 100, 150, 200} ). Make sure the titles of the figures reflect their contents.
Turn in the final matlab script that you used to accomplish part B. It should display 5 figures
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more