MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / main

Function main

examples/image_processing/filters.cpp:199–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199int main(int argc, char **argv) {
200 try {
201 int device = argc > 1 ? atoi(argv[1]) : 0;
202 af::setDevice(device);
203 af::info();
204
205 array img =
206 loadImage(ASSETS_DIR "/examples/images/vegetable-woman.jpg", true);
207
208 array prew_mag, prew_dir;
209 array sob_mag, sob_dir;
210 array img1ch = colorSpace(img, AF_GRAY, AF_RGB);
211 prewitt(prew_mag, prew_dir, img1ch);
212 sobelFilter(sob_mag, sob_dir, img1ch);
213 array sprd = spread(img, 3, 3);
214 array hrl = hurl(img, 10, 1);
215 array pckng = pick(img, 40, 2);
216 array difog = DifferenceOfGaussian(img, 1, 2);
217 array bil = bilateral(hrl, 3.0f, 40.0f);
218 array mf = medianfilter(hrl, 5, 5);
219 array gb = gaussianblur(hrl, 3, 3, 0.8);
220 array emb = emboss(img, 45, 20, 10);
221
222 af::Window wnd("Image Filters Demo");
223 printf("Press ESC while the window is in focus to exit\n");
224 while (!wnd.close()) {
225 wnd.grid(2, 5);
226 wnd(0, 0).image(hrl / 255, "Hurl noise");
227 wnd(1, 0).image(gb / 255, "Gaussian blur");
228 wnd(0, 1).image(bil / 255, "Bilateral filter on hurl noise");
229 wnd(1, 1).image(mf / 255, "Median filter on hurl noise");
230 wnd(0, 2).image(prew_mag / 255, "Prewitt edge filter");
231 wnd(1, 2).image(sob_mag / 255, "Sobel edge filter");
232 wnd(0, 3).image(sprd / 255, "Spread filter");
233 wnd(1, 3).image(pckng / 255, "Pick filter");
234 wnd(0, 4).image(difog / 255,
235 "Difference of gaussians(3x3 and 5x5)");
236 wnd(1, 4).image(emb / 255, "Emboss effect");
237 wnd.show();
238 }
239
240 } catch (af::exception &e) {
241 fprintf(stderr, "%s\n", e.what());
242 throw;
243 }
244 return 0;
245}

Callers

nothing calls this directly

Calls 15

infoFunction · 0.85
loadImageFunction · 0.85
colorSpaceFunction · 0.85
spreadFunction · 0.85
hurlFunction · 0.85
pickFunction · 0.85
DifferenceOfGaussianFunction · 0.85
medianfilterFunction · 0.85
gaussianblurFunction · 0.85
embossFunction · 0.85
closeMethod · 0.80
gridMethod · 0.80

Tested by

no test coverage detected