当前位置: 首页 > news >正文

什么网站的注册是动态shop后缀的网站

什么网站的注册是动态,shop后缀的网站,php做网站用什么软件好,网站互动⚠️主要是自己温习用,只保证代码正确性,不保证讲解的详细性。 今天继续总结cuda最基本的入门demo。很多教程会给你说conv怎么写,实际上sobel也是conv,并且conv本身已经用torch实现了。 之前在课题中尝试了sobel的变体&#xff0…

⚠️主要是自己温习用,只保证代码正确性,不保证讲解的详细性。

今天继续总结cuda最基本的入门demo。很多教程会给你说conv怎么写,实际上sobel也是conv,并且conv本身已经用torch实现了。

之前在课题中尝试了sobel的变体,为了起一个复习的作用,我把原始sobel(不是变体)的代码备份到这里,比起变体,这个原始的非常简单,很适合学习。

目录

      • 最简单的sobel
      • sobel其实还有其他变体

最简单的sobel

#include <opencv2/opencv.hpp>
#include <iostream>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>using namespace std;
using namespace cv;__global__ void sobel_gpu(unsigned char* in, unsigned char* out, const int Height, const int Width) {int x = blockDim.y * blockIdx.y + threadIdx.y;int y = blockDim.x * blockIdx.x + threadIdx.x;// 只对非边缘地带进行计算if (x > 0 && x < Height - 1 && y > 0 && y < Width - 1) {int idx = x * Width + y;int idx_up = idx - Width;int idx_down = idx + Width;char gx_res = in[idx_up - 1] + 2 * in[idx - 1] + in[idx_down - 1] - in[idx_up + 1] - 2 * in[idx + 1] - in[idx_down + 1];char gy_res = in[idx_up - 1] + 2 * in[idx_up] + in[idx_up + 1] - in[idx_down - 1] - 2 * in[idx_down] - in[idx_down + 1];out[idx] = (gx_res + gy_res) / 2;}else if (x == 0 || x == Height - 1 || y == 0 || y == Width - 1) {int idx = x * Width + y;out[idx] = in[idx];}
}int main() {Mat img = imread("lena.jpg", 0);int height = img.rows;int width = img.cols;int memsize = height * width * sizeof(unsigned char);Mat gaussImg;GaussianBlur(img, gaussImg, Size(3, 3), 0, 0, BORDER_DEFAULT);Mat dst_gpu(height, width, CV_8UC1, Scalar(0));unsigned char* in_gpu;unsigned char* out_gpu;// 接下来对模糊之后的图像进行处理cudaMalloc((void**)&in_gpu, memsize);cudaMalloc((void**)&out_gpu, memsize);dim3 threadsPerBlock(32, 32);dim3 blocksPerGrid((width + threadsPerBlock.x - 1) / threadsPerBlock.x, (height + threadsPerBlock.y - 1) / threadsPerBlock.y);cudaMemcpy(in_gpu, gaussImg.data, memsize, cudaMemcpyHostToDevice);sobel_gpu << < blocksPerGrid, threadsPerBlock > >> (in_gpu, out_gpu, height, width);cudaMemcpy(dst_gpu.data, out_gpu, memsize, cudaMemcpyDeviceToHost);imwrite("save.png", dst_gpu);cudaFree(in_gpu);cudaFree(out_gpu);return 0;
}

感兴趣的小伙伴可以自己去下载这个lena图,我就不提供了,一搜就有。

sobel其实还有其他变体

这个sobel有一些缺点:
在这里插入图片描述
直接看效果吧,这个效果如何不做评价,但是我的课题用这个肯定不是最优解…可以看到在边缘检测(或者直接叫它线条检测吧)上还有可提高的空间。所以现有文件还有什么可训练sobel、八方向sobel(这个我觉得还可以)。

你要是用到深度学习里面,我建议可以试试sobel的变体。

http://www.yayakq.cn/news/740420/

相关文章:

  • 第一环保网站建设项目环评公示网页设计课程期末总结
  • 深圳商城网站建设报价单上海突发新闻
  • 昆明网站建设是什么意思肖港网站开发
  • 关于建设网站与营销的好处seo推广怎么样
  • 做外贸有那些网站平台如何自己做电商
  • 无人机公司网站建设成品源码1988
  • 建设旅游信息网站的好处潍坊商城网站建设
  • 对网站建设这门课程的想法网站的维护及建设
  • 嵌入式软件开发工具有哪些seo专业为网站建设
  • 陕西省建设信息网站dede购物网站
  • 国内做心理咨询师培训出名的网站哪个网站可以做社工试题
  • 直接进网站的浏览器企业营销策划书
  • 响应式网站建设品牌全网天下漯河做网站zrgu
  • 网站建设协wordpress圆圈特效
  • 济南新网站优化商城网站seo
  • 周到的宁波网站建设网站建设微信托管
  • nas wordpress建站阿里巴巴网站官网
  • 专做水果的网站手工制作飞机模型
  • 什么网站做贸易好电影网站推广
  • 焦作网站建设公司中国建设银行官网站企业年金
  • 美容类网站模版万网空间上传网站
  • 公司网站建设注意事项设计网页页面
  • 金沙洲网站建设工作室做网站都需要买什么软件
  • 在阿里巴巴网站上怎么做贸易html5标准网站建设
  • 免费做网站的优缺点wordpress模板自媒体
  • 关于网站建设的博客微官网建设公司排行
  • 做电影类网站品牌策划咨询
  • 怎样制作网站教程哪家好淘宝关键词搜索量查询
  • 上海做企业网站的公司北京服饰电商网站建设
  • apache 创建网站网站建设文字资料