gray

水平竖直线及矩形方式提取结构

时光总嘲笑我的痴心妄想 提交于 2019-11-29 09:59:34
结构化膨胀:通过自定义提取兴趣的结构,在该结构覆盖下的最大值作为该取值。 结构化腐蚀: 通过自定义提取兴趣的结构,在该结构覆盖下的最小值作为该取值。 一、水平直线提取 代码如下: #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; int main(int argc, char** argv) { Mat src, dst; src = imread("L:/opencv_picture/14.png"); if (!src.data) { printf("could not load image...\n"); return -1; } char INPUT_WIN[] = "input image"; char OUTPUT_WIN[] = "result image"; namedWindow(INPUT_WIN, CV_WINDOW_AUTOSIZE); imshow(INPUT_WIN, src); Mat gray_src; cvtColor(src, gray_src, CV_BGR2GRAY); imshow("gray image", gray_src); Mat binImg; adaptiveThreshold(~gray_src, binImg, 255,

cmakelists.txt的多行注释

偶尔善良 提交于 2019-11-29 08:23:48
CMake>=3.0 的时候支持多行注释,以 #[[ 开始进行块注释,并且在块注释的一端与 ]] 结束。 #[[ cuda_add_executable(combine_gray combine_gray.cu) cuda_add_executable(combine_rgb combine_rgb.cu) cuda_add_executable(gray gray.cu) cuda_add_executable(struct_test struct_pointer.cu) cuda_add_executable(struct_array struct_array.cu) ]] cuda_add_executable(multi_stream_gray multi_stream_gray.cu) #[[ target_link_libraries(combine_gray ${OpenCV_LIBS}) target_link_libraries(combine_rgb ${OpenCV_LIBS}) target_link_libraries(gray ${OpenCV_LIBS}) ]] 来源: https://blog.csdn.net/xiangxianghehe/article/details/100670863

图像颜色反转

那年仲夏 提交于 2019-11-29 04:44:36
反转原理:像素值 = 255-当前像素值 主要分为灰度图像反转和彩色图像反转 import cv2import numpy as npimg = cv2.imread('D:/pythonob/imageinpaint/img/zidan.jpg',1)gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)imgInfo = gray.shapeheight = imgInfo[0]width = imgInfo[1]revGray = np.zeros((height,width,1),np.uint8)#灰度图像颜色反转for i in range(0,height): for j in range(0,width): grayPixel = gray[i,j] revGray[i,j] = 255-grayPixelrevColor = np.zeros((height,width,3),np.uint8)#彩色图像颜色反转for i in range(0,height): for j in range(0,width): (b,g,r) = img[i,j] revColor[i,j] = (255-b,255-g,255-r)cv2.imshow('src',img)cv2.imshow('gray',gray)cv2.imshow(

图像灰度处理

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 04:26:26
这里采用四种方法对图像进行灰度处理: 方法一:读取图片时只读取灰度图像 方法二:调用opencv Api实现 方法三:算法实现图像灰度:gray = (B + G + R)/3 方法四:算法实现:gray = r*0.299 + g*0.587 + b*0.114 代码: import cv2import numpy as npgray1 = cv2.imread('D:/pythonob/imageinpaint/img/zidan.jpg',0)#方法一imgSrc = cv2.imread('D:/pythonob/imageinpaint/img/zidan.jpg',1)gray2 = cv2.cvtColor(imgSrc,cv2.COLOR_BGR2GRAY)#方法二:API实现图像灰度。第二个参数:转换方式BGR-->gray#方法三;算法实现图像灰度:gray = (B + G + R)/3imgInfo = imgSrc.shapeheight = imgInfo[0]width = imgInfo[1]gray3 = np.zeros((height,width,3),np.uint8)for i in range(0,height): for j in range(0,width): (b,g,r) = imgSrc[i,j] gray = (int(b)

使用OpenCL提升OpenCV图像处理性能 | speed up opencv image processing with OpenCL

为君一笑 提交于 2019-11-28 15:08:37
本文首发于个人博客 https://kezunlin.me/post/59afd8b3/ ,欢迎阅读最新内容! speed up opencv image processing with OpenCL <!--more--> Guide OpenCL is a framework for writing programs that execute on these heterogenous platforms. The developers of an OpenCL library utilize all OpenCL compatible devices (CPUs, GPUs, DSPs, FPGAs etc) they find on a computer / device and assign the right tasks to the right processor. Keep in mind that as a user of OpenCV library you are not developing any OpenCL library. In fact you are not even a user of the OpenCL library because all the details are hidden behind the transparent API

异步FIFO结构及FPGA设计 ---跨时钟域设计

