| 86 | } |
| 87 | |
| 88 | int main(int argc, char **argv) { |
| 89 | try { |
| 90 | int device = argc > 1 ? atoi(argv[1]) : 0; |
| 91 | af::setDevice(device); |
| 92 | af::info(); |
| 93 | |
| 94 | array man = loadImage(ASSETS_DIR "/examples/images/man.jpg", true); |
| 95 | array fight = loadImage(ASSETS_DIR "/examples/images/fight.jpg", true); |
| 96 | array nature = |
| 97 | resize(loadImage(ASSETS_DIR "/examples/images/nature.jpg", true), |
| 98 | fight.dims(0), fight.dims(1)); |
| 99 | |
| 100 | array intensity = colorSpace(fight, AF_GRAY, AF_RGB); |
| 101 | array mask = clamp(intensity, 10.0f, 255.0f) > 0.0f; |
| 102 | array blend = alphaBlend(fight, nature, mask); |
| 103 | array highcon = changeContrast(man, 0.3); |
| 104 | array highbright = changeBrightness(man, 0.2); |
| 105 | array translated = translate(man, 100, 100, 200, 126); |
| 106 | array sharp = usm(man, 3, 1.2); |
| 107 | array zoom = digZoom(man, 28, 10, 192, 192); |
| 108 | array morph_mask = constant(1, 3, 3); |
| 109 | array bdry = boundary(man, morph_mask); |
| 110 | |
| 111 | af::Window wnd("Image Editing Operations"); |
| 112 | printf("Press ESC while the window is in focus to exit\n"); |
| 113 | while (!wnd.close()) { |
| 114 | wnd.grid(2, 5); |
| 115 | wnd(0, 0).image(man / 255, "Input"); |
| 116 | wnd(1, 0).image(highcon / 255, "High Contrast"); |
| 117 | wnd(0, 1).image(highbright / 255, "High Brightness"); |
| 118 | wnd(1, 1).image(translated / 255, "Translation"); |
| 119 | wnd(0, 2).image(sharp / 255, "Unsharp Masking"); |
| 120 | wnd(1, 2).image(zoom / 255, "Digital Zoom"); |
| 121 | wnd(0, 3).image(nature / 255, "Background for blend"); |
| 122 | wnd(1, 3).image(fight / 255, "Foreground for blend"); |
| 123 | wnd(0, 4).image(blend / 255, "Alpha blend"); |
| 124 | wnd(1, 4).image(bdry / 255, "Boundary extraction"); |
| 125 | wnd.show(); |
| 126 | } |
| 127 | } catch (af::exception &e) { |
| 128 | fprintf(stderr, "%s\n", e.what()); |
| 129 | throw; |
| 130 | } |
| 131 | return 0; |
| 132 | } |
nothing calls this directly
no test coverage detected