FANDOM


Notes from 02/03/2016. This is about Masking and Adding images. Adding images together will lay one picture on top of the other and combine their colors, I believe. Blending will create a transparent layer of sorts. And Threshold will take an image and any color above or below will be turned either black or white (for a binary threshold anyways.)

#Addition and Masking images

import numpy
import cv2

#Addition
#Method 1
img1=cv2.imread('file1.jpg',0)
img2=cv2.imgread('file2.jpg',0)
imgAdd=cv2.add(img1,img2) #uses a saturated add, if two colors are added >255, 255 will be returned

#Method 2
imgAdd=img1+img2 #modulo add if sum>255= (remainder of the sum/255)


#Blending - transparent layer of sorts

#(img,weight of first, img2, weight of second (1-weight of first), const to add to each sum (normally 0)
imgAdd=cv2.addWeighted(img1,0.7,img2,0.3,0)


#Thresholding - black and white image.  Anything less than a certain value will be black and anything greater will be white
#input needs to be grayscale (wether by processing or default)

#5 different types (see slides on blackboard, slide 11)

imgT=cv2.threshold(img1, 100, 255, cv2.THRESH_BINARY) #file, threshold, max to color, type

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.