Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 15

LAPORAN MODUL 2 EKSPERIMEN 6

PRAKTIKUM TEKNOLOGI SISTEM ELEKTRONIKA AUDIO VIDEO

“Motion Estimation for Video Coding”

Dosen Pengampu:
Dr. Yasdinul Huda S.Pd M.T

Disusun oleh:
Fadhli Harzian Syah (21065024)

PROGRAM STUDI PENDIDIKAN TEKNIK ELEKTRONIKA


DEPARTEMEN TEKNIK ELEKTRONIKA
FAKULTAS TEKNIK
UNIVERSITAS NEGERI PADANG
2024
TEKNOLOGI SISTEM ELEKTRONIKA AUDIO VIDEO
Eksperimen 6

[Motion Estimation for Video Coding]


Yao Wang and Xiaofeng Xu,
eeweb.poly.edu/~yao/EE4414/exp2_motion.doc
Yasdinul Huda

1. Introduction
Seperti yang telah Anda pelajari di kuliah, prediksi kompensasi gerak (motion
compensated prediction) adalah langkah penting dalam teknik pengkodean video
modern.
Untuk percobaan ini, Anda diberikan program MATLAB untuk melakukan
estimasi gerak (motion estimation) dan kompensasi gerak (motion compensation)
menggunakan teknik yang berbeda: EBMA, Exhaustive Block Matching Algorithm.
(with integer or half-pel accuracy) dan HBMA, Hierarchical Block Matching
Algorithm. Anda harus membaca kode MATLAB dan mencoba memahami
bagaimana setiap algoritma diimplementasikan. Anda juga diminta untuk
menjalankan program ini dengan pengaturan parameter yang berbeda dan mencatat
hasil prediksi dan waktu perhitungan yang dihasilkan. Dari eksperimen ini, Anda
harus menghargai (appreciate) trade-off antara akurasi prediksi dan waktu komputasi
dengan algoritma dan pengaturan parameter yang berbeda.
Program lain menerapkan blok DCT pada gambar, mengukur koefisien DCT,
dan menghitung jumlah koefisien non-zero setelah kuantisasi. Jumlah koefisien non-
zero adalah indikator yang baik dari bit rate (laju bit) yang diperlukan untuk kode
frame. Dengan menerapkan program ini pada frame video asli dan kesalahan prediksi,
dan membandingkan jumlah koefisien non-zero yang dihasilkan, Anda juga dapat
menghargai penghematan bit-rate dengan estimasi gerak.

2. Experiment

(1) EBMA_main.m is the main program for performing motion estimation using
EBMA. You can call fuction EBMA_integer(..) or EBMA_half(…) from
EBMA_main.m to execute integer or half-pel accuracy EBMA. It also calls for
plot_MV_function(…), which plots the estimated motion field. Go through these
programs to understand the underlying operations. Note you can view the Matlab
programs using MATLABEditor. Either click on those files, or uses the “open” menu
in MATLAB command window. In EBMA_main.m, which variables should be
changed if you want to do motion estimation between the following two frames:
‘foreman66.Y’ and ‘foreman69.Y’? What if you want to change the horizontal and
vertical search range?
Predicted Image Prediction Error Image

50

100

150

200

250

50 100 150 200 250 300 350

Motion Field

(2) Run the program EBMA_main as is, which calls EBMA_integer() function, and
uses a preset block size (=16) and search range (=16). Capture all images and record
the running time and PSNR. Save the predicted image into “pimg1”. (this can be
done simply at the command window by entering >>pimg1=pimg;)

EBMA_integer(),

Target Image Anchor Image

50 50

100 100

150 150

200 200

250 250

50 100 150 200 250 300 350 50 100 150 200 250 300 350

Prediction Error Image Predicted Image

50

100

150

200

250

50 100 150 200 250 300 350

Motion Field
(3) Now, open EBMA_main.m, change the line that calls EBMA_integer(..) to call
EBMA_half(…) instead. Save the file, and run EBMA_main again. Capture all
images and record the running time and PSNR.
Save the predicted image into “pimg2”. Compared to the results obtained using
EBMA_integer(), which method is more accurate, which method takes more time?
Explain why.

EBMA_half(…)
Target Image Anchor Image

50 50

100 100

150 150

200 200

250 250

50 100 150 200 250 300 350 50 100 150 200 250 300 350
Prediction Error Image
Predicted Image

50

100

150

200

250

50 100 150 200 250 300 350

Motion Field
metode mana yang lebih akurat, metode mana yang membutuhkan waktu lebih lama?
Jelaskan mengapa?

 Metode yang Lebih Akurat: EBMA_half() karena menghasilkan nilai PSNR yang
lebih tinggi, menunjukkan bahwa prediksi gambar lebih mirip dengan gambar
asli.

 Metode yang Lebih Cepat: EBMA_integer() karena tidak memerlukan interpolasi


tambahan, sehingga mengurangi waktu komputasi.

