dct

DCT coefficients changed after JPEG saved to ios photo library

久未见 提交于 2019-12-08 09:31:41
问题 There is a strange change when saving JPEG image to the iOS photo library. I don't know if I am doing something wrong. I'm using libjpeg-turbo to access JPEG images and then I modify DCT coefficients of the image. Modified image (just in DCT, nothing else) is saved in photo library. But after I open the saved image, DCT coefficients are not the same that I changed in the previous step. In detail, let me explain how I'm adding +1 to each DCT. I am using standard procedure from "example.c" of

In scipy why doesn't idct(dct(a)) equal to a?

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:54:21
问题 I am trying to implement JPEG compression using python. When I tried to apply the DCT, quantization, IDCT process for a tiff image, I found something strange for scipy.fftpack.dct/idct. Since there is only 1D dct/idct within scipy package, I was doing this for a 2D dct import numpy as np from scipy.fftpack import dct, idct def dct2(block): return dct(dct(block.T).T) def idct2(block): return idct(idct(block.T).T) I tested the 2D dct/idct using a simple 3x3 matrix. I was expecting to get a True

Decompression stops inbetween and output file filled with zeros(BLACK PIXELS)?

我是研究僧i 提交于 2019-12-05 02:56:57
问题 I am trying to apply DCT(discrete cosine transformation) compression on a bmp(bitmap) file. I have a c file which i am running in Turbo C++. This is not actually compressing but i was trying to implement the DCT and IDCT. The code is as follows: /* the image to be compressed is a bmp with 24 bpp and with name "college4.bmp" of dimensions 200*160 ie 25*20- 8*8 blocks o/p is college2.dat format: 8 bit signed integers starting rowwise from 0,0 to 8,8 the coefficients order is blue,green,red for

In scipy why doesn't idct(dct(a)) equal to a?

天涯浪子 提交于 2019-12-04 06:25:24
I am trying to implement JPEG compression using python. When I tried to apply the DCT, quantization, IDCT process for a tiff image, I found something strange for scipy.fftpack.dct/idct. Since there is only 1D dct/idct within scipy package, I was doing this for a 2D dct import numpy as np from scipy.fftpack import dct, idct def dct2(block): return dct(dct(block.T).T) def idct2(block): return idct(idct(block.T).T) I tested the 2D dct/idct using a simple 3x3 matrix. I was expecting to get a True matrix with this test case. a = np.random.randint(0,255,9).reshape(3,3) print a == idct2(dct2(a))

why DCT transform is preferred over other transforms in video/image compression

谁说胖子不能爱 提交于 2019-12-04 01:12:37
I went through how DCT (discrete cosine transform) is used in image and video compression standards. But why DCT only is preferred over other transforms like dft or dst? Because cos(0) is 1, the first (0th) coefficient of DCT-II is the mean of the values being transformed. This makes the first coefficient of each 8x8 block represent the average tone of its constituent pixels, which is obviously a good start. Subsequent coefficients add increasing levels of detail, starting with sweeping gradients and continuing into increasingly fiddly patterns, and it just so happens that the first few

DCT Compression - Block Size, Choosing Coefficients

冷暖自知 提交于 2019-12-03 16:48:11
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 is more "Compact". It should be more emphasized in a fast varying images (High Frequency). Let's say we

Problems with DCT and IDCT algorithm in java

て烟熏妆下的殇ゞ 提交于 2019-12-03 14:21:21
问题 Here I have my DCT algorithm class with "applyDCT" and "applyIDCT" methods. Technically after doing a forward DCT (discrete cosine transform) on a 2x2 table of random integers between 0 and 255, and then immediately doing a reverse DCT on these numbers, we should come back to the original integer numbers we had in the first place. In my case, this is not so. What am I doing wrong here? public class DCT { private static final int N = 2; private double[] c = new double[N]; public DCT() { this

Video Compression: What is discrete cosine transform?

天大地大妈咪最大 提交于 2019-12-03 12:22:01
问题 I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL: http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html Now I can transform an 8x8 section of a black and white image, such as: 0140 0124 0124 0132 0130 0139 0102 0088 0140 0123 0126 0132 0134 0134 0088 0117 0143 0126 0126 0133 0134 0138 0081 0082 0148 0126 0128 0136 0137 0134 0079

Problems with DCT and IDCT algorithm in java

两盒软妹~` 提交于 2019-12-03 04:33:27
Here I have my DCT algorithm class with "applyDCT" and "applyIDCT" methods. Technically after doing a forward DCT (discrete cosine transform) on a 2x2 table of random integers between 0 and 255, and then immediately doing a reverse DCT on these numbers, we should come back to the original integer numbers we had in the first place. In my case, this is not so. What am I doing wrong here? public class DCT { private static final int N = 2; private double[] c = new double[N]; public DCT() { this.initializeCoefficients(); } private void initializeCoefficients() { for (int i=1;i<N;i++) { c[i]=1; } c

Video Compression: What is discrete cosine transform?

安稳与你 提交于 2019-12-03 01:51:00
I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL: http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html Now I can transform an 8x8 section of a black and white image, such as: 0140 0124 0124 0132 0130 0139 0102 0088 0140 0123 0126 0132 0134 0134 0088 0117 0143 0126 0126 0133 0134 0138 0081 0082 0148 0126 0128 0136 0137 0134 0079 0130 0147 0128 0126 0137 0138 0145 0132 0144 0147 0131 0123 0138 0137 0140 0145 0137 0142 0135 0122