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 | |
image = cv2.imread('combine.jpg') | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
mask = (gray == 0).astype('uint8') * 255 | |
blurred = cv2.GaussianBlur(mask, (15,15), 10) | |
result = cv2.inpaint(image, blurred, 3, cv2.INPAINT_TELEA) | |
cv2.imshow('result', result) | |
print('press any key to exit') |
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
#!/usr/bin/env python3 | |
from itertools import combinations_with_replacement | |
from typing import List, Tuple, Generator | |
VALID_E_SERIES = (3, 6, 12, 24, 48, 96, 192) | |
def E(m: int) -> Generator[float, None, None]: | |
""" A generator of IEEE E-series values. |
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 pathlib import Path | |
from scipy.io import wavfile | |
from scipy.fft import fft, fftfreq | |
import matplotlib.pyplot as plt | |
import numpy as np | |
path = Path('.') # path to whale song files | |
files = list(path.glob('*.wav')) |
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 scipy.spatial import KDTree | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# SETUP | |
points = np.array([[1,2],[5,9],[-8,-2],[5,-5],[-4,-1]]) | |
xmin, xmax, ymin, ymax = -10, 10, -10, 10 | |
x_resolution = y_resolution = 300 | |
pixel_size = max((xmax-xmin)/x_resolution, (ymax-ymin)/y_resolution) | |
radius = 3 |
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
#!/usr/bin/env python3 | |
from pymavlink import mavutil, mavlink | |
class CourseAverager: | |
MSG_TYPE = 'GLOBAL_POSITION_INT' | |
def __init__(self, mavlink_connection, request_rate=1, decay_rate=0.95, initial_course=(0, 0)): | |
self.master = mavlink_connection | |
self.request_message(request_rate) |
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
''' | |
Cleans up a drawing, and creates grey, blue, and red variants. | |
Blue and red are saved with a transparent background. | |
Grey is saved as single channel. | |
Author: ES-Alexander | |
License: MIT (a.k.a. free use, but not my problem if it doesn't work for you) | |
Created in response to: | |
https://www.reddit.com/r/opencv/comments/wmyuyh/question_remove_paper_background_from_sketches/ |
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
''' Written in response to u/thisisjusttofindajob's Reddit post | |
https://www.reddit.com/r/learnpython/comments/xnq9bv/how_to_render_objects_randomly_in_time/ | |
about random timings with an average frequency. | |
''' | |
from time import perf_counter | |
import random |
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
''' Mandelbulb.py | |
Adapted from | |
https://github.com/AstroKriel/Mandelbulb/blob/main/python/main.py | |
EXAMPLE OUTPUT: | |
https://youtube.com/shorts/f8ek83Z9SFo | |
Original author: AstroKriel | |
- Mandelbulb raymarcher |
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
# relevant types | |
from collections.abc import Sequence | |
from numbers import Real | |
import pathlib | |
# functionality | |
from itertools import chain, pairwise | |
import plotly.graph_objects as go | |
import numpy as np | |
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
#!/usr/bin/env python3 | |
def parse(file): | |
''' Generates encoded characters from file byte data. | |
Encoding is suitable for embedded [Graphics] in SubStation Alpha files. | |
See here for encoding specification and other details: | |
http://www.tcax.org/docs/ass-specs.htm | |
Bytes are split into groups of 6 bits, then 33 is added to each group |
OlderNewer