Skip to content

Instantly share code, notes, and snippets.

View pravj's full-sized avatar
📖

Pravendra Singh pravj

📖
View GitHub Profile
# Reference: https://code.likeagirl.io/finding-dominant-colour-on-an-image-b4e075f98097
from sklearn.cluster import KMeans
# word block colors (color palette)
block_colors = []
# change dimension to (width x height, color-channels)
screen = screen.reshape((screen.shape[0] * screen.shape[1], 3))
# Collect 8 major colors in the image using KMeans clustering
import cv2
# grayscale version of the single color image
image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
# bilateral filter is effective when you want to
# keep the edges sharp while removing noise
image_gray = cv2.bilateralFilter(image_gray, 10, 50, 50)
# find contour in gray scale image after applying erosion and dilation
[{"name": "sample 1", "image": "url 1"}, {"name": "sample 2", "image": "url 2"}]
# Python 3 program to find the stem
# of given list of words
# function to find the stem (longest
# common substring) from the string array
def findstem(arr):
# Determine size of the array
n = len(arr)