Commit Graph

34 Commits

Author SHA1 Message Date
jst e950449c49 Fix wrong boundary calculation (bug #17)
This fix doesn't currently work concurrently. This will be fixed in another commit.
2014-08-20 20:54:59 +02:00
Charlie Vieth 427b8d133e Optimized Nearest-Neighbor function - 2x faster 2014-07-29 18:32:58 -04:00
Charlie Vieth 80b3fc2b3f Pre-calculate start offset, optimize bound check
Increased performance by 30% for RGBA and 45% for Gray images, minor
performance increase for 16-bit images.

The start offset calculated by createWeights are stored in a slice and
passed to the resize functions to prevent duplication of effort.
2014-07-29 16:53:35 -04:00
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 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 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 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 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 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 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 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 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
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
jst e548f52385 Blur input image during downscaling by scaling the filter kernel to prevent moires in the output image 2012-09-19 21:03:56 +02:00
jst d0b2b9bc39 Added MitchellNetravali, changed Lanczos a bit 2012-09-19 19:32:00 +02:00
jst c980eecff5 Small simplification 2012-09-16 09:20:11 +02:00
jst e96bbe5547 Unify filters and their dependencies 2012-09-15 20:24:14 +02:00
jst 3fc31c95cc Kernel simplified 2012-09-15 19:30:32 +02:00
jst eaf9383af0 filters.go simplified 2012-09-14 23:12:05 +02:00
jst 524fd851ea Casting float to int has the same properties as math.Floor 2012-09-04 22:51:19 +02:00
jst d93161631c Use Kernel normalization for more accurate Lanczos resampling. Lanczos2 filter added 2012-09-04 18:49:04 +02:00
jst 339b8fd43a Speed up calculation by avoiding dynamic casting 2012-09-01 00:21:10 +02:00
jst 14d51db8b4 Changed function signature to include error handling. Filters simplified. 2012-08-08 21:32:51 +02:00
nfnt 428642c9f1 initial commit 2012-08-02 21:59:40 +02:00