python rgb 图像_在Python中查找RGB图像的互补图像
python rgb 圖像
Complementary image is a transformed image such that it consists of complementary colours of the ones, which is present in the original image.
互補(bǔ)圖像是一種變換后的圖像 ,它由原始圖像中存在的互補(bǔ)色組成。
For finding the complement of an image, we have to simply subtract each pixel value from the maximum pixel value supported by the class. (in this case, class - uint8, the maximum value of pixel can be 255) and store in the output image array. In the output image, dark areas become lighter and light areas become darker.
為了找到圖像的補(bǔ)碼 ,我們必須簡(jiǎn)單地從類支持的最大像素值中減去每個(gè)像素值。 (在這種情況下,類為uint8,pixel的最大值可以為255 )并存儲(chǔ)在輸出圖像數(shù)組中。 在輸出圖像中,黑暗區(qū)域變亮,明亮區(qū)域變暗。
Complementary image = 255 – original image.
補(bǔ)充圖像= 255-原始圖像 。
In this program, we will be using two functions of OpenCV-python (cv2) module. let's see their syntax and descriptions first :
在此程序中,我們將使用OpenCV-python(cv2)模塊的兩個(gè)功能。 我們先來看一下它們的語法和描述:
1) imread():
It takes an absolute path/relative path of your image file as an argument and returns its corresponding image matrix.
1)imread():
它以圖像文件的絕對(duì)路徑/相對(duì)路徑作為參數(shù),并返回其對(duì)應(yīng)的圖像矩陣。
2) imshow():
It takes window name and image matrix as an argument in order to display an image in a display window with a specified window name.
2)imshow():
它以窗口名稱和圖像矩陣為參數(shù),以便在具有指定窗口名稱的顯示窗口中顯示圖像。
Python程序查找RGB圖像的互補(bǔ)圖像 (Python program to find complementary image of the RGB image)
# open-cv library is installed as cv2 in python # import cv2 library into this program import cv2# read an image using imread() function of cv2 # we have to pass only the path of the image img = cv2.imread(r'C:/Users/user/Desktop/pic1.jpg')# displaying the image using imshow() function of cv2 # In this : 1st argument is name of the frame # 2nd argument is the image matrix cv2.imshow('original image',img)# Find complements of img array and # store it in the variable comp_image = 255 - img# Show the image formed cv2.imshow("Complementary image",comp_image);Output
輸出量
翻譯自: https://www.includehelp.com/python/find-complementary-image-of-the-rgb-image.aspx
python rgb 圖像
總結(jié)
以上是生活随笔為你收集整理的python rgb 图像_在Python中查找RGB图像的互补图像的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “漠漠蚕弄丝”下一句是什么
- 下一篇: 一套护肤品多少钱啊?