-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (43 loc) · 1.55 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <string>
#include <cstdlib>
#define STB_IMAGE_IMPLEMENTATION
#include "include/stb_image.h"
#include "kernels/imageTools.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "include/stb_image_write.h"
uchar4* loadImage(const char* filename,int* width, int *height) {
int channels;
unsigned char* img = stbi_load(filename,width,height,&channels,STBI_rgb_alpha);
if (img == NULL) {
std::cerr << "Error Loading Image: " << filename << std::endl;
exit(1);
}
size_t imgSize = (*width) * (*height);
uchar4* d_image = new uchar4[imgSize];
imageLoadWrapper(img,d_image,imgSize);
stbi_image_free(img);
return d_image;
}
int main(int, char**){
int width;
int height;
//test();
//std::cout << "test" << std::endl;
uchar4* img = loadImage("/home/paperspace/CudaImageProcessing/image/lord.jpeg",&width,&height);
std::cout << "load image" << std::endl;
cudaDeviceProp deviceProp;
int device;
//imageGrayScaleWrapper(img,img,width,height);
//imageSobelEdgeWrapper(img,img,width,height);
//imageWriteWrapper("/home/paperspace/CudaImageProcessing/image/output.jpg",img,width,height);
//imageGaussianBlurWrapper(img,img,width,height,3,7.0);
//imageMeanBlurWrapper(img,img,width,height);
imageFFTImageGenerate(img,img,width,height);
//compressImage(img,img,width,height);
imageWriteWrapper("/home/paperspace/CudaImageProcessing/image/output.jpg",img,width,height);
delete[] img;
return 0;
}