心已入冬 提交于 2019-11-28 02:34:21
http://hi.baidu.com/hieda/blog/item/e8f8752465afb337c895593c.html 异步FIFO 结构及FPGA 设计 吴自信,张嗣忠. 单片机及嵌入式系统应用,2000 摘要 :首先介绍异步FIFO的概念、应用及其结构,然后分析实现异步FIFO的难点问题及其解决办法;在传统设计的基础上提出一种新颖的电路结构并对其进行综合仿真和FPGA实现。 1、异步FIFO介绍 在现代的集成电路芯片中,随着设计规模的不断扩大,一个系统中往往含有数个时钟。多时钟域带来的一个问题就是,如何设计异步时钟之间的接口电路。异步 FIFO(First In First Out)是解决这个问题一种简便、快捷的解决方案。使用异步FIFO可以在两个不同时钟系统之间快速而方便地传输实时数据。在网络接口、图像处理等方面, 异步FIFO得到了广泛的应用。 异步FIFO是一种先进先出的电路,使用在需要产时数据接口的部分,用来存储、缓冲在两个异步时钟之间的数据传输。在异步电路中,由于时钟之间周期和相位完全独立,因而数据的丢失概率不为零。如何设计一个高可靠性、高速的异步FIFO电路便成为一个难点。本文介绍解决这一问题的一种方法。 由图1可以看出:整个系统分为两个完全独立的时钟域——读时钟域和写时间域;FIFO的存储介质为一块双端口RAM,可以同时进行读写操作。在写时钟域部分

OpenCV学习笔记1

三世轮回 提交于 2019-11-28 01:03:25
OpenCV学习笔记1 引入 图片的显示读取写入 import cv2 image = cv2.imread("timg.jpg") #第二个参数可以选择色彩,例如灰色:cv2.IMREAD_GRAYSCALE # 显示图片 cv2.imshow("timg1",image) # 等待键盘输入,否则一闪而过 cv2.waitKey() # cv2.imwrite("名字",image) cv2.destroyAllWindows()# 关闭所有窗口 使用opencv进行图片svd压缩: import cv2 ​ image = cv2.imread("timg.jpg") # 降低图片尺寸 image = cv2.resize(image,(264,264)) image = image[:,:,[2,1,0]] # 使用SVD分解 image_gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) import numpy as np k = int(image_gray.shape[1]/4) u1,s1,v1 = np.linalg.svd(image_gray) image1 = image_gray.dot(v1[:k,:].T) import matplotlib.pyplot as plt fig,sns = plt

卷积神经网络的可视化(一)

空扰寡人 提交于 2019-11-27 14:04:40
卷积神经网络简单可视化 在本次练习中,我们将可视化卷积层 4 个过滤器的输出(即 feature maps)。 加载图像 import cv2 import matplotlib.pyplot as plt %matplotlib inline img_path = 'images/udacity_sdc.png' bgr_img = cv2.imread(img_path) gray_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2GRAY) gray_img = gray_img.astype("float32")/255 plt.imshow(gray_img, cmap='gray') plt.show() 定义并可视化过滤器(卷积核) import numpy as np filter_vals = np.array([[-1, -1, 1, 1], [-1, -1, 1, 1], [-1, -1, 1, 1], [-1, -1, 1, 1]]) print('Filter shape: ', filter_vals.shape) Filter shape: (4, 4) filter_1 = filter_vals filter_2 = -filter_1 filter_3 = filter_1.T filter_4 =

AttributeError: module 'cv2' has no attribute 'SIFT'

*爱你&永不变心* 提交于 2019-11-27 12:43:58
原因:opencv将SIFT等算法整合到xfeatures2d集合里面了。 将siftDetector=cv2.SIFT() 变更后为 siftDetector= cv2.xfeatures2d.SIFT_create() 即可正常使用SIFT算法。 import cv2 import numpy as np img = cv2 . imread ( 'C:/Users/www12/Desktop/Photo/test_1.jpg' ) gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) sift = cv2 . xfeatures2d . SIFT_create ( ) kp = sift . detect ( gray , None ) img = cv2 . drawKeypoints ( gray , kp , img ) cv2 . imshow ( 'img' , cv2 . resize ( img , ( 800 , 600 ) ) ) cv2 . waitKey ( 0 ) cv2 . destroyAllWindows ( ) 来源: CSDN 作者: HUN ysy 链接: https://blog.csdn.net/weixin_43772533/article/details/103242930

Qt widget使用QML自定义导航栏

一曲冷凌霜 提交于 2019-11-27 10:24:37
具体方法: https://www.cnblogs.com/judes/p/11359243.html qml: import QtQuick 2.0 import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick 2.7 Item { signal clickIndex(int index) Rectangle { id: tab_btn width: 80 height: parent.height color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#292929" } GradientStop { position: 1.0; color: "#828282" } } Column { id: colomn_btn anchors.fill: parent spacing: 0 Rectangle { id:btn_1 width: parent.width height: width color: "gray" Text { id: text