GithubHelp home page GithubHelp logo

Tile mode? about deblurring HOT 1 OPEN

cpuimage avatar cpuimage commented on June 16, 2024
Tile mode?

from deblurring.

Comments (1)

zvezdochiot avatar zvezdochiot commented on June 16, 2024

Hi @cpuimage .

Somehow I made a tiled version:

diff -Nard Deblurring Deblurringtail > Deblurringtail.patch
diff '--color=auto' -Nard Deblurring/CMakeLists.txt Deblurringtail/CMakeLists.txt
2c2
< project(Deblurring)
---
> project(Deblurringtail)
12c12
< add_executable(Deblurring
---
> add_executable(Deblurringtail
22c22
< target_link_libraries(Deblurring -lfftw3 -lfftw3f -lm)
\ No newline at end of file
---
> target_link_libraries(Deblurringtail -lfftw3 -lfftw3f -lm)
diff '--color=auto' -Nard Deblurring/main.cpp Deblurringtail/main.cpp
167a168,169
>     args::ValueFlag<int> tailSize(parser, "tailSize", "set the tail size", {"tail"}, -1);
>     args::ValueFlag<flt> smooth(parser, "smooth", "smooth part origin", {"smooth"}, flt(0));
170c172
<     args::Positional<std::string> out_kernel(parser, "out_kernel", "kernel output file", args::Options::Required);
---
>     //args::Positional<std::string> out_kernel(parser, "out_kernel", "kernel output file", args::Options::Required);
212c214,216
<     opts.out_kernel = args::get(out_kernel);
---
>     opts.tailSize = args::get(tailSize);
>     opts.smooth = args::get(smooth);
>     //opts.out_kernel = args::get(out_kernel);
238a243
>     printf("image size %dx%d\n", w, h);
247,252c252,266
<     // estimate the kernel (call Algorithm 1 of the paper)
<     img_t<flt> kernel;
<     estimateKernel(kernel, img, opts.kernelSize, opts);
< 
<     // save the estimated kernel
<     iio_write_image(opts.out_kernel, &kernel[0], kernel.w, kernel.h, kernel.d);
---
>     int tw, th, twc, thc;
>     if (opts.tailSize > 0)
>     {
>         tw = opts.tailSize;
>         th = opts.tailSize;
>         twc = (w + tw - 1) / tw;
>         thc = (h + th - 1) / th;
>     }
>     else
>     {
>         tw = w;
>         th = h;
>         twc = 1;
>         thc = 1;
>     }
254d267
<     // deconvolve the blurry image using the estimated kernel
256,260c269,329
<     img_t<flt> tapered;
<     img_t<flt> deconv;
<     pad_and_taper(tapered, img, kernel);
<     deconvBregman(deconv, tapered, kernel, 20, opts.finalDeconvolutionWeight);
<     unpad(result, deconv, kernel);
---
>     result.ensure_size(w, h, d);
>     printf("smooth %f\n", opts.smooth);
>     printf("tail size %dx%d\n", tw, th);
>     for (int j = 0; j < thc; j++)
>     {
>         int y0 = j * th;
>         int y1 = y0 + th;
>         y1 = (y1 < h) ? y1 : h;
>         int dy = y1 - y0;
>         for (int k = 0; k < twc; k++)
>         {
>             int x0 = k * tw;
>             int x1 = x0 + tw;
>             x1 = (x1 < w) ? x1 : w;
>             int dx = x1 - x0;
> 
>             img_t<flt> tail;
>             tail.ensure_size(dx, dy, d);
>             size_t ind, indt = 0;
>             printf("tail %d,%d (%dx%d)\n", j, k, dx, dy);
>             for (int y = y0; y < y1; y++)
>             {
>                 for (int x = x0; x < x1; x++)
>                 {
>                     for (int c = 0; c < d; c++)
>                     {
>                         ind = ((y * w) + x) * d + c;
>                         tail[indt] = img[ind];
>                         indt++;
>                     }
>                 }
>             }
>             // estimate the kernel (call Algorithm 1 of the paper)
>             img_t<flt> kernel;
>             estimateKernel(kernel, tail, opts.kernelSize, opts);
> 
>             // save the estimated kernel
>             //iio_write_image(opts.out_kernel, &kernel[0], kernel.w, kernel.h, kernel.d);
> 
>             // deconvolve the blurry image using the estimated kernel
>             img_t<flt> tailresult;
>             img_t<flt> tapered;
>             img_t<flt> deconv;
>             pad_and_taper(tapered, tail, kernel);
>             deconvBregman(deconv, tapered, kernel, 20, opts.finalDeconvolutionWeight);
>             unpad(tailresult, deconv, kernel);
>             indt = 0;
>             for (int y = y0; y < y1; y++)
>             {
>                 for (int x = x0; x < x1; x++)
>                 {
>                     for (int c = 0; c < d; c++)
>                     {
>                         ind = ((y * w) + x) * d + c;
>                         result[ind] = opts.smooth * tail[indt] + (1.0f - opts.smooth) * tailresult[indt];
>                         indt++;
>                     }
>                 }
>             }
>         }
>     }
diff '--color=auto' -Nard Deblurring/options.hpp Deblurringtail/options.hpp
11a12,13
>     int tailSize;
>     flt smooth;

But the kernel could no longer attach the output.

Deblurringtail.patch.gz
main.cpp.gz
options.hpp.gz

Deblurringtail.tar.gz
Deblurringtail-win32.zip

from deblurring.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.