Keywords: Graphics, Image Processing, Color Science, RGB, Grayscale


Texture Formats

Texture formats



Converting RGB to grayscale/intensity

数字图像处理(18): 图像灰度变换——线性灰度变换 和 非线性灰度变换(对数变换 与 伽马变换)


Bicubic interpolation

Cubic Hermite spline



Q: How to compute grayscale in UE4 Materials?
A: The dot product of a RGB color and a coefficient is grayscale, this value can be used to computing falloff.

and you can get a new color with grayscale modified by appending these individual channels.

Panorama Stitching

Panorama Stitching using OpenCV Python

How To Make Panorama Images with Image Stitching in OpenCV Python

Image Panorama Stitching with OpenCV

How to create a panorama image using OpenCV with Python

Image Stitching with OpenCV and Python

OpenCV panorama stitching

Ordinary Tricks on OpenCV-Python

How do I access the pixels of an image using OpenCV-Python?
import cv2
image = cv2.imread("sample.jpg")
pixel= image[200, 550]
print pixel


[ 73 89 102]

pixel_b, pixel_g, pixel_r = image[row][column]


Add an alpha channel to a image

Python opencv adds an alpha channel to the image and sets the transparency:

import cv2
import numpy as np

img = cv2.imread("/home/shuai/Desktop/lena.jpg")

b_channel, g_channel, r_channel = cv2.split(img)

alpha_channel = np.ones(b_channel.shape, dtype=b_channel.dtype) * 255
#minimum is 0
alpha_channel[:, :int(b_channel.shape[0] / 2)] = 100

img_BGRA = cv2.merge((b_channel, g_channel, r_channel, alpha_channel))

cv2.imwrite("lena.png", img_BGRA)


Python with OpenCV3

# First create the image with alpha channel
rgba = cv2.cvtColor(rgb_data, cv2.COLOR_RGB2RGBA)

# Then assign the mask to the last channel of the image
rgba[:, :, 3] = alpha_data


# First create the image with alpha channel
cv::cvtColor(rgb_data, rgba , cv::COLOR_RGB2RGBA);

# Split the image for access to alpha channel
cv::split(rgba, channels);

# Assign the mask to the last channel of the image
channels[3] = alpha_data;

# Finally concat channels for rgba image
cv::merge(channels, 4, rgba);


Get alpha channel of a image
dir_of_script =  pathlib.Path(__file__).parent.absolute()
full_path = os.path.join(dir_of_script, "heightmap.png")
image = cv2.imread(full_path, cv2.IMREAD_UNCHANGED)
#(400, 250) is just pixel postion for testing
pixel = image[400, 250]
# would print 4 channels


[  0   0   0 118]


Create transparent image in opencv python
import numpy as np
import cv2

img_height, img_width = 300, 300
n_channels = 4
transparent_img = np.zeros((img_height, img_width, n_channels), dtype=np.uint8)

# Save the image for visualization
cv2.imwrite("./transparent_img.png", transparent_img)


Then he made one last effort to search in his heart for the place where his affection had rotted away, and he could not find it. ― Gabriel Garcia Marquez, One Hundred Years of Solitude