# Demo entry 6677116

py

Submitted by anonymous on Dec 02, 2017 at 06:49
Language: Python. Code size: 5.9 kB.

```# -*- coding: utf-8 -*-
"""
Created on Wed Jul 12 15:29:04 2017

"""
import cv2
import numpy as np
import Queue

return img

def sobel_operator(img):
for i in range(1,len(img)-1):
for j in range(1,len(img[0])-1):
for j in range(0,len(img[0])):

def canny_operator(img):
for i in range(0,len(img)-1):
for j in range(0,len(img[0])-1):
for j in range(0,len(img[0])-1):

for i in range(1,len(img)-1):
for j in range(1,len(img[0])-1):
else:
else:
else:
dtemp1 = dtemp2 = 0
else:
else:
pass
else:

def deal(img,i,j):
def islegal(m,n,img):
if m>=0 and m<len(img) and n>=0 and n<len(img[0]):
return True
return False
q = Queue.Queue()
q.put((i,j))
while q.empty()==False:
m,n = q.get()
for k in range(m-1,m+2):
for l in range(n-1,n+2):
if islegal(k,l,img) and img[k][l]==1:
img[k][l]=255
q.put((k,l))
return img

img[i][j] = 255
img[i][j] = 1
else:
img[i][j] = 0
if img[i][j]==255:
img = deal(img,i,j)
return img

def canny(img):
Gause_img = cv2.GaussianBlur(img,(3,3),0)
result_img = getresult(canny_img,Gause_img,20,10)
return result_img

def main():