Commit Graph

133 Commits

Author SHA1 Message Date
jst
016a61cd31 Optimize data-locality for a huge increase in processing speed.
This is a complete rewrite! The tight scaling loop needs data locality for optimal performance. The old version used lots of pointer redirections to access image data which was bad for data locality. By providing the complete loop for each image type, this problem is solved. Unfortunately this increases code duplication but the result should be worth it: I could measure a ~6x speed-up for certain test cases!
2014-07-19 13:19:31 +02:00
jst
bdfbbead13 Merge branch 'anisus-master'
Fixes #14, regression from 494d8de4e5
2014-06-18 19:05:59 +02:00
Accipiter Nisus
f3cac2f865 Fix to resize correctly when source image.Bounds().Min is not (0,0) 2014-06-16 13:53:36 +10:00
jst
8aee0d995b Update README.md to mention resize.Thumbnail. 2014-01-30 20:03:15 +01:00
jst
079ed2e48a Merge branch 'master' of https://github.com/matrixik/resize into matrixik-master 2014-01-30 19:40:14 +01:00
jst
a83cb40860 Remove some redundancies. 2014-01-28 19:53:26 +01:00
jst
446eea2f7b Remove LUT based filters.
Caching kernel weights makes using the LUT based approach obsolete. Now they seem to be even slower than their counterparts.
2014-01-28 18:54:57 +01:00
jst
9884534579 Cache kernel weights for each row.
For each row the convolution kernel is evaluated at fixed positions around "u". By calculating these values once for each row, a huge speedup is achieved.
2014-01-28 18:48:08 +01:00
jst
8f586c4f06 Add benchmarks to compare execution times.
Run "go test -bench LargeJpegThumb" to benchmark all functions at once.
2014-01-18 11:55:34 +01:00
jst
45368ad0cd Multiply instead of dividing 2014-01-17 23:14:37 +01:00
jst
314cea6612 Avoid temporaries to save some cycles. 2014-01-17 22:54:15 +01:00
jst
7c5018c82b Extract method "resizeSlice" to reduce duplicate code. 2014-01-17 19:05:30 +01:00
Dobrosław Żybort
b744503c5c Add: thumbnail helper function 2013-11-27 22:40:16 +01:00
jst
f8ec710330 Fix wrong calculation of second adjust parameter. 2013-11-23 18:38:06 +01:00
jst
d9287fbcb6 Use x,y as coordinates of the origin image. 2013-11-23 18:02:18 +01:00
jst
d1bef9bdb6 Refactoring 2013-11-18 20:19:56 +01:00
jst
494d8de4e5 Speedup calculation by exploiting the separability of the resizing filter.
Should be ~5x faster! More optimization will follow.

before:
> go test -bench .
PASS
Benchmark_BigResizeLanczos3-4	       1	2438137093 ns/op
Benchmark_BigResizeLanczos3Lut-4	       1	1157612362 ns/op
Benchmark_Reduction-4	       2	 743950618 ns/op

