#include <stdio.h>
using namespace af;
}
static const float h_gauss[] = {
0.0318, 0.0375, 0.0397, 0.0375, 0.0318,
0.0375, 0.0443, 0.0469, 0.0443, 0.0375,
0.0397, 0.0469, 0.0495, 0.0469, 0.0397,
0.0375, 0.0443, 0.0469, 0.0443, 0.0375,
0.0318, 0.0375, 0.0397, 0.0375, 0.0318,
};
static const float h_sobel[] = {
-2.0, -1.0, 0.0,
-1.0, 0.0, 1.0,
0.0, 1.0, 2.0
};
static void img_test_demo(bool console)
{
array img_rgb =
loadimage(
"../common/images/sunset_emp.jpg",
true) / 255.f;
channel_split(img_rgb, rr, gg, bb);
channel_split(hsv, hh, ss, vv);
if (!console) {
fig(
"sub",4,2,1);
image(img_rgb);
fig(
"title",
"color image");
fig(
"sub",4,2,2);
image(bb);
fig(
"title",
"blue channel");
fig(
"sub",4,2,3);
image(ss);
fig(
"title",
"saturation");
fig(
"sub",4,2,6);
image(img_gray < 130);
fig(
"title",
"binary thresholding");
fig(
"sub",4,2,7);
image(inorm);
fig(
"title",
"hist eq");
}
}
int main(int argc, char** argv)
{
int device = argc > 1 ? atoi(argv[1]) : 0;
bool console = argc > 2 ? argv[2][0] == '-' : false;
try {
printf("** ArrayFire Image Demo **\n\n");
img_test_demo(console);
fprintf(stderr,
"%s\n", e.
what());
throw;
}
if (!console) {
printf("hit [enter]...");
getchar();
}
return 0;
}