1 #include <Base/Image/Image.hh>
2 #include <Base/Image/ImageIO.hh>
3 #include <OpenGLFramework/SpecializedBatches/GpuImageFilter.hh>
4 #include <OpenGLFramework/Base/glfException.hh>
5 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
10 #include "Base/Common/getopt_W32.h"
22 none, mean, median, gauss
26 cout <<
"Usage: biasGPUfilter [options] infile outfile" << endl;
27 cout <<
" Options: " << endl;
28 cout <<
"-r radius : size of the filter kernel: size = 2 * radius + 1" << endl;
29 cout <<
"-a : use mean filter" << endl;
30 cout <<
"-g : use gauss filter" << endl;
31 cout <<
"-b : use median filter" << endl;
32 cout <<
"-v : verbose" << endl;
33 cout <<
"-p : median: independent channel sort. Else sort will be done on grey values" << endl;
34 cout <<
"-t thresh : gauss: sigma-value" << endl;
37 int main(
int argc,
char *argv[]) {
39 filtertype UseFilter = none;
42 float threshold = -FLT_MAX;
47 c = getopt(argc, argv,
"r:abpt:vg:");
63 threshold = float(atof(optarg));
78 if (argc - optind < 2) {
79 cout <<
"==> To few arguments." << endl;
84 if (UseFilter == none) {
85 cout <<
"==> No filtertype specified." << endl;
93 cout <<
"Median filter ";
102 cout <<
"Mean filter";
105 cout <<
"Gauss filter";
110 cout <<
" size " << 2 * rad + 1 <<
"x" << 2 * rad + 1;
111 if (threshold > -FLT_MAX) cout <<
" threshold " << threshold;
112 cout <<
" : " << argv[optind] <<
" -> " << argv[optind + 1] << endl;
116 if (ImageIO::Load(argv[optind], inImage) < 0) exit(1);
139 BIASERR(
"Median is limited a half-window size of 15"<<endl);
143 BIASWARN(
"Median with rad > 5 will most likely not work on the GPU with this implementation"<<endl<<
" -> check the image for artefacts!");
151 if (threshold < 0.) {
157 cout <<
"==> No filtertype specified." << endl;
169 ImageIO::Save(argv[optind + 1], outImage);
basic image filter on the gpu
Exception class used for run-time errors in the OpenGLFramework.
virtual void Destroy()
Uninitializes the rendering context.
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
void FilterMean(ImageBase &in, ImageBase &out, enum ImageBase::EStorageType type, int rad, float threshold)
GLX pbuffer rendering context.
void FilterGauss(ImageBase &in, ImageBase &out, enum ImageBase::EStorageType type, int rad, float threshold)
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
void FilterMedian(ImageBase &in, ImageBase &out, enum ImageBase::EStorageType type, int rad, float threshold, bool planar)
enum EStorageType GetStorageType() const
This is the base class for images in BIAS.
Configuration for a rendering context.