资源简介
This program is meant to run a sobel filter using three different methods. Each sobel filter function runs in a different way than the others, one is a basic sobel filter running through just the cpu on a single thread, another runs through openmp to parallelize the single threaded cpu function, and the last one runs through a NVIDIA gpu to parallelize the function onto the many cores available on the gpu. The resulting output from the functions should be the same no matter which way it is ran, the only difference will be the time taken to process each method. In most cases, the CPU will run the slowest, then openmp, and finally the GPU method will run the fastest (due to having more cores to handle many small computations). The result will be an image showing an edge map produced by each method, the edge maps should all be the same.
代码片段和文件信息
/*************************************************************************************************
* File: imageLoader.cpp
* Date: 10/16/2017
*
* Description: This file is meant to be a file of load/write functions for the original program.
* The file includes both a useful typedef to shorten unsigned chars into bytes and a struct
* meant to make accessing image data easier.
*************************************************************************************************/
#include “lodepng.h“
#include
typedef unsigned char byte; // most useful typedef ever
/************************************************************************************************
* struct imgData(byte* uint uint)
* - a struct to contain all information about our image
***********************************************************************************************/
struct imgData {
imgData(byte* pix = nullptr unsigned int w = 0 unsigned int h = 0) : pixels(pix) width(w) height(h) {
};
byte* pixels;
unsigned int width;
unsigned int height;
};
/************************************************************************************************
* imgData loadImage(char*)
* - takes in a filename with a png extension and uses LodePNG to decode it the resulting data
* - is converted to grayscale and then a structure containing the pixel data image width and
* - height are returned out. Decoding currently uses a C style decoding that uses free and an
* - array might consider re-writing to use the newer decode using a C++ vector if I have time.
*
* Inputs: char* filename : the filename of the image to load
* Outputs: imgData : a structure returned containing the image data (pixels width height)
*
***********************************************************************************************/
imgData loadImage(char* filename) {
unsigned int width height;
byte* rgb;
unsigned error = lodepng_decode_file(&rgb &width &height filename LCT_RGBA 8);
if(error) {
printf(“LodePNG had an error during file processing. Exiting program.\n“);
printf(“Error code: %u: %s\n“ error lodepng_error_text(error));
exit(2);
}
byte* grayscale = new byte[width*height];
byte* img = rgb;
for(int i = 0; i < width*height; ++i) {
int r = *img++;
int g = *img++;
int b = *img++;
int a = *img++;
grayscale[i] = 0.3*r + 0.6*g + 0.1*b+0.5;
}
free(rgb);
return imgData(grayscale width height);
}
/************************************************************************************************
* void writeImage(char* std::string imgData)
* - This function takes a filename as a char array a string of text and a structure containing
* - the image‘s pixel info width and height. The function will take the original filename
* - remove the .png ending and append text before re-adding the .png extension then lodepng is
* - ca
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-10-18 15:44 CUDA-Sobel-Filter-master\
文件 50 2017-10-18 15:44 CUDA-Sobel-Filter-master\.gitignore
文件 469 2017-10-18 15:44 CUDA-Sobel-Filter-master\Makefile
文件 1206 2017-10-18 15:44 CUDA-Sobel-Filter-master\README.md
文件 13861916 2017-10-18 15:44 CUDA-Sobel-Filter-master\flags.png
文件 4037 2017-10-18 15:44 CUDA-Sobel-Filter-master\imageLoader.cpp
文件 220491 2017-10-18 15:44 CUDA-Sobel-Filter-master\lodepng.cpp
文件 82320 2017-10-18 15:44 CUDA-Sobel-Filter-master\lodepng.h
文件 12768 2017-10-18 15:44 CUDA-Sobel-Filter-master\sobelFilter.cu
- 上一篇:青岛理工大学 计算机竞赛 宣传
- 下一篇:中科院自动化所博士论文
相关资源
- hyperledger fabric 1.2.0版本.rar
- 算法 第4版(美)Robert Sedgewick(原版
- hyperledgerFabric-1.4的bin和config
- Statistical Signal Processing - Detection Esti
- Hyperledger Fabric区块链医疗系统毕业设
- Addison-Wesley - Algorithms in C Sedgewick
- Optimum Array Processing Part IV of Detection
-
li
nk IoT Edge介绍2019-01-07 - mmdetection测试权重文件--faster_rcnn_r50
- faster_rcnn_inception_v2_coco_2018_01_28.tar.g
- FB5M.name.txt
- AnomalyDetectionCVPR2018-master工程
- 算法第四版-扫描版-Robert Sedgewick
- 《HyperLedger Fabric开发实战-快速掌握区
-
CV ob
ject detection目标检测近几年论文 - saliency detection
- Microsoft Edge浏览器卸载工具
- energydetection.zip
- EDGE网络的容量规划研究
- HOG-LBP+detection 行人检测
- HOG-LBP-detection
- 多机部署Hyperledger Fabric+Composer(两台
- detection of diabetic retinopathy in retinal f
- 学习Hyperledger Fabric 实战联盟链 地址
- 区块链孔一学院视频+源码
- Hyperledger Fabric 超级账本视频教程
-
WumpusWorld 使用 Knowledgeba
se的AI 实现 - Hyperledger Fabric kafka配置
- 学习HyperledgerFabric实战联盟链.txt
- 颜色恒常性算法
评论
共有 条评论