The high level of image processing is provided in MATLAB how do we know that? How it is different from the interface application (Adobe Photoshop, illustrate). MATLAB has the ability to use a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation. Of course, we have to put in the command and run the script to change our image and video it may turn out the same or a different thing depending on your propose and experience in special techniques that are included in MATLAB. I studied some techniques that use to improve the quality of video and images. I test it on the advertising videos that can conclude all the concepts that I studied in my lecture. Let’s see how it works!
To adjust the red colors to be sharper in the dark background. I try to add more red color in RGB mode that would consistent with all effect animations. The sharp red can looks more touchable and realistic. Here is the script: the advertising is fascinating and recognize. See “Sharp red Coca-Cola advertising” video footages click on this link:
v = VideoReader(‘PearlHarbour.mp4’);
n = v.NumberOfFrames;
w = VideoWriter(‘PearlHarbourCP’, ‘Motion JPEG AVI’);
open(w)
for i = 1:1000
img = read(v, i); %matrix
r = rgb2gray(img);
imshowpair(img, r, ‘montage’);
writeVideo(w, r)
end;
close(w)
We can add more colorful on the can. Let’s adjust the rainbow tone on its. It calls “Coca-Cola advertising with rainbow sparkling” version. The script are pretty longer than the we have anyway it turn out the rainbow!. Using the script below with “imadjust()” to adjust rainbow color tone in the advertising.
v = VideoReader(‘cocaads.mp4’);
n = v.NumberOfFrames;
w = VideoWriter(‘cocarainbow.avi’);
open(w)
for ci = 1: n
img = read(v, ci);
R = img(:, :, 1);
G = img(:, :, 2);
B = img(:, :, 3);
if(ci >= 10)&&(ci <70)%purple
sR = imadjust(R, [(0/255) (50/255)], [0 1] );
sG = imadjust(G, [(0/255) (255/255)], [0 1] );
sB = imadjust(B, [(0/255) (50/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
elseif(ci >= 70)&&(ci <130)%blue-light
sR = imadjust(R, [(0/255) (255/255)], [0 1] );
sG = imadjust(G, [(0/255) (50/255)], [0 1] );
sB = imadjust(B, [(0/255) (50/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
elseif(ci >= 130)&&(ci <190)%blue
sR = imadjust(R, [(0/255) (255/255)], [0 1] );
sG = imadjust(G, [(0/255) (255/255)], [0 1] );
sB = imadjust(B, [(0/255) (50/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
elseif(ci >= 190)&&(ci <250)%green
sR = imadjust(R, [(0/255) (255/255)], [0 1] );
sG = imadjust(G, [(0/255) (50/255)], [0 1] );
sB = imadjust(B, [(0/255) (255/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
elseif(ci >= 250)&&(ci <310)%yellow
sR = imadjust(R, [(0/255) (50/255)], [0 1] );
sG = imadjust(G, [(0/255) (50/255)], [0 1] );
sB = imadjust(B, [(0/255) (255/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
4
elseif(ci >= 310)&&(ci <380)%orange
sR = imadjust(R, [(0/255) (20/255)], [0 1] );
sG = imadjust(G, [(0/255) (90/255)], [0 1] );
sB = imadjust(B, [(0/255) (255/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
elseif(ci >= 380)%red
sR = imadjust(R, [(0/255) (50/255)], [0 1] );
sG = imadjust(G, [(0/255) (255/255)], [0 1] );
sB = imadjust(B, [(0/255) (255/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
else
s = img;
end
writeVideo(w, s);
end;
close(w)
To adjust the main color tone which is orange color to turn its more brightness. I adjust the orange tone in RGB mode until it is compatible with all environment. I use the script below with “imadjust()” to change orange color tone in the advertising. After adjustment, the light orange will make the advertising more attractive and cheerful. Here is the script: See “Light orange Fanta advertising” video footages click on this link:
v = VideoReader(‘orangejuice.mp4’);
n = v.NumberOfFrames;
w = VideoWriter(‘lightorangejuice.avi’);
open(w)
for ci = 1: n
img = read(v, ci);
R = img(:, :, 1);
G = img(:, :, 2);
B = img(:, :, 3);
sR = imadjust(R, [(0/255) (70/255)], [0 1] );
sG = imadjust(G, [(0/255) (190/255)], [0 1] );
sB = imadjust(B, [(0/255) (200/255)], [0 1] );
s = cat(3, sR, sG, sB);
imshowpair(img, s, ‘montage’);
writeVideo(w, s);
end;
close(w)
To make the video looked mysterious and background by history. The compression mode has been restricted on the MATLAB online version. I cannot change the file to MP4 so that the file size is just a little compression by using the specific frame range and ‘Motion JPEG AVI’ .avi file type. Here is the script to change the gray tone for the PearlHarbour video.
v = VideoReader(‘PearlHarbour.mp4’);
n = v.NumberOfFrames;
w = VideoWriter(‘PearlHarbourCP’, ‘Motion JPEG AVI’);
open(w)
for i = 1:1000
img = read(v, i); %matrix
r = rgb2gray(img);
imshowpair(img, r, ‘montage’);
writeVideo(w, r)
end;
close(w)
Design to degrade your video footage only in some frames. Blurring the cigarette film from short video by this script. Using some part of the movie scene to do spatial down sampling. The blurring scene start from frame number: 480 and degrade more after run to 800.
v = VideoReader(‘monicasmoke.mp4’);
n = v.NumberOfFrames;
w = VideoWriter(‘monicasmoke.avi’, ‘Motion JPEG AVI’);
open(w)
for ci = 1: n
img = read(v, ci);
if(ci > 480)&&(ci <800)
s = imresize(imresize(img, 1/4), 4);
elseif(ci >= 800)
s = imresize(imresize(img, 1/20), 20);
else
s = img;
end
writeVideo(w, s);
end;
close(w)
For who used MATLAB in a trial version, the video sound may cut off from your video. You can use another application to put the sound or used this scrip to split the sound to support the external task that you will do with other applications. Here is the script:
[input_file, Fs] = audioread(‘fire02.mp4’);
audiowrite(‘target_file.WAV’, input_file, Fs);
This blog is a part of my image processing course at Assumption University
Thank you to my advisor Dr. Kanoksak Wattanachote