after:
> go test -bench .
PASS
Benchmark_BigResizeLanczos3-4	       5	 403685685 ns/op
Benchmark_BigResizeLanczos3Lut-4	      10	 225539497 ns/op
Benchmark_Reduction-4	      10	 207004759 ns/op
2013-11-18 19:54:31 +01:00
jst
4d25061069 Fixed yet another typo. 2013-07-08 21:06:48 +02:00
jst
252ccc84a2 Add benchmarks for Lanczos3Lut to compare it with Lanczos3 performance. 2013-07-08 20:55:46 +02:00
jst
098f882331 Fix a typo. 2013-07-08 20:55:20 +02:00
jst
b272d51eaa Update README.md 2013-07-08 20:54:24 +02:00
jst
a85ea9eaa8 Rename Lanczos functions using look-up tables to Lanczos2Lut, Lanczos3Lut and restore Lanczos2, Lanczos3 to give users the choice between higher speed or higher accuracy. 2013-07-08 20:48:20 +02:00
jst
9e5ed35b85 Move splineKernel function nearer to Lanczos definitions. 2013-07-08 20:40:36 +02:00
Geoff Adams
c1b8c4986e Use a lookup table to speed up the Lanczos kernel
Profiling the resize operation using Lanczos kernels showed that most of
the time was spent in the Sin function, which is called twice per
evaluation of the Lanczos kernel. Generating a lookup table and doing a
linear interpolation between table entries speeds up the resize by a
factor of 4.
2013-07-04 02:28:43 -07:00
jst
33204d8746 Update README.md 2013-04-11 20:37:15 +02:00
jst
c37f8f8470 gofmt 2013-04-09 21:59:02 +02:00
jst
62777ac833 Precalculate bicubic factors, save some cycles. 2013-04-09 21:31:31 +02:00
jst
6448fff2ee Generalize spline based filters
This also fixes a quality issue with Mitchell-Netravali: A factor was
missing in the calculation.
2013-04-04 22:32:33 +02:00
jst
5290c4773b Add Travis build status in README 2013-04-03 20:50:30 +02:00
jst
09f4012229 Add Travis integration 2013-04-03 20:42:17 +02:00
jst
da95f74904 go fmt 2013-03-10 11:55:50 +01:00
jst
852f4a47e7 Merge branch 'no-image-shift' of http://github.com/jsummers/nfnt.resize
Merge branch 'fix-canvas-size-issue'
2013-03-10 11:33:44 +01:00
jst
84039c403b Test for correct canvas size. 2013-03-10 10:58:08 +01:00
jst
b6fef854bc Merge branch 'improve-canvas-size' of http://github.com/jsummers/nfnt.resize into fix-canvas-size-issue 2013-03-10 10:46:06 +01:00
jst
82ab8b977c Make kernel the only dependency of convolution1d 2012-12-13 22:13:37 +01:00
jst
e512502b3c Use range for more idiomatic Go 2012-12-13 21:55:44 +01:00
jst
bf09bbe0a3 boolToUint: true -> 1 2012-12-11 20:35:47 +01:00
jst
a32116ce4a Add documentation 2012-12-11 20:35:02 +01:00
jst
0c69e0e0b7 Change order of fields in filterModel 2012-12-11 20:24:30 +01:00
jst
bf006ca38d Description added
Describe filterModel interface,
Extract bool-to-int method
2012-12-11 20:18:23 +01:00
jst
2d6edc049a Change ordering 2012-12-11 19:57:34 +01:00
jst
cfcbeb4bb2 Use replicated border in genericConverter 2012-12-10 21:26:34 +01:00
jst
dc1fcd1d24 gofmt 2012-12-10 19:52:41 +01:00
jst
f6fa51fe2f Merge branch 'master' of https://github.com/nfnt/resize 2012-12-10 19:33:12 +01:00
jst
378e366327 Replicate border instead of using a constant
Constant border could lead to wrong values alpha values with certain
configurations.
2012-12-10 19:27:21 +01:00
jst
dd1c157427 Include kernel boundary check
Filter kernels should yield Zero if they are evaluted outside their
intended size. Though filterModel.Interpolate doesn't do this by design,
it's better to include it anyways.
2012-12-10 18:56:53 +01:00
Jason Summers
cdbd68f34f Improve the way the new canvas size is calculated
If both dimensions are given, always use those dimensions, avoiding roundoff
error.

If only one dimension is given, slightly prefer rounding the other dimension
up, to rounding it down.
2012-11-27 20:49:01 -05:00
Jason Summers
3d9094eb9e Center the resized image on the canvas, instead of shifting it slightly 2012-11-27 20:38:19 -05:00
jst
1169a8bfc3 Include samples in README.md 2012-11-14 22:08:45 +01:00
jst
3e06045c3f Speed up computation: Try to avoid Image.At() as much as possible -> specialized color access for some image types 2012-09-21 20:02:25 +02:00