Page 1 of 1

### Problem with Sobel

Posted: Sun Oct 21, 2018 9:39 pm
Hello.
I have a project with OpenMV M7.This project is used Sobel to get edge.I use morph to build Sobel.But I found this function takes up a lot of resources and can't get a good result.I found some function used Sobel.
Can you help me?Thank you.

### Re: Problem with Sobel

Posted: Sun Oct 21, 2018 9:44 pm
Hi, can you post your code? Note that general purpose convolutions take up a lot of CPU.

### Re: Problem with Sobel

Posted: Sun Oct 21, 2018 9:52 pm
# Untitled - By: bmi

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()

#sobel
kernel_size = 1
kernel_x = [-1, 0, +1,\
-2, 0, +2,\
-1, 0, +1]
kernel_y = [-1, -2, -1,\
0, 0, 0,\
+1, +2, +1]

while(True):
clock.tick()
img = sensor.snapshot()
tempy = img.bilateral(1)

sobel_x = img.morph(kernel_size, kernel_x)
sobel_y = tempy.morph(kernel_size, kernel_y)

print(clock.fps())

This is my code. I know this code have a problem.Sobel formula is G = |Gx| + |Gy|.But I didn't find absolute function.

### Re: Problem with Sobel

Posted: Sun Oct 21, 2018 10:08 pm
I see what you are trying to do... um, you can't really do this with the OpenMV Cam however. This is because you need an output buffer for each sobel method.

Um, what do you want to do with the sobel image? If you just need the magnitude then you can do: https://en.wikipedia.org/wiki/Kernel_(image_processing)

Our find_lines() method runs this kinda of thing internally all in C and collects the result. What is the end application?

### Re: Problem with Sobel

Posted: Sun Oct 21, 2018 10:55 pm
I want to use Sobel to find elliptical or circular fuzzy edges.

### Re: Problem with Sobel

Posted: Sun Oct 21, 2018 11:53 pm
Um, is find_circles() not enough? If so, then you have to do this in C. Or, alternatively, allocate two image buffers (see the sensor module for allocing a second buffer) and then copy the snapshot into the second buffer and sobel each with a different gradient. That said, you're not going to be able to process the images quick enough in python.

### Re: Problem with Sobel

Posted: Mon Oct 22, 2018 1:12 am
Thank you.I will try it.