In Class Exercise Your goal is to create a script to decode the picture. Use the
ID: 3917137 • Letter: I
Question
In Class Exercise Your goal is to create a script to decode the picture. Use the file encoding_script.m' to help figure out how to create the decoding script. .By examining the 'encoding_script.m' file it can be seen that a 16 bit number representing the total number of characters is encoded in the first 16 pixels. I've created a template that decodes this number and provides it to you for future use. Decode the rest of the image ERING In Class Exercise Note: dec2bin can convert characters to binary numbers. Note: bin2num can convert binary numbers to decimal numbers Thus, all the encrypted characters will be decoded into decimal numbers. To convert the decoded decimal numbers to characters simply: decodedCharacters-char (decodedDecimalNumbers)Explanation / Answer
close all;
clear all; %clears workspace, closes all figures
f1 = @(block_struct) dct2(block_struct.data); %performing discrete cosine transformation
f2=@(block_struct) idct2(block_struct.data);%performing inverse discrete cosine transformation
Im=imread('picture.tif); %reading the given image here and storing it in Im
imwrite(IM,'new.tif');%Writing the image as new.tif . just to see the difference between original image and stored image
figure.imshow(IM);
J=blockproc(Im,[16,16],f1); %using blockproc funtion,where block size is defined as [16 16] and block processing on image 'Im' and the funtion f1 defined as above
depth=find(abs(J)<150); % finding the absolute value of J which is less than 150
J(depth)=zeros(size(depth);%assiging all the values as zero wherever value is less than 150
K=blockproc(J,[16,16],f2)/255; %performing blockproc for f2 which is IDCT and store it in K
figure.imshow(K);
imwrite(K,newc.tif);% write the mage as newc.tif
compression ratio=nume1(J)/nume(depth);
You can change the value in "depth=find(abs(J)<150);" and observe the difference in size of the image