(4) Edit the EBMA_main.m program to change horizontal search range into “8”. Also
change the EBMA_half(…) back to EBMA_integer(…) to run integer accuracy
EBMA. Save the program and run it again. Capture all images and record the running
time and PSNR. Save the predicted image into “pimg3”. Compared to the results
obtained using EBMA_integer() with search range =16, which method is more
accurate, which method takes more time? Explain why.

EBMA_integer() dengan rentang pencarian horizontal menjadi “8”

Target Image Anchor Image

50 50

100 100

150 150

200 200

250 250

50 100 150 200 250 300 350 50 100 150 200 250 300 350

Prediction Error Image Predicted Image

50

100

150

200

250

50 100 150 200 250 300 350


Motion Field

 Metode yang Lebih Akurat

EBMA_integer() dengan jangkauan pencarian horizontal 16 karena menghasilkan


nilai PSNR yang lebih tinggi.

 Metode yang Lebih Cepat

EBMA_integer() dengan jangkauan pencarian horizontal 8 karena mengurangi jumlah


perhitungan yang diperlukan, sehingga mempercepat waktu eksekusi.

(5) The function video_coding(..) is intended to show the required bit rate and
reconstructed image, when we apply DCT to the prediction error image and quantize
the DCT coefficients. Instead of applying run-length coding to the quantized DCT
coefficients, the program simply counts the number of non-zero coefficients after
quantization. This number is a good indicator of the required bit rate for coding an
image. It also shows you the original image, DCT image without quantization,
quantized DCT image, and the reconstructed image from the quantized DCT
coefficients. As a comparison, it also applies the same processing on the original
image. Go through this program and try to understand the underlying processing. This
program uses a MATLAB function “blkproc(…)”, which performs the same
function on every block of an image, where the function can be a built-in MATLAB
function or a user-defined function. You can type “help blkproc” on the MATLAB
command window to learn more about how this function works.
250

200

150

100

50

(6) Run this program with the predicted image from using half-pel motion estimation
(step 3) as the input of this program. Note that in this case, you should use ‘img2’ for
the first parameter “Anchor_Img”, and use ‘pimg2’ for the second parameter
“Predict_Img”. Hint: To run the program, on the MATLAB command window, type
“video_coding (img2,pimg2)”. Enter “8” for the quantization factor. Capture all
images and record the percentage of non-zero coefficients and PSNRs. What is
percentage of non-zero coefficients when DCT is applied to the original image? What
is percentage when DCT is applied to the error image? Which way (DCT on original
image or DCT on error image) will lead to lower bit rate? Which method gives you
better reconstructed image? (both visually and in terms of PSNR). Explain why.

DCT of Original Image


Original image
Quantized DCT of Original Image
Quantized DCT of Original Image

DCT of the error image


Original error image without quantization

Reconstructed error image from quantized DCT Quantized DCT of the error image
Reconstructed image with prediction

Original image

(7) Now

repeat the
same program with a high quantization factor (e.g. 80 or higher). Capture all images
and record the percentage of non-zero coefficients and PSNRs. Which quantization
factor gives you better reconstructed image quality? Which factor gives you the
smaller percentage of non-zero coefficients (correspondingly bit rate)? And why?

DCT of Original Image Quantized DCT of Original Image

Reconstructed image from quantized DCT Original error image without quantization
DCT of the error image Quantized DCT of the error image

Reconstructed error image from quantized DCT Reconstructed image with prediction

Original image DCT of Original Image

Quantized DCT of Original Image


Reconstructed image from quantized DCT
Original error image without quantization DCT of the error image

Quantized DCT of the error image


Reconstructed error image from quantized DCT

Reconstructed image with predict


Analisis
• Kualitas Gambar Rekonstruksi Lebih Baik:
Faktor kuantisasi yang menghasilkan PSNR lebih tinggi menunjukkan kualitas gambar
yang direkonstruksi lebih baik.
• Persentase Koefisien Bukan Nol yang Lebih Kecil:
Faktor kuantisasi yang menghasilkan persentase koefisien bukan nol yang lebih kecil
menghasilkan laju bit yang lebih rendah.
• Faktor Kuantisasi Tinggi (mis., 80):

Kuantisasi yang lebih tinggi mengurangi jumlah nilai yang berbeda dalam gambar,
sehingga menghasilkan lebih banyak koefisien nol dan kecepatan bit yang lebih rendah.
Namun, hal ini biasanya menghasilkan kualitas gambar yang lebih rendah (PSNR lebih
rendah) karena hilangnya informasi yang lebih besar.

• Faktor Kuantisasi Lebih Rendah (mis., 50):

Kuantisasi yang lebih rendah mempertahankan lebih banyak informasi, sehingga


menghasilkan kualitas gambar yang lebih tinggi (PSNR lebih tinggi).
Namun, hal ini biasanya menghasilkan persentase koefisien bukan nol yang lebih tinggi
dan kecepatan bit yang lebih tinggi.

3. Report
Your report should start with a general description of what you did in this experiment,
followed by the results and observations you obtained. You should answer all the
questions (written in italics in the proceeding instructions), with the corresponding
figures next to your answers.

You might also like