Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

opencv convert black pixels to white

import cv2

img = cv2.imread("path/to/image")

th = 20 # defines the value below which a pixel is considered "black"
black_pixels = np.where(
    (img[:, :, 0] < th) & 
    (img[:, :, 1] < th) & 
    (img[:, :, 2]  th)
)

# set those pixels to white
img[black_pixels] = [255, 255, 255]
Comment

PREVIOUS NEXT
Code Example
Python :: python autocorrelation plot 
Python :: Handling categorical feature 
Python :: mode with group by in python 
Python :: how to redirect in django 
Python :: trim string python 
Python :: how to bold in colorama 
Python :: python sum of list axes 
Python :: remove specific character from object in pandas column using iloc 
Python :: gogle query python simple 
Python :: python run batch file 
Python :: how to replace a word in text file using python 
Python :: add to a list python 
Python :: checksum python 
Python :: how to make a python file that prints out a random element from a list 
Python :: Program to find GCD or HCF of two numbers python 
Python :: hash() python 
Python :: python verify if string is a float 
Python :: create new column with length of old column value python 
Python :: mse python 
Python :: python random array shuffle 
Python :: plus in python 
Python :: python split string after substring 
Python :: undefined in python 
Python :: python unresolved import vscode 
Python :: get basename without extension python 
Python :: how to empty a dictionary in python 
Python :: python finally keyword 
Python :: download image from url python requests 
Python :: doomsday fuel foobar 
Python :: python insert path 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =