Commit Graph

34 Commits

Author SHA1 Message Date
jst
ebea2e66be Support image.NRGBA, image.NRGBA16 in resize.Resize function. 2015-03-25 18:47:07 +01:00
jst
daa7cf45d3 Return NRGBA images.
Resizing images with alpha channels is easier for NRGBA, NRGBA64 image types.
Support for these is added by providing the necessary resize functions.
2015-03-25 18:38:23 +01:00
Charlie Vieth
076a9ce3b9 Limit spawned goroutines to GOMAXPROCS(0).
This change sets the number of spawned goroutines to the GOMAXPROCS
value set by the user.

Using more goroutines than available execution threads is slightly
detrimental to performance (~0.5%), and prevents users of the library
from controlling the number of spawned goroutines.
2015-03-15 17:59:38 -04:00
jst
9485f5475a Return input image if output dimensions equal input dimensions. 2014-12-17 11:10:53 +01:00
jst
581d15cb53 Fix parallel computation. 2014-08-20 21:12:39 +02:00
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
eefd4737aa Optimize YCbCr image resize 2014-07-30 02:08:58 -04: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
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
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
7c5018c82b Extract method "resizeSlice" to reduce duplicate code. 2014-01-17 19:05:30 +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
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
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
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
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
e96bbe5547 Unify filters and their dependencies 2012-09-15 20:24:14 +02:00
jst
eaf9383af0 filters.go simplified 2012-09-14 23:12:05 +02:00
jst
339b8fd43a Speed up calculation by avoiding dynamic casting 2012-09-01 00:21:10 +02:00
jst
294efa80bb Prevent resize from doing things multiple times if #CPUs > width 2012-08-23 19:36:02 +02:00
jst
9041d4db18 Function signature changed again, no need for multiple return value 2012-08-09 18:58:57 +02:00
jst
14d51db8b4 Changed function signature to include error handling. Filters simplified. 2012-08-08 21:32:51 +02:00
nfnt
f725c68998 fixed typo, thanks liuben 2012-08-06 21:49:02 +02:00
nfnt
2d612957ed fixed typo 2012-08-03 18:22:12 +02:00
nfnt
fdc4a64918 Tests added 2012-08-03 18:12:26 +02:00
nfnt
428642c9f1 initial commit 2012-08-02 21:59:40 +02:00