| 14 | | print "sobelizing", |
| 15 | | sobel = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| 16 | | #sobel_x = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| 17 | | #sobel_y = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| 18 | | #cv.Sobel(im, sobel_x, 1, 0, 3) |
| 19 | | #cv.Sobel(im, sobel_y, 0, 1, 3) |
| 20 | | cv.Sobel(im, sobel, 1, 1, sobel_aperture) |
| | 14 | for sobel_aperture in (3, 5, 7): |
| | 15 | print "sobelizing", |
| | 16 | start = time.time() |
| | 17 | sobel = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| | 18 | #sobel_x = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| | 19 | #sobel_y = cv.CreateMat(im.height, im.width, cv.CV_32FC3) |
| | 20 | #cv.Sobel(im, sobel_x, 1, 0, 3) |
| | 21 | #cv.Sobel(im, sobel_y, 0, 1, 3) |
| | 22 | cv.Sobel(im, sobel, 1, 1, sobel_aperture) |
| | 23 | print "took %.2fs" % (time.time() - start) |
| 22 | | #cv.ShowImage('window', sobel) |
| 23 | | #cv.WaitKey() |
| 24 | | sobel_img = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 3) |
| 25 | | cv.ConvertScale(sobel, sobel_img, 8.0) |
| 26 | | sobel_h = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| 27 | | sobel_s = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| 28 | | sobel_v = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| 29 | | cv.Split(sobel_img, sobel_h, sobel_s, sobel_v, None) |
| 30 | | cv.SaveImage('%s-sobel-h-%s.png' % (fn, sobel_aperture), sobel_h) |
| 31 | | cv.SaveImage('%s-sobel-s-%s.png' % (fn, sobel_aperture), sobel_s) |
| 32 | | cv.SaveImage('%s-sobel-v-%s.png' % (fn, sobel_aperture), sobel_v) |
| 33 | | print "wrote %s-sobel-[hsv].png" % fn |
| | 25 | #cv.ShowImage('window', sobel) |
| | 26 | #cv.WaitKey() |
| | 27 | sobel_img = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 3) |
| | 28 | cv.ConvertScale(sobel, sobel_img, 8.0) |
| | 29 | sobel_h = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| | 30 | sobel_s = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| | 31 | sobel_v = cv.CreateImage((im.width, im.height), cv.IPL_DEPTH_8U, 1) |
| | 32 | cv.Split(sobel_img, sobel_h, sobel_s, sobel_v, None) |
| | 33 | cv.SaveImage('%s-sobel-h-%s.png' % (fn, sobel_aperture), sobel_h) |
| | 34 | cv.SaveImage('%s-sobel-s-%s.png' % (fn, sobel_aperture), sobel_s) |
| | 35 | cv.SaveImage('%s-sobel-v-%s.png' % (fn, sobel_aperture), sobel_v) |
| | 36 | print "wrote %s-sobel-[hsv]-%s.png" % (fn, sobel_aperture) |