Changelog plus tidy of code/docs for convolve operation

This commit is contained in:
Lovell Fuller
2016-07-04 22:13:47 +01:00
parent 4c172d25f6
commit a5d85b8a54
6 changed files with 37 additions and 33 deletions

View File

@@ -215,8 +215,10 @@ namespace sharp {
/*
* Convolution with a kernel.
*/
VImage Convolve(VImage image, int width, int height, double scale, double offset,
const std::unique_ptr<double[]> &kernel_v) {
VImage Convolve(VImage image, int const width, int const height,
double const scale, double const offset,
std::unique_ptr<double[]> const &kernel_v
) {
VImage kernel = VImage::new_from_memory(
kernel_v.get(),
width * height * sizeof(double),

View File

@@ -38,8 +38,8 @@ namespace sharp {
/*
* Convolution with a kernel.
*/
VImage Convolve(VImage image, int width, int height, double scale, double offset,
const std::unique_ptr<double[]> &kernel_v);
VImage Convolve(VImage image, int const width, int const height,
double const scale, double const offset, std::unique_ptr<double[]> const &kernel_v);
/*
* Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.

View File

@@ -640,9 +640,10 @@ class PipelineWorker : public AsyncWorker {
// Convolve
if (shouldConv) {
image = Convolve(image,
baton->convKernelWidth, baton->convKernelHeight,
baton->convKernelScale, baton->convKernelOffset,
baton->convKernel);
baton->convKernelWidth, baton->convKernelHeight,
baton->convKernelScale, baton->convKernelOffset,
baton->convKernel
);
}
// Sharpen
@@ -1165,13 +1166,12 @@ NAN_METHOD(pipeline) {
// Convolution Kernel
if(Has(options, New("convKernel").ToLocalChecked()).FromJust()) {
Local<Object> kernel = Get(options, New("convKernel").ToLocalChecked()).ToLocalChecked().As<Object>();
baton->convKernelWidth = attrAs<int32_t>(kernel, "width");
baton->convKernelHeight = attrAs<int32_t>(kernel, "height");
baton->convKernelWidth = attrAs<uint32_t>(kernel, "width");
baton->convKernelHeight = attrAs<uint32_t>(kernel, "height");
baton->convKernelScale = attrAs<double>(kernel, "scale");
baton->convKernelOffset = attrAs<double>(kernel, "offset");
size_t kernelSize = baton->convKernelWidth * baton->convKernelHeight;
size_t const kernelSize = static_cast<size_t>(baton->convKernelWidth * baton->convKernelHeight);
baton->convKernel = std::unique_ptr<double[]>(new double[kernelSize]);
Local<Array> kdata = Get(kernel, New("kernel").ToLocalChecked()).ToLocalChecked().As<Array>();
for(unsigned int i = 0; i < kernelSize; i++) {