Trial of New Interpolation Methods
Posted: 2012-05-27T00:06:30-07:00
I have added as a trial to the current SVN IMv6.7.7-3 some new 'pixel level' interpolation methods.
These are only in IMv6 at this time, and the names for the methods are not final..
Notes...
Remember these are interpolative methods, ment for special types of enlargement.
Should the size of the 'Nearest' be controlable rather than either 0.25 of the real pixel?
Here is the code used to generate the above (IMv6)
-----------------------------------
Oh One more interpolative method under trial. NearestBackground.
This uses the images 'background color' instead of the 'average' for between pixels. But you will only ever get a single pixel for the 'actual pixel'.
That is samples which are an 'exact match' (well within floating point error). As such you will only see 'exact matches' is you scale the image by an 'odd' size. That is 1,3,5,7,9 etc. That is for scale 9, the image is enlarged 9 times, And you get one real pixel, plus 8 background color rows and columns between them.
This may be very useful, or may not. Ideas, thoughts, comments?
On idea is for a 'control variable' the controls how close to the 'real pixel', should be regarded as 'near', from 'near zero' as in this case, to 0.25 for the previous 'Nearest' interpolations.
These are only in IMv6 at this time, and the names for the methods are not final..
- Average16 -- average of 16 pixels around sampling point
- Average9 -- 9 pixels around nearest pixel
- Average -- Average of 4 pixels around sampling point
- NearestAverage -- Select nearest pixel if close, else Average
- NearestBlend -- blend 1, 2 or 4 pixel neighbors
Notes...
- Before this 'Average' was equivelent to 'Average16' above. -- I always though it was as 'Average' above.
- Averaged methods are pixel level interpolative (box or linear) bluring methods.
- The 'Nearest' methods are variations on NearestNeighbor (or just 'Nearest')
- The center image 'NearestNeighbour' is equivelent to a 'scale' and shows the actual location of the pixel.
- Note that 'Average' Averages the area between pixels and as such the corners of the averaged area is located in 'center' of the pixel.
- Average9 does a Nearest Neighbour, and then averages it and its 8 neibhbours, to generate a average. A but like a radius 1 'flat' or averaging convolution of the source pixels.
- NearestAverage is equivelent to a 1/2 sized Nearest Neighbour, overlayed on 'Average'. The odd shaped colors are the averaged color.
- NearestBlend is the same but only averages the actual closest pixels. It is more like a 2-pass or tensor version
of the NearestAverage.
Remember these are interpolative methods, ment for special types of enlargement.
Should the size of the 'Nearest' be controlable rather than either 0.25 of the real pixel?
Here is the code used to generate the above (IMv6)
Code: Select all
pixel='' color=''
for i in Average16 Average9 Average \
NearestNeighbor NearestAverage NearestBlend ; do
pixel="$pixel i_pixel_$i.gif"
convert xc: -bordercolor black -border 2 \
-filter point -interpolate $i \
+distort SRT 32,0 -set comment $i i_pixel_$i.gif
color="$color i_color_$i.gif"
convert \( xc:red xc:blue +append \) \
\( xc:yellow xc:cyan +append \) -append \
-bordercolor black -border 1 \
-filter point -interpolate $i \
+distort SRT 40,0 -set comment $i i_color_$i.gif
done
montage -label %c $pixel $color \
-background silver -tile 6x -geometry +10+10 \
pixel_interpolations.png
rm i_*.gif
Oh One more interpolative method under trial. NearestBackground.
Code: Select all
convert \( xc:red xc:blue +append \) \
\( xc:yellow xc:cyan +append \) -append \
-bordercolor black -border 1 \
-filter point -interpolate NearestBackground \
+distort SRT 5,0 -scale 400% color_NearestBackground.gif
This uses the images 'background color' instead of the 'average' for between pixels. But you will only ever get a single pixel for the 'actual pixel'.
That is samples which are an 'exact match' (well within floating point error). As such you will only see 'exact matches' is you scale the image by an 'odd' size. That is 1,3,5,7,9 etc. That is for scale 9, the image is enlarged 9 times, And you get one real pixel, plus 8 background color rows and columns between them.
This may be very useful, or may not. Ideas, thoughts, comments?
On idea is for a 'control variable' the controls how close to the 'real pixel', should be regarded as 'near', from 'near zero' as in this case, to 0.25 for the previous 'Nearest' interpolations.