octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #61760] [octave forge] (image) imresize - anti


From: Christof Kaufmann
Subject: [Octave-bug-tracker] [bug #61760] [octave forge] (image) imresize - antialiasing is not implemented
Date: Wed, 12 Jan 2022 11:20:52 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0

Follow-up Comment #4, bug #61760 (project octave):

I finished implementing imresize based on convolution.

* I found out that "box" is the same as "nearest". I modified
private/interp_method accordingly.
* Anti-aliasing is implemented, like described here
<http://avisynth.nl/index.php/Lanczos_lobs/taps> and here
<https://blogs.mathworks.com/steve/2017/01/16/aliasing-and-image-resizing-part-3/>.
* Performance might have improved. The convolution is now implemented in a
more generic way. It requires less memory for bicubic interpolation. Compared
to imremap / interp2 I could verify for bilinear interpolation that the
convolutional approach is much faster.
* A Property-Value interface is now implemented.
* There are new tests for all the new features.
* Matlab compatibility has improved a lot. However, I did not do anything for
indexed colours or categorical images (except adding a note that there is
currently no support).
* Lanczos2 and Lanczos3 filters are now included.

I am quite happy with the results so far, but there is one big issue left: I
implemented Lanczos in the way it is described at Wikipedia
<https://en.wikipedia.org/wiki/Lanczos_resampling> and everywhere else. I
believe this gives quite good results, although the sum of coefficients may
not be 1 (see last paragraph in wikipedia/Limitations
<https://en.wikipedia.org/wiki/Lanczos_resampling>). For normalization the
coefficients of all shifts would have to be saved or at least added up, which
costs a bit of memory. I have not tried that and don't know if this is a big
issue, maybe not. The thing with the Lanczos implementation is, that it is
quite similar to what Matlab does, but does not give the same results. Matlab
precalculates the coefficients from the Lanczos kernels. Here
<https://de.mathworks.com/help/visionhdl/ug/image-downsize.html#d123e7665>
they say they use 6 taps and 32 phases. So they use an approximation, maybe
also optimized for hardware and I don't know which implementation is more
accurate. I can try to mimic their behaviour, but I don't know if it is worth
it. I left some outputs in the test for you, that show the mean absolute
difference and max absolute difference between my Lanczos implementation and
the Matlab reference images.

Maybe you can have a look on the imresize and tell me your opinion on Lanczos.
I would appreciate a fast response, because it is a lot of work for me to get
into interpolation again after a long time not looking into this.

(file #52651, file #52652)
    _______________________________________________________

Additional Item Attachment:

File name: interp_method.m                Size:1 KB
    <https://file.savannah.gnu.org/file/interp_method.m?file_id=52651>

File name: imresize.m                     Size:43 KB
    <https://file.savannah.gnu.org/file/imresize.m?file_id=52652>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61760>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]