Edge Detection: Sobel operator
来源:互联网 发布:activiti java 代码 编辑:程序博客网 时间:2024/05/01 23:49
Excerpts from the Book: Python Programming in Context
http://en.wikipedia.org/wiki/Sobel_operator
In order to find an edge, it is necessary to evaluate each pixel in relation to those that appear around it. Since we are looking for places where intensity on one side of the pixel is greatly different from the intensity on the other ...
As a means of looking for these intensity differences, we use the idea of a kernel, also known as a filteror a mask. These kernels will be used to weight the intensities of the surrounding pixels ...Sobel operators, named after Irwin Sobel who developed them for use in edge detection. ...
The kernels will be used during convolution-- a process in which pixels in the original image will be mathematically combined with each mask. The result will then be used to decide whether that pixel represents an edge.
def convolve(anImage, pixelRow, pixelCol, kernel):kernelColumnBase = pixelCol - 1kernelRowBase = pixelRow - 1sum = 0for row in range(kernelRowBase, kernelRowBase+3):for col in range(kernelColumnBase, kernelColumnBase+3):kColIndex = col - kernelColumnBasekRowIndex = row - kernelRowBaseapixel = anImage.getPixel(col, row)intensity = apixel.getRed() # gray scale imagesum = sum + intensity * kernel[kRowIndex][kColIndex]return sumimport mathdef edgeDetect(theImage):grayImage = pixelMapper(theImage, grayPixel)newim = EmptyImage(grayImage.getWidth, grayImage.getHeight())black = Pixel(0, 0, 0)white = Pixel(255, 255, 255)xMask = [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]yMask = [[1, 0, -1], [2, 0, -2], [1, 0, -1]]for row in range(1, grayImage.getHeight()-1):for col in range(1, grayImage.getWidth()-1):gx = convolve(grayImage, row, col, xMask)gy = convolve(grayImage, row, col, yMask)g = math.sqrt(gx**2 + gy**2)if g > 175:newim.setPixel(col, row, black)else:newim.setPixel(col, row, white)return newim
- Edge Detection: Sobel operator
- Sobel edge detection
- Sobel Edge Detection 的shader实现
- Sobel operator
- sobel operator
- edge detection
- OpenCV边缘检测Edge Detection集合使用范例, 包含Sobel, Canny等
- Canny Edge Detection Tutorial
- POJ 1009 Edge Detection
- poj 1009 Edge Detection
- 1009 Edge Detection
- poj 1009 Edge Detection
- POJ 1009 Edge Detection
- POJ-1009-Edge Detection
- [POJ][1009]Edge Detection
- POJ 1008 Edge detection
- POJ 1009: Edge Detection
- POJ 1009 Edge Detection
- devexpress 延长试用期
- Sencha Touch 2 Global Variable
- 关于以太网帧中标签的解释
- 【设计模式】之十一Visitor
- vs2008快捷键
- Edge Detection: Sobel operator
- oracle备份操作
- 放弃吧,Hibernate 4直到4.3.0 Beta1还没有解决Proxool连接池不可用的问题
- java正则表达式除去html标签
- 为什么要用虚函数?什么时候用虚函数?
- HEVC-视觉感知基本感念
- Block使用
- MATLAB调用C/C++函数的方法
- apn(Access Point Name, 接入点名称)简介