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

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

[Octave-bug-tracker] [bug #60322] [octave forge] (image) imresize bicubi


From: Christof Kaufmann
Subject: [Octave-bug-tracker] [bug #60322] [octave forge] (image) imresize bicubic interpolation inaccurate
Date: Fri, 2 Apr 2021 10:27:51 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0

Follow-up Comment #1, bug #60322 (project octave):

So, imresize and interp2 in MATLAB use a convolution algorithm, see Wikipedia
<https://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm>,
with a = -0.5 and a symmetrical padding for the borders. In Octave imresize
uses imremap, which uses interp2 and this approximates the derivatives instead
of using the convolution algorithm, see Wikipedia
<https://en.wikipedia.org/wiki/Bicubic_interpolation#Finding_derivatives_from_function_values>.
So interp2 is not MATLAB compatible. imremap was implementing an own bicubic
interpolation using convolution in 2019, see this commit
<http://hg.code.sf.net/p/octave/image/file/d531a8379111/inst/imremap.m>, but
with a = -1 instead of a = -0.5.

Now, there are basically two options:
* Reintroduce the bicubic convolution algorithm in imremap, but with a = -0.5.
This would give MATLAB compatibility.
* Stick with interp2 and apply appropriate padding (only for scale > 1). Then
we could not test against a MATLAB reference and need a new test.

I don't know what is better. We might want to look at some interpolated images
and compare them. The differences are not only near the borders. However,
currently there are errors at the border because of a workaround to avoid
padding for bilinear interpolation. I made an example to compare the results
of both bicubic methods, see attachment bicubic_examples.m. bicubic_conv
yields the same results as MATLAB and bicubic_interp uses interp2 with
padding.

I read somewhere that MATLAB implements antialiasing by broadening the
interpolation convolution kernel. When thinking about implementing
antialiasing, it could be useful to have a convolutional implementation of the
cubic interpolation. Though there are certainly other ways of implementing
antialiasing.

So, what's your opinion?

(file #51178)
    _______________________________________________________

Additional Item Attachment:

File name: bicubic_examples.m             Size:3 KB
    <https://file.savannah.gnu.org/file/bicubic_examples.m?file_id=51178>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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