GNOME Bugzilla – Bug 158127
improve scale, rotate, etc. using a sinc-based interpolation algorithm
Last modified: 2005-01-11 18:33:20 UTC
Currently, image scaling (and rotation AFAIK, etc.) offers three interpolation options: nearest, linear, cubic The most correct option, sinc, is missing. (this is a 1/sin(x) function) Note also that _all_ of these should be done in a linear-light (gamma==1.0) color space for correct output. The sRGB gamma curve, including the linear portion near black, should be used when conversion is needed.
Could you perhaps try to rephrase this as an enhancement request? It would sound less harsh and might increase the likelihood that it would be implemented one day.
I don't mean to sound harsh. By "most correct", I really mean it, in a math sense. Think FFT, waves, bandwidth, signals, Nyquist limit, etc. The differance will be clearly visible if you rotate a zone plate image (a type of test image) in 5-degree increments until you go around all 360 degrees. The comment about gamma is because it is a very common and serious error to ignore gamma. BTW, for some of these operations, I suspect that the most efficient implementation would involve operations done in frequency space. Take an FFT on each gamma==1.0 channel, do some stuff, and then use an inverse FFT to get back. This would be exactly equivalent to using the sinc() function. (sorry I can't better define "some stuff" for you)
Sorry, but I don't think such a bug report makes much sense. If you want to add a better interpolation function, please come up with a patch or at least an algorithm that can be integrated. I could point out several dozens of algorithms that are better than the one that GIMP offers at the moment. It would however not improve the situation at all if we had a bug report for each of these. As it stands this report is way too vague to be useful. The summary is misleading and lacks the term "interpolation" that would allow to find it when searching Bugzilla. The report itself doesn't include any useful information, not even a pointer to external resources. Unless you change that, I will have to close it as INCOMPLETE.
Oops, didn't meant to change the summary to become even less useful. That was an accident, changing it back and setting to NEEDINFO.
Heh, I just got told last night that I should report lots of separate bugs, and now you say that would be bad. Anyway, the third hit on Google for "sinc degree rotate" (no quotes) is: http://home.no.net/dmaurer/~dersch/interpolator/interpolator.html I note that the author of that page is already using sinc() for a GIMP plug-in. So, I expect that GIMP-friendly GPL code is available and would merely need to be integrated into the core app.
See, now this report starts to make sense. And of course you should file separate bug reports for separate issues. I certainly didn't say that would be bad.
Using sinc would probably give nice results, but it means convolving with a rather large matrix, which would be slow: the sinc-based interpolation described on Dersch's page uses a 16x16 convolution matrix. It would be interesting to investigate using an FFT for this -- but I don't know whether even a fast FFT implementation such as FFTW would be fast enough to be usable in GIMP. And it would require a lot of memory, too.
*** Bug 163674 has been marked as a duplicate of this bug. ***
Bug 163174 also has more links to imporved algorithms and discussions.
See also bug #162250 which has a patch that is almost ready for inclusion (and should end up being applied to CVS pretty soon).
Now that the patch from bug #162250 is in CVS, it's probably best to close this report as duplicate of the newer one. *** This bug has been marked as a duplicate of 162250 ***