Skip to content

Instantly share code, notes, and snippets.

View PeaceAndHiLight's full-sized avatar

PeaceAndHiLight

View GitHub Profile
@PeaceAndHiLight
PeaceAndHiLight / PixelInfo.py
Last active January 5, 2016 12:32
OpenCV and Numpy ImageRead
#coding: utf-8
import cv2
import numpy as np
# readImage
img = cv2.imread('beatles_forsale.jpg')
print type(img)
pixelValue = img[10, 20]
@PeaceAndHiLight
PeaceAndHiLight / Lenna.bmp
Last active August 12, 2017 01:31
Test Numpy Method
@PeaceAndHiLight
PeaceAndHiLight / ROI.py
Last active January 6, 2016 14:16
Python About ROI
#coding: utf-8
import cv2
import numpy as np
rows = 256
cols = 256
img = np.zeros((rows,cols,3), dtype=np.uint8)
@PeaceAndHiLight
PeaceAndHiLight / CopyJohn.py
Created January 6, 2016 14:39
Python Copy ROI
#coding: utf-8
import cv2
import numpy as np
# Read Image
img = cv2.imread('beatles_forsale.jpg')
# Copy John's Face
john = img[20:80, 40:100]
@PeaceAndHiLight
PeaceAndHiLight / flip.py
Created January 7, 2016 15:03
Flip Image
#coding: utf-8
import cv2
img = cv2.imread('beatles_forsale.jpg', cv2.IMREAD_COLOR)
xAxis = cv2.flip(img, 0)
yAxis = cv2.flip(img, 1)
xyAxis = cv2.flip(img, -1)
@PeaceAndHiLight
PeaceAndHiLight / resize_default.py
Last active January 9, 2016 11:58
Python OpenCV resize
#coding: utf-8
import cv2
import numpy as np
img = cv2.imread('sgt_512.jpg', cv2.IMREAD_COLOR)
orgHeight, orgWidth = img.shape[:2]
size = (orgHeight/2, orgWidth/2)
@PeaceAndHiLight
PeaceAndHiLight / resize_interpolation.py
Created January 9, 2016 12:42
Python OpenCV resize interpolation
#coding: utf-8
import cv2
import numpy as np
img = cv2.imread('input.jpg', cv2.IMREAD_COLOR)
orgHeight, orgWidth = img.shape[:2]
size = (orgHeight/2, orgWidth/2)
@PeaceAndHiLight
PeaceAndHiLight / addWeighted.py
Last active January 15, 2016 15:09
use addWeighted, create mixed image
#coding: utf-8
import cv2
import numpy as np
#サイズの同じ画像を2枚読み込んでおく
imgA = cv2.imread('A.jpg', 1)
imgB = cv2.imread('B.jpg', 1)
#画像の大きさと次元が同じあることを確認しておく
print imgA.shape
@PeaceAndHiLight
PeaceAndHiLight / addPngOnJpeg.py
Created January 24, 2016 10:56
Add png Image On Jpeg Image
#coding: utf-8
import cv2
import numpy as np
img = cv2.imread('B.jpg', cv2.IMREAD_COLOR)
logo = cv2.imread('logo2.png', cv2.IMREAD_UNCHANGED)
#Get Height And Width of Logo
logoHeight, logoWidth = logo.shape[:2]
import cv2
import numpy as np
gamma = 1.8
lookUpTable = np.zeros((256, 1), dtype = 'uint8')
for i in range(256):
lookUpTable[i][0] = 255 * pow(float(i) / 255, 1.0 / gamma)