Skip to content

Instantly share code, notes, and snippets.

import random
import colorsys
import matplotlib.pyplot as plt
def create_image(w, h, color):
image = np.zeros((w, h, 3), np.uint8)
# Fill image with red color(set each pixel to red)
image[:] = color
return image
@ntdat017
ntdat017 / drive_download.sh
Created January 11, 2022 06:33
script to google drive downloading
#!/usr/bin/env bash
drive_download() {
if [[ -f "$3/$2" ]]; then
echo "$2 already existed"
return
fi
echo "$2 not found, downloading..."
mkdir -p "$3"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=$1" > /dev/null
@ntdat017
ntdat017 / histogram_matching.py
Created January 9, 2020 04:05
transform image with same histogram
import numpy as np
def hist_matching(src_img, dst_img):
shape = src_img.shape
src = src_img.ravel()
dst = dst_img.ravel()
s_values, bin_idx, s_counts = np.unique(src, return_inverse=True, return_counts=True)
d_values, d_counts = np.unique(dst, return_counts=True)
@ntdat017
ntdat017 / unicode_utils.py
Last active May 3, 2022 02:20
Function Tranform Unicode Compound to Unicode (UTF-8) of Vietnamese character. Read more about charset in vnese at http://vietunicode.sourceforge.net/charset/vietcharset.html
import os
import io
def compound_unicode(unicode_str):
"""
Tranform Unicode Compound to Unicode (UTF-8).
Chuyển đổi chuỗi Unicode Tổ Hợp sang Unicode UTF-8.
Edited from: https://gist.github.com/anhtran/d317a2c52b015bb243fd262f1cad0e4f
"""
unicode_str = unicode_str.replace("e\xd2", "\u1EBB") # ẻ