ArrayFire: image_processing/deconvolution.cpp (original) (raw)

#include <stdio.h>

#include

using namespace af;

const unsigned ITERATIONS = 96;

const float RELAXATION_FACTOR = 0.05f;

float mx = max(in.as(f32));

float mn = min(in.as(f32));

return (in - mn) / (mx - mn);

}

int main(int argc, char *argv[]) {

int device = argc > 1 ? atoi(argv[1]) : 0;

try {

printf("** ArrayFire Image Deconvolution Demo **\n");

af::Window myWindow("Image Deconvolution");

array in = loadImage(ASSETS_DIR "/examples/images/house.jpg", false);

array kernel = gaussianKernel(13, 13, 2.25, 2.25);

array blurred = convolve(in, kernel);

iterativeDeconv(blurred, kernel, ITERATIONS, RELAXATION_FACTOR,

iterativeDeconv(blurred, kernel, ITERATIONS, RELAXATION_FACTOR,

while (!myWindow.close()) {

myWindow.grid(2, 3);

myWindow(0, 0).image(normalize(in), "Input Image");

myWindow(1, 0).image(normalize(blurred), "Blurred Image");

myWindow(0, 1).image(normalize(tikhonov), "Tikhonov");

myWindow(1, 1).image(normalize(landweber), "Landweber");

myWindow(0, 2).image(normalize(richlucy), "Richardson-Lucy");

myWindow.show();

}

fprintf(stderr, "%s\n", e.what());

throw;

}

return 0;

}

Window object to render af::arrays.

A multi dimensional data container.

const array as(dtype type) const

Casts the array into another data type.

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

@ AF_ITERATIVE_DECONV_LANDWEBER

Landweber Deconvolution.

@ AF_ITERATIVE_DECONV_RICHARDSONLUCY

Richardson-Lucy Deconvolution.

@ AF_INVERSE_DECONV_TIKHONOV

Tikhonov Inverse deconvolution.

AFAPI void setDevice(const int device)

Sets the current device.