Reconstruct the initial image with idct2

Hello, for an assignment I needed to create an image of 512x512 pixels black with in its center a square of white pixel of 100pixels, then I had to make its transformation into discrete cosine and now I must thanks to the function idct2, reconstruct the initial image by retaining only :
  • The 80% largest coefficients of the DCT
  • The 50% largest coefficients of the DCT
  • The 20% largest coefficients of the DCT
But I don't know how to set this parameter, here is my code currently.
image=zeros(512,512);
image(206:305,206:305)=255;
J = dct2(image);
imshow(log(abs(J)),[])
colormap parula
colorbar

 採用された回答

Jonas
Jonas 2021 年 6 月 19 日
編集済み: Jonas 2021 年 6 月 19 日

0 投票

have a look into this post

3 件のコメント

Damien Dubois
Damien Dubois 2021 年 6 月 20 日
No I hadn't found this post. Thanks a lot for your help. Here is how I proceeded I think I have the solution to keep for example the 75% largest coefficient of my DCT. Can you confirm that this is the case?
image=zeros(512,512);
image(206:305,206:305)=255;
J = dct2(image);
Y=prctile(abs(J),75,'all');
J(abs(J)<=Y)=0;
imshow(rescale(idct2(J)))
Jonas
Jonas 2021 年 6 月 20 日
your code is correct. it will remove all values that are smaller than 75% border of absolute values. you can change it to 80, 50 (which is the median by the way!) and 20 to achieve your original goal according to your question
Damien Dubois
Damien Dubois 2021 年 6 月 20 日
Thank you very much for your precious help

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

製品

リリース

R2021a

質問済み:

2021 年 6 月 17 日

コメント済み:

2021 年 6 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by