mirror of
https://github.com/zebrajr/opencv.git
synced 2026-01-15 12:15:17 +00:00
GSoC 2016 - Adding ALIASES for tutorial (#7041)
* GSoC 2016 - Adding toggle files to be used by tutorials. Add a toggle option for tutorials. * adds a button on the HTML tutorial pages to switch between blocks * the default option is for languages: one can write a block for C++ and another one for Python without re-writing the tutorial Add aliases to the doxyfile. * adding alises to make a link to previous and next tutorial. * adding alias to specify the toggle options in the tutorials index. * adding alias to add a youtube video directly from link. Add a sample tutorial (mat_mask_opertaions) using the developed aliases: * youtube alias * previous and next tutorial alias * buttons * languages info for tutorial table of content * code referances with snippets (and associated sample code files) * Removing the automatic ordering. Adding specific toggles for cpp, java and python. Move all the code to the footer / header and Doxyfile. Updating documentation.
This commit is contained in:
committed by
Maksim Shabunin
parent
36b5abf6b7
commit
fcddfa4f86
@@ -0,0 +1,57 @@
|
||||
import time
|
||||
import numpy as np
|
||||
import cv2
|
||||
## [basic_method]
|
||||
def sharpen(my_image):
|
||||
my_image = cv2.cvtColor(my_image, cv2.CV_8U)
|
||||
|
||||
height, width, n_channels = my_image.shape
|
||||
result = np.zeros(my_image.shape, my_image.dtype)
|
||||
|
||||
## [basic_method_loop]
|
||||
for j in range (1, height-1):
|
||||
for i in range (1, width-1):
|
||||
for k in range (0, n_channels):
|
||||
sum = 5 * my_image[j, i, k] - my_image[j + 1, i, k] - my_image[j - 1, i, k]\
|
||||
- my_image[j, i + 1, k] - my_image[j, i - 1, k];
|
||||
|
||||
if sum > 255:
|
||||
sum = 255
|
||||
if sum < 0:
|
||||
sum = 0
|
||||
|
||||
result[j, i, k] = sum
|
||||
## [basic_method_loop]
|
||||
|
||||
return result
|
||||
## [basic_method]
|
||||
|
||||
|
||||
I = cv2.imread("../data/lena.jpg")
|
||||
cv2.imshow('Input Image', I)
|
||||
|
||||
t = round(time.time())
|
||||
J = sharpen(I)
|
||||
t = (time.time() - t)/1000
|
||||
print "Hand written function times passed in seconds: %s" % t
|
||||
|
||||
cv2.imshow('Output Image', J)
|
||||
|
||||
t = time.time()
|
||||
## [kern]
|
||||
kernel = np.array([ [0,-1,0],
|
||||
[-1,5,-1],
|
||||
[0,-1,0] ],np.float32) # kernel should be floating point type
|
||||
## [kern]
|
||||
|
||||
## [filter2D]
|
||||
K = cv2.filter2D(I, -1, kernel) # ddepth = -1, means destination image has depth same as input image.
|
||||
## [filter2D]
|
||||
|
||||
t = (time.time() - t)/1000
|
||||
print "Built-in filter2D time passed in seconds: %s" % t
|
||||
|
||||
cv2.imshow('filter2D Output Image', K)
|
||||
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
@@ -0,0 +1,5 @@
|
||||
print('Not showing this text because it is outside the snippet')
|
||||
|
||||
## [hello_world]
|
||||
print('Hello world!')
|
||||
## [hello_world]
|
||||
Reference in New Issue
Block a user