Home | Trees | Indices | Help |
---|
|
1 # PyVision License 2 # 3 # Copyright (c) 2006-2008 Stephen O'Hara 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # 1. Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # 13 # 2. Redistributions in binary form must reproduce the above copyright 14 # notice, this list of conditions and the following disclaimer in the 15 # documentation and/or other materials provided with the distribution. 16 # 17 # 3. Neither name of copyright holders nor the names of its contributors 18 # may be used to endorse or promote products derived from this software 19 # without specific prior written permission. 20 # 21 # 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 26 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 34 ''' 35 Created on Oct 18, 2010 36 @author: Stephen O'Hara 37 ''' 38 import cv 39 import pyvision as pv 4042 ''' 43 void cv.Sobel(src, dst, xorder, yorder, apertureSize = 3) 44 @param im: Input image 45 @param xorder: The order of the x derivative (see cv.Sobel openCV docs) 46 @param yorder: The order of the y derivative (see cv.Sobel openCV docs) 47 @param aperture_size: How large a convolution window to use 48 @param sigma: Optional smoothing parameter to be applied prior to detecting edges 49 ''' 50 gray = im.asOpenCVBW() 51 edges = cv.CreateImage(cv.GetSize(gray), 8, 1) 52 53 if sigma!=None: 54 cv.Smooth(gray,gray,cv.CV_GAUSSIAN,int(sigma)*4+1,int(sigma)*4+1,sigma,sigma) 55 56 #sobel requires a destination image with larger bit depth... 57 #...so we have to convert it back to 8 bit for the pv Image... 58 dst32f = cv.CreateImage(cv.GetSize(gray),cv.IPL_DEPTH_32F,1) 59 60 cv.Sobel(gray, dst32f, xorder, yorder, aperture_size) 61 cv.Convert(dst32f, edges) 62 edges = pv.Image(edges) 63 64 return edges65
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Apr 21 14:32:01 2015 | http://epydoc.sourceforge.net |