how to change these parts to 0??

1 view (last 30 days)
DOHYUN JANG
DOHYUN JANG on 30 Nov 2019
Answered: Sourav Bairagya on 9 Dec 2019
This is the picture of a gray image after DCT porcess. I want make other 4 images which are : 1. make part 1 in picture to 0 and then idct 2. make part 2 in picture to 0 and then idct 3. make part 3 in picture to 0 and then idct 4. make part 4 in picture to 0 and then idct
please help me ....
  1 Comment
Walter Roberson
Walter Roberson on 30 Nov 2019
dctstuff = dct(...);
dct1 = dctstuff;
dct1(1:20, 1:20) = 0;
idct1 = idct(dct1);

Sign in to comment.

Answers (1)

Sourav Bairagya
Sourav Bairagya on 9 Dec 2019
dct.png
Assuming the dct image is ‘dct_img’ and the indexes of the sections are as shown here in this figure, you can create four inverse DCTs in the following way:
%For section 1
dct1 = dct_img;
dct1(1:25, 1:25) = 0;
img1 = idct(dct1);
%For section 2
dct2 = dct_img;
dct2(1:25, 25:256) = 0;
img2 = idct(dct2);
%For section 3
dct3 = dct_img;
dct3(25:256, 1:25) = 0;
img3 = idct(dct3);
%For section 4
dct4 = dct_img;
for i=1:256
for j=256:-1:(256-i+1)
dct4(i, j)=0;
end
end
img4 = idct(dct4);

Products

Community Treasure Hunt

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

Start Hunting!