This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = cv2.imread('book_page_1_cropped.jpg', 0) | |
ret, th = cv2.threshold(image, | |
0, # threshold value, ignored when using cv2.THRESH_OTSU | |
255, # maximum value assigned to pixel values exceeding the threshold | |
cv2.THRESH_BINARY + cv2.THRESH_OTSU) # thresholding type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
gray = cv2.imread('book_page_1_cropped.jpg', 0) # open as grayscale | |
plt.hist(gray.ravel(), 256, [0,256]) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
image = cv2.imread('book_page_1_cropped.jpg') | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
ret, th = cv2.threshold(gray, | |
127, # threshold value | |
255, # maximum value assigned to pixel values exceeding the threshold | |
cv2.THRESH_BINARY) # threshold method type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = cv2.imread('input.jpg', 0) # read as grayscale | |
th = cv2.adaptiveThreshold(image, | |
255, # maximum value assigned to pixel values exceeding the threshold | |
cv2.ADAPTIVE_THRESH_GAUSSIAN_C, # gaussian weighted sum of neighborhood | |
cv2.THRESH_BINARY, # thresholding type | |
5, # block size (5x5 window) | |
3) # constant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import sys | |
animation = "|/-\\" | |
for i in range(100): | |
time.sleep(0.1) | |
sys.stdout.write("\r" + animation[i % len(animation)]) | |
sys.stdout.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get informations like channels, colorspace, etc. | |
identify -verbose file.png |

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adaboost = {} | |
Adaboost.__index = Adaboost | |
function Adaboost:create(training_set, ground_truth) | |
local adaboost = {} | |
setmetatable(adaboost,Adaboost) | |
adaboost.training_set = training_set | |
adaboost.ground_truth = ground_truth | |
adaboost.N = training_set:size()[1] | |
adaboost.weights = torch.ones(adaboost.N):div(adaboost.N) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cut video | |
ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4 | |
# convert to webm | |
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm | |
#concat | |
ffmpeg -f concat -safe 0 -i mylist.txt -c copy darmstadt.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec3 hsv2rgb(vec3 c) | |
{ | |
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | |
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); | |
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); | |
} |
NewerOlder