You are on page 1of 2

%This program computes the DCT of the input image and writes it out %read in cover image cover

= imread('zinniaorig.pgm'); %this is original zinnia image %convert to double dblcover = double(cover); %compute the DCT of the image DCTcover = dct2(dblcover); %find max and min values of the DCT of input max(max(DCTcover)) min(min(DCTcover)) %find max and min of log of DCT values logofDCT = log(DCTcover); max(max(logofDCT)) min(min(logofDCT)) %decide to display image in log format as its range is too large otherwise %also display using [] in imshow command - stretches the log values between %black and white so humans can see it better %show original and its dct figure(1), imshow(cover); title('Original Image'); figure(2), imshow(logofDCT,[]); title('Logarithm of DCT of Image with []'); %imwrite(logofDCT,'logdctzinnia.bmp'); %now do DCT of a subimage dblsub = double(cover(128:255,128:255)); imshow(uint8(dblsub)); [N,M] = size(dblsub); DCTsub = dct2(dblsub); figure(3), imshow(log(DCTsub),[]); title('Logarithm of DCT subimage of Image wit h []'); imwrite(cover(128:255,128:255),'subzinnia.bmp'); imwrite(log(DCTsub),'logdctsubzinnia.bmp');

You might also like