Professional Documents
Culture Documents
........................................................................................................................................ 1
Q1 Reading Given MP3 using audioread ................................................................................. 1
1a Plotting initial 4 sec ........................................................................................................ 1
1b creating new file ............................................................................................................. 2
1c Playing Audio ................................................................................................................ 2
1d Audio Info ..................................................................................................................... 2
1e Convert Samples to vectors .............................................................................................. 2
Q2 Finding error between data and resultant samples ................................................................ 2
Q3 Reading given txt data .................................................................................................... 3
Q4 Read given jpeg image ................................................................................................... 3
4a Seperate RGB ................................................................................................................ 4
4b Resizing image ............................................................................................................... 6
4c Conversion of colour to gray ............................................................................................ 7
4d Creating RGB from red pallete ......................................................................................... 7
Q5 Reading xls file and displaying image ............................................................................... 8
Q6 Calculating no. of frames ................................................................................................ 8
Q6b Extract frames till 2 secs ............................................................................................... 9
%%LAB1
Author :Aadhitiya VS
net id av558
1710110001
1
1b creating new file
audiowrite('new_audio.wav',ydata,fs); % writes a matrix of audio data,
y with sample rate to a new.wave
% on increasing fs the song is faster
1c Playing Audio
sound(ydata,fs); %sound function plays the audio
1d Audio Info
audioinfo('new_audio.wav');
2
ce= ceil(ydata); %ceiling ydata
ro = round(ydata); %rounding data
diff1 = ydata - flo; %calculating difference then we calculate
absolute
diff2 = ydata - ce;
diff3 = ydata - ro;
ab1 = abs(diff1);
ab2 = abs(diff2);
ab3 = abs(diff3);
F = sum(ab1(:)); %adding the absolute value of the difference between
floor and ydata
G = sum(ab2(:));
H = sum(ab3(:));
3
Ir=I(:,:,1); % We are breaking 3d vector into a single vector of red
colour
Ig=I(:,:,2); % breaking the 3d vector into a single vector of 2nd
coloumn of green.
Ib=I(:,:,3); % Similar process for blue
4a Seperate RGB
figure;
imshow(I); %Shows the coloured image
title('coloured image');
figure;
imshow(Ir); %shows the red pallete but its grey
title('red image');
figure;
imshow(Ig); % shows green pallete but its grey
title('green image');
figure;
imshow(Ib); % shows blue pallete but its grey
title('blue image');
4
5
4b Resizing image
I1=imresize(I,1.5); %resizes I to 1.5 its size and stores it in I1
figure;
imshow(I1); %shows 1.5x the image
title('resize');
6
4c Conversion of colour to gray
Igray=rgb2gray(I); % converts I to Grayscale Igray
figure;
imshow(Igray); %the difference is that they are gray now
title('Grayscale');
7
Q5 Reading xls file and displaying image
[numstr,str]=xlsread('Text_Data.xlsx');
%to convert string into characters
c1=char(str);
asc=double(c1); %converting to double
img=reshape(asc,[],11); %resizing to our own specifications
figure;
imshow(img);
title('xls image');
8
Q6b Extract frames till 2 secs
Vid = VideoWriter('New.avi'); %writing video data into avi file
open(Vid); %opening it to write video data
for i=0:2*Framerate; % for loop to collect frames till 2 seconds
f = readFrame(V); %storing it in frames
writeVideo(Vid,f); %writing video with the frames obtained till 2 secs
end
close(Vid);
implay('New.avi'); %plays the new video created