#include <stdio.h>
#include <cstdlib>
outr = rgb(span, span, 0);
outg = rgb(span, span, 1);
outb = rgb(span, span, 2);
}
static const float h_gauss[] = {
0.0318f, 0.0375f, 0.0397f, 0.0375f, 0.0318f, 0.0375f, 0.0443f,
0.0469f, 0.0443f, 0.0375f, 0.0397f, 0.0469f, 0.0495f, 0.0469f,
0.0397f, 0.0375f, 0.0443f, 0.0469f, 0.0443f, 0.0375f, 0.0318f,
0.0375f, 0.0397f, 0.0375f, 0.0318f,
};
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() {
array img_gray =
loadImage(ASSETS_DIR
"/examples/images/trees_ctm.jpg",
false);
loadImage(ASSETS_DIR
"/examples/images/sunset_emp.jpg",
true) /
255.f;
array rotatedImg =
rotate(img_gray, Pi / 2,
false) / 255.f;
array thrs_img = (img_gray < 130.f).as(
f32);
channel_split(img_rgb, rr, gg, bb);
channel_split(hsv, hh, ss, vv);
while (!wnd.close()) {
wnd.grid(2, 4);
wnd(0, 0).image(img_rgb, "Input Image");
wnd(1, 0).image(rotatedImg, "Rotate");
wnd(0, 1).image(ss, "Saturation");
wnd(1, 1).image(bb, "Blue Channel");
wnd(0, 2).image(smt, "Smoothing");
wnd(1, 2).image(thrs_img, "Binary Thresholding");
wnd(0, 3).image(inorm, "Histogram Equalization");
wnd(1, 3).image(edge_det, "Edge Detection");
wnd.show();
}
}
int main(int argc, char** argv) {
int device = argc > 1 ? atoi(argv[1]) : 0;
try {
printf("** ArrayFire Image Demo **\n\n");
img_test_demo();
fprintf(stderr,
"%s\n", e.
what());
throw;
}
return 0;
}
Window object to render af::arrays.
A multi dimensional data container.
An ArrayFire exception class.
virtual const char * what() const
Returns an error message for the exception in a string format.
@ f32
32-bit floating point values
AFAPI array abs(const array &in)
C++ Interface to calculate the absolute value.
AFAPI void setDevice(const int device)
Sets the current device.
AFAPI array colorSpace(const array &image, const CSpace to, const CSpace from)
C++ Interface wrapper for colorspace conversion.
AFAPI array histEqual(const array &in, const array &hist)
C++ Interface for histogram equalization.
AFAPI array histogram(const array &in, const unsigned nbins, const double minval, const double maxval)
C++ Interface for histogram.
AFAPI array loadImage(const char *filename, const bool is_color=false)
C++ Interface for loading an image.
AFAPI array convolve(const array &signal, const array &filter, const convMode mode=AF_CONV_DEFAULT, const convDomain domain=AF_CONV_AUTO)
C++ Interface for convolution any(one through three) dimensional signals.