Effacer les filtres
Effacer les filtres

how wa can discard 75% of small coefficients after get the DCT conversion of each image block?

1 vue (au cours des 30 derniers jours)
Hi, i want to do this step on one image but i don't know how i can discard 75% of smal coefficients after get the DCT, please help me .
Can i do this without using for and if?
step:
Divide the input image into smaller blocks with dimensions nXn.
Get the DCT conversion of each image block.
Discard 75% of small coefficients.
Recreate and view the image
my code:
im=imread('s1.jpg');
im = rgb2gray(im);
figure;
imshow(im)
title('Original image');
img_dct=dct2(im);
figure;
imagesc(img_dct);
colormap(gray);
im_dct=idct2(img_dct);
title('DCT Compress Image');
figure;
imagesc(im_dct);
colormap(gray);

Réponses (1)

Jonas
Jonas le 30 Mai 2021
Modifié(e) : Jonas le 30 Mai 2021
use the
Y = prctile(block,75,'all')
command to get the 75% percentile, you can then set all values smaller than this threshold to 0 by
block(block<=Y)=0;
  3 commentaires
Jonas
Jonas le 31 Mai 2021
Modifié(e) : Jonas le 31 Mai 2021
the problem seems to be your image, using a matlab demo image works for me, does it for you?
im=imread('cameraman.tif');
imDct=dct2(im);
Y=prctile(abs(imDct),75,'all');
imDct(abs(imDct)<=Y)=0;
imshow(rescale(idct2(imDct)))
Jonas
Jonas le 31 Mai 2021
Modifié(e) : Jonas le 31 Mai 2021
you used the block variable before you assigned it! i thought you are doing block wise dct
edit: you wrote in your question that you have to do blockwise dct, have a look into the block processor

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by