dct

How to perform a *Fast* DCT (Discrete Cosine Transform) in R?

ぐ巨炮叔叔 提交于 2020-01-31 03:50:51
问题 Using Rprof revealed the dct in the dtt package to be the main offender in a piece of R code that was running quite slowly. Swapping it out for fft in the stats package (which is not the same transformation, but should take the same time to compute) my run time improved dramatically. In fact 2/3 of my Rprof lines were dct calls previously and a mere 3 lines of about 600 were fft calls after making the switch. Is the dct implementation in the dtt package not done using the fast discrete

DCT based Video Encoding Process

南笙酒味 提交于 2020-01-06 07:56:12
问题 I am having some issues that I am hoping you will be able to clarify. I have self taught myself a video encoding process similar to Mpeg2. The process is as follows: Split an RGBA image into 4 separate channel data memory blocks. so an array of all R values, a separate array of G values etc. take the array and grab a block of 8x8 pixel data, to transform it using the Discrete Cosine Transform (DCT). Quantize this 8x8 block using a pre-calculated quantization matrix. Zigzag encode the output

DCT Compression - Block Size, Choosing Coefficients

北战南征 提交于 2019-12-21 05:25:09
问题 I'm trying to understand the effect of the Block Size and best strategy of choosing the Coefficients in DCT compression. Basically I want to ask what I wrote here: Video Compression: What is discrete cosine transform? Lets assume the most primitive compression. Making block of an image. Performing a DCT on each blog and zeroing out some coefficients. To my understanding, the smaller the block the better. Smaller blocks means the Pixels are more correlated hence the energy in the DCT spectrum

Discrete Cosine Transform DCT implementation C

我的未来我决定 提交于 2019-12-20 11:08:21
问题 Im trying to implement a forward and inverse Discrete Cosine Transform (DCT) in C. The code is to transorm a single input block of pixels to the transformation matrix via the dct() function and then back to the original pixel values via the idct() function. Please see the attached code. My output form the idct are consecutive values of 244, 116, 244, 116 etc. From the look of the idct values, it doesnt look like my program is working.. Could someone help me out and give me an idea of what

DCT using integer only

三世轮回 提交于 2019-12-13 21:21:49
问题 I need to implement DCT transform, but i can't use float or double types. There is a lot of implementations on the internet, but all of them use float. Does anyone know any source with DCT on integers? P.S I need it to implement Color Layout Descriptor. 回答1: I found a blog post that describes the integer based DCT and IDCT here and gives an implementation in Matlab. The code he used is on GitHub, available here. I used the method bink_dct_B2.m. This calculates a scaled 1D-DCT transform, so if

convert float to integer

安稳与你 提交于 2019-12-13 01:26:28
问题 how to scale and by which factor to scale dctmtx coefficients from float to get following integer values: float dctmtx: ( (0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536), (0.4904 0.4157 0.2778 0.0975 -0.0975 -0.2778 -0.4157 -0.4904), (0.4619 0.1913 -0.1913 -0.4619 -0.4619 -0.1913 0.1913 0.4619), (0.4157 -0.0975 -0.4904 -0.2778 0.2778 0.4904 0.0975 -0.4157), (0.3536 -0.3536 -0.3536 0.3536 0.3536 -0.3536 -0.3536 0.3536), (0.2778 -0.4904 0.0975 0.4157 -0.4157 -0.0975 0.4904 -0.2778),

Trying to implement The inverse of a dct 8*8 matrix

自古美人都是妖i 提交于 2019-12-11 18:16:36
问题 I have managed to calculate the dct of an 8*8 matrix and I am having trouble doing the inverse. Can anyone have a look at this code and tell me what I am doing now. I should be getting the exact same values as before but im getting different values. I am reading in the input from a csv file and out putting it to anther csv file. Its programmed in c void idct_func(float inMatrix[8][8]){ double idct, Cu, sum, Cv; int i, j, u, v; float idctMatrix[8][8], greyLevel; FILE * fp = fopen("mydata.csv",

What is the effect of storing a larger value in a grayscale png image?

懵懂的女人 提交于 2019-12-11 02:53:53
问题 I am trying to perform the DCT on an image with block size 8X8 in java. After performing DCT on the first block, I get the very first value as "372". After performing the DCT on the entire image, I wrote the values into a PNG-grayscale image.Values inside the image automatically changed. The grayscale image will not store the value greater than 255. What will happen to the value which is greater than 255 (for eg., 372) ? 回答1: you can not get to original image after loss of information so you

Scipy's fftpack dct and idct

北慕城南 提交于 2019-12-10 15:34:35
问题 Let say you use the dct function, then do no manipulation of the data and use the invert transform; wouldn't the inverted data be the same as the pre-transformed data? Why the floating point issue? Is it a reported issue or is it a normal behavior? In [21]: a = [1.2, 3.4, 5.1, 2.3, 4.5] In [22]: b = dct(a) In [23]: b Out[23]: array([ 33. , -4.98384545, -4.5 , -5.971707 , 4.5 ]) In [24]: c = idct(b) In [25]: c Out[25]: array([ 12., 34., 51., 23., 45.]) Anyone has an explanation as why? Of

FFTW fftwf_plan_r2r_2d() with FFTW_REDFT01 equivalent

别来无恙 提交于 2019-12-08 11:52:29
问题 I am trying to port code that uses FFTW to use KissFFT. The code uses fftwf_plan_r2r_2d() with FFTW_REDFT01. What would be the equivalent call in KissFFT? If this call (with FFTW_REDFT01 ) is equivalent to a DCT, could I just use a direct DCT transform instead, e.g. such as OpenCV cv::dct? Is there some input data modification I'd need to do, like reflections and symmetrizations? 回答1: Answering my own question... With the help of these two references, I ended up not using DFT at all, but