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
# 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 |
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 | |
# 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 |
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
[{"name": "sample 1", "image": "url 1"}, {"name": "sample 2", "image": "url 2"}] |
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
# 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) |
OlderNewer