Giter Club home page Giter Club logo

Comments (7)

denpo1022 avatar denpo1022 commented on September 4, 2024

Hi @yuan243212790 , actually they are not the same formula.

Here the DCT formula:
image

and the IDCT one:
image

If you replace C(i), C(j) above with C(u), C(v) then you can understand the code more easily.

from image-transform-dct-and-idct.

yuan243212790 avatar yuan243212790 commented on September 4, 2024

can you tell me what the differences?just exchange f(X,Y) and D(X,Y)

from image-transform-dct-and-idct.

denpo1022 avatar denpo1022 commented on September 4, 2024

@yuan243212790 Maybe explain with the code will be better:

One of the differences you should watch out is the position where calculating C(i) C(j) ( Cu Cv in the code).
For DCT, calculate C(i) C(j) right after the first nested for loop (means before double Σ in the formula).

for u in range(M):
for v in range(N):
# according from the formula of DCT
if u == 0:
Cu = 1 / np.sqrt(M)
else:
Cu = np.sqrt(2) / np.sqrt(M)
if v == 0:
Cv = 1 / np.sqrt(N)
else:
Cv = np.sqrt(2) / np.sqrt(N)

For IDCT, the calculation is located after second nested for loop (means after double Σ in the formula).
for x in range(M):
for y in range(N):
# calculate IDCT
tmp_sum = 0
for u in range(M):
for v in range(N):
# according from the formula of IDCT
if u == 0:
Cu = 1 / np.sqrt(M)
else:
Cu = np.sqrt(2) / np.sqrt(M)
if v == 0:
Cv = 1 / np.sqrt(N)
else:
Cv = np.sqrt(2) / np.sqrt(N)

Also be careful with the variables name I used in the nested for loop.
(In DCT outer nested for loop uses u and v, inner one uses x and y. In IDCT outer nested for loop uses x and y, inner one uses u and v)

from image-transform-dct-and-idct.

yuan243212790 avatar yuan243212790 commented on September 4, 2024

from image-transform-dct-and-idct.

denpo1022 avatar denpo1022 commented on September 4, 2024

I won't call them exactly the same but yes the basic idea and concept of the both formulas are pretty similar.
For me it's more clear to treat DCT and IDCT as distinct formulas, but now I understand your opinion and the way of thinking.
Regarding DCT and IDCT as the same would be fine, just be careful when implementing with the code :D

from image-transform-dct-and-idct.

yuan243212790 avatar yuan243212790 commented on September 4, 2024

from image-transform-dct-and-idct.

denpo1022 avatar denpo1022 commented on September 4, 2024

Thank you very much!I just want to know the implement in code are the same,Only one is the operation of the original image, and the other is the post-processing of the former

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年7月6日(星期三) 晚上6:41 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [denpo1022/Image-Transform-DCT-and-IDCT] dct and idct are the same formula? (Issue #1) I won't call them exactly the same but yes the basic idea and concept of the both formulas are pretty similar. For me it's more clear to treat DCT and IDCT as distinct formulas, but now I understand your opinion and the way of thinking. Regarding DCT and IDCT as the same would be fine, just be careful when implementing with the code :D — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

No problem. You can always launch a new issue whenever you got something want to ask.

from image-transform-dct-and-idct.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.