This homepage has file size limit. Then killed this file. This file is moved to Zuruyaumineko's homepage2's final place.
1.The digital picure zooming
We know the words that are resize,resample,scaling,interporation,resolution conversion,decimation and resampling. All of these words are keywords of picture size conversion.
1.1.Zooming on space area
We know the algorithm called Lanczos 3-lobed sinc filtered interporation and decimation. I show an explanation by the sampling theorem as follows. the following explanation is how to resize digital picture(included lanczos 3 resize).
Principle of resize
Following explanation is four fifth decimation.
The function type sin(x)/x is called sinc function. It is the symboll of Sampling theorem. When the parameter 'a' of function sin(ax)/ax becomes smaller and smaller,this function's filter characteristic is lower and lower frequency pass. digital picture decimation is to convolute sinc function to picture sample and subsample some pixels. When we decimate pictures,their high frequency components are lost. if we shrink picture to one pixel picture,it has only direct current component ie. average of all pixels of this picture. decimation is band limitting. Rational decimation is poly-phase finite impulse response filtering whose coefficients be changed step by step as above figure. Next figures are why poly phase FIR filter is needed for rational decimation.
How to get the the interpolated value of arbitrary position (Explanation of the sampling theorem)
1.2.Zooming on space frequency area
I show on next links C program source lists which is the even functional DFT resizer and DCT resizer.
if you want to resize bitmap digital picture with higher quality than lanczos 3-lobed sinc filter algorithm, please use it. They use the most nearest to ideal Low Pass Filter. We can select arbitrary integer horizontal size and integer vertical size. Even functional DFT resizer is later than DCT resizer on function end time. I show the reason why these resize algorithm is high quality on following figure.principle of resize 2
I made execute file on windows command prompt of BMP arbitrary size interpolator.
usage
DCT_UP_RESIZE2 -i nantyara.bmp -o kakudai(.bmp extension no need)-sizexminus (horizontal size difference between before and after. when 640->720, value 80)-sizexminusy (vertical size difference between before and after. when 400->480, value 80)
Example
When gazou.bmp with 320x180 changes to kakudai.bmp with 400x200 on C drive, as follow.
copy DCT_UP_RESIZE2.exe and gazou.bmp on c:\
C:\>DCT_UP_RESIZE2 -i gazou.bmp -o kakudai -sizexminus 80 -sizexminusy 20
kakudai.bmp will be generated on c:\
DCT_DOWN_RESIZE -i nantyara.bmp -o syukusyou(.bmp extension no need)-sizexminus (horizontal size difference between before and after.When 720->640,value 80)-sizexminusy (vertical size difference between before and after.When 480->400, value 80)
例
When gazou.bmp with 400x200 changes to syukusyou.bmp with 320x180 on C drive,as follow.
copy DCT_DOWN_RESIZE.exe and gazou.bmp on c:\
C:\>DCT_DOWN_RESIZE -i gazou.bmp -o syukusyou -sizexminus 80 -sizexminusy 20
syukusyou.bmp will be generated on c:\
Space area resize is close relation to Space frequency area resize.
You will find a difficulty on the space area resize.
The difficulty is that pixels for left half taps don't exist when we filter by FIR on left side end pixels.
How do we do ?
The answer is that we put a mirror on left side end pixel.
And we filter to the mirror image pixels.
So right side end pixels , top side end pixels and bottom side end pixels are done in the same way.
These way are essentially the same as DCT resize technique.
--The difference between DFT and DCT with same number of samples--
DCT has twice frequency resolving power than DFT with same number of samples.
So in the result of DCT, we get only data which is less than nyquist frequency.
We can twice frequency resolving power than normal DCT.
The way is that we arrange same N sample after N sample and DCT to the 2xN samples.
In the same way, 4xN ,8xN and etc.
So frequency sampling interval can be shorter than normal DCT.
About Quantize
Quantize from 24bit color to 3bit color.
Algorhithm
@Caliculate each R,G and B histgrams from R,G,B all pixel values.
They are from pixel value 0 to pixel value 255.
R is 256 kind,G is 256 kind and B is 256 kind.
ADifinit M half of all pixels number.
BDifinit H maximum pixel value of the picture.
CDifinit L minimum pixel value of the picture.
DDivide in two at M on each of R,G and B. and make 8 areas.
EcCaliculate the centers of gravity of each 8 areas