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

做网站实现图片自动压缩营销推广活动策划

做网站实现图片自动压缩,营销推广活动策划,网站开发一般用什么软件,小型求职招聘网站源码 php自定义设备函数 核函数:__global__修饰;在设备中执行;设备函数:__device__修饰;在设备中执行;只能被核函数或其他设备函数调用;主机函数:__host__修饰(可省略&#xff0…
自定义设备函数
  • 核函数:__global__修饰;在设备中执行;
  • 设备函数:__device__修饰;在设备中执行;只能被核函数或其他设备函数调用;
  • 主机函数:__host__修饰(可省略);在主机中执行;
#include <stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<math.h>
#include <malloc.h> 
#include <opencv2/opencv.hpp>#include <stdlib.h>#define BLOCK_SIZE 1void __device__ thread_gpu(unsigned char in, unsigned char* out, int thread)
{in > thread ? *out = 255 : *out = 0;	
}//图像卷积 GPU
__global__ void sobel_gpu(unsigned char* in, unsigned char* out, const int Height, const int Width)
{int x = blockDim.x * blockIdx.x + threadIdx.x;int y = blockDim.y + blockIdx.y + threadIdx.y;int index = y * Width + x;int Gx = 0;int Gy = 0;unsigned char x0, x1, x2, x3, x4, x5, x6, x7, x8;if (x>0 && x<(Width-1) && y>0 && y<(Height-1)){x0 = in[(y - 1)*Width + (x - 1)];x1 = in[(y - 1)*Width + (x)];x2 = in[(y - 1)*Width + (x + 1)];x3 = in[(y)*Width + (x - 1)];x5 = in[(y)*Width + (x + 1)];x6 = in[(y + 1)*Width + (x - 1)];x7 = in[(y + 1)*Width + (x)];x8 = in[(y + 1)*Width + (x + 1)];Gx = (x0 + 2 * x3 + x6) - (x2 + 2 * x5 + x8);Gy = (x0 + 2 * x1 + x2) - (x6 + 2 * x7 + x8);out[index] = (abs(Gx) + abs(Gy)) / 2;thread_gpu(out[index], &out[index], 80);}
}int main()
{cv::Mat src;src = cv::imread("photo16.jpg");cv::Mat grayImg,gaussImg;cv::cvtColor(src, grayImg, cv::COLOR_BGR2GRAY);cv::GaussianBlur(grayImg, gaussImg, cv::Size(3,3), 0, 0, cv::BORDER_DEFAULT);int height = src.rows;int width = src.cols;//输出图像cv::Mat dst_gpu(height, width, CV_8UC1, cv::Scalar(0));//GPU存储空间int memsize = height * width * sizeof(unsigned char);//输入 输出unsigned char* in_gpu;unsigned char* out_gpu;cudaMalloc((void**)&in_gpu, memsize);cudaMalloc((void**)&out_gpu, memsize);dim3 threadsPreBlock(BLOCK_SIZE, BLOCK_SIZE);dim3 blocksPreGrid((width + threadsPreBlock.x - 1)/threadsPreBlock.x, (height + threadsPreBlock.y - 1)/threadsPreBlock.y);cudaMemcpy(in_gpu, gaussImg.data, memsize, cudaMemcpyHostToDevice);sobel_gpu <<<blocksPreGrid, threadsPreBlock>>> (in_gpu, out_gpu, height, width);cudaMemcpy(dst_gpu.data, out_gpu, memsize, cudaMemcpyDeviceToHost);cv::imwrite("dst_gpu_save.png", dst_gpu);//cv::namedWindow("src", cv::WINDOW_NORMAL);cv::imshow("src", src);cv::imshow("dst_gpu", dst_gpu);cv::waitKey();cudaFree(in_gpu);cudaFree(out_gpu);return 0;
}

在这里插入图片描述
在这里插入图片描述

http://www.hotlads.com/news/2612.html

相关文章:

  • 12306网站架构关键词排名关键词快速排名
  • 银河盛世网站建设外链百科
  • 网站建设公司软jian湖南岚鸿互联网广告平台排名
  • 政府网站用的什么cms系统今日中央新闻
  • 贵阳网站建设设计seo计费系统开发
  • 广州平面设计河北百度seo关键词排名
  • 苏州工业园区建设局网站怎么搞自己的网站
  • 郑州做食用菌配送的网站东莞百度seo新网站快速排名
  • 网站主页设计收费百度推广一年大概需要多少钱
  • 邢台无忧网站建设公司免费域名注册网站
  • 阜蒙县建设学校官网网站网络推广渠道都有哪些
  • 哪个网站可以做图片网络广告投放渠道有哪些
  • 做彩票网站模板优质的seo快速排名优化
  • 做网站销售挣钱吗电商seo是什么
  • 什么网站可以做家教线上宣传渠道有哪些
  • 医院美容网站建设手机优化是什么意思
  • 网站建设公司招人2345网址导航智能主板
  • 卖东西的网站怎么建设中国十大企业培训公司
  • linux网站建设模板网址域名大全2345网址
  • 搭建网站服务器需要什么配置第一推广网
  • 织梦网站自动跳转手机网站微信朋友圈广告推广
  • vue做的网站文字不能复制长沙seo外包平台
  • 网站做自己的超链接百度快照推广是什么意思
  • 国外成人做视频网站百度百科官网登录
  • 制作网站对话框白城seo
  • 200平米火锅店装修费用九幺seo工具
  • 新华书店网站建设网站快速收录付费入口
  • 找人做辅助的网站网络广告一般是怎么收费
  • 周村有做网站广告的吗推广图片大全
  • 安县移动网站建设福建百度开户