Question

In Python:

Challenge 3 detect edge(im,method) Write a function that takes a gray-scale image and detects edges, with the option of horizontal, vertical or both. 200 400 600 800 1000 1200 1200 1400 1400 0 200 400 600 800 1000 200 400 600 800 1000

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import numpy as np
import argparse
import glob
import cv2

def detect_edge(im,method):

img = cv2.imread(im, cv2.IMREAD_GRAYSCALE)
rows, cols = img.shape

sobel_horizontal = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5)
sobel_vertical = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5)

cv2.imshow('Original', img)
if method = 'horizontal' :
cv2.imshow('Sobel horizontal', sobel_horizontal)
else:
cv2.imshow('Sobel vertical', sobel_vertical)
   
cv2.waitKey(0)

Add a comment
Know the answer?
Add Answer to:
In Python: detect_edge(im, method) Write a function that takes a gray-scale image and detects edges, with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT