Search
General information for Matlab development.
To fulfill this assignment, you need to submit these files (all packed in one .zip file) into the upload system:
.zip
answers.txt
assignment_basics.m
matrix_manip.m
compute_letter_mean.m
compute_lr_histogram.m
initial1_mean.png
initial2_mean.png
initials_histograms.png
Use template of the assignment. When preparing a zip file for the upload system, do not include any directories, the files have to be in the zip file root.
Beware of using for loops! :)
for
This is highly experimental feature. Use at your own risk.
Standard is to use Matlab. You may skip this info box if you follow the standard rules.
General information for Python development.
basics.ipynb
basics.py
matrix_manip
compute_letter_mean
compute_lr_histogram
Follow the instructions on Matlab - faculty license.
Statistical Pattern Recognition Toolbox contains variety of algorithms which you will implement by yourself during this course (you can use them as an inspiration) and contains also many support functions which we will use throughout the semester.
Download the latest version of the toolbox from https://gitlab.fel.cvut.cz/smidm/statistical-pattern-recognition-toolbox. Unpack the content of the .zip file into your working directory (you should be able to find it next week!). To be able to use the toolbox, you have to set the path to it:
stprpath
Now you can switch to any other directory and still use the functions from the STPR toolbox.
To verify the paths try to run demo_ocr.
demo_ocr
We will be using MATLAB programming language during the whole semester. It is necessary for you to be as familiar with it as possible, since the labs are time limited and the tasks are often challenging. It may happen that you spend more time looking for MATLAB syntax of some function instead of solving the problem itself.
For the case you are not too sure about your MATLAB skills, here are few useful links:
help ops % short help on MATLAB operators and special characters doc sum % documentation for the sum function lookfor transpose % searches for string "transpose" in the documentation
In most of the assignments there will be a set of simple questions. Answering the questions should help you to solve the assignment. All questions need to be answered correctly to get the points for the assignment.
Fill the correct answers to your answers.txt file.
Example answers.txt (bogus answers only, fill the correct ones):
question1 : gen_zero_matrix question2 : 'x*' # enclose special characters in tick marks, also known as single quotation marks. question3 : '^' # enclose special characters in tick marks, also known as single quotation marks. question4 : [a,d,e] question5 : [b,f]
In the first part of today’s assignment, you will start with some simple matrix manimulation tasks. AVOID THE USE OF ANY LOOPS IN YOUR PROGRAM!
Your goal is to complete a function output = matrix_manip(A, B), where A and B are input matrices and output is a resulting structure containing results of operations described below.
output = matrix_manip(A, B)
A
B
output
To have some data to work with, use matrices A and B from assignment_basics.m:
A = [16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1] B = [ 3 4 9 4 3 6 6 2 3 4; 9 2 10 1 4 3 7 1 3 5]
Function should work on general input matrices, not only for above prescribed A and B matrices or matrices with the same dimensions. Dimensions of the input matrices will be always suitable for all of the following tasks.
output.A_transpose
>> output.A_transpose output.A_transpose = 16 5 9 4 2 11 7 14 3 10 6 15 13 8 12 1
output.A_3rd_col
>> output.A_3rd_col output.A_3rd_col = 3 10 6 15
:
output.A_slice
>> output.A_slice output.A_slice = 7 6 12 14 15 1
output.A_gr_inc
>> output.A_gr_inc output.A_gr_inc = 17 2 3 14 1 6 12 11 9 1 10 8 7 13 1 5 15 16 1 1
>
[]
C
output.C
>> output.C output.C = 499 286 390 178 286 383 351 396 390 351 383 296 178 396 296 508
>> output.A_weighted_col_sum output.A_weighted_col_sum = 391
.*
sum()
output.D
>> output.D output.D = -1 0 5 0 -1 2 2 -2 -1 0 3 -4 4 -5 -2 -3 1 -5 -3 -1
repmat
D
>> output.D_select output.D_select = 0 5 0 -2 -4 4 -5 -5
.^2
find
norm
In this part of the assignment, you are supposed to work with a simple input data which contains images of letters. We will use similar data structures later on during the labs. Do the following:
Note: Plotting and displaying of images should be implemented only in assignment_basics.m.
data_33rpz_cv01.mat
images
Alphabet
labels
ims = permute(images,[1 2 4 3]); % The images must be ordered by the 4th dimension. (not needed in new matlab versions) montage(ims); colormap gray;
imshow
imagesc
subplot
montage
uint8
letter_mean = compute_letter_mean(letter_char, Alphabet, images, labels)
letter_char
letter_mean
x = sum of pixel values in the left half of image - sum of pixel values in the right half of image
lr_histogram = compute_lr_histogram(letter_char, Alphabet, images, labels, num_bins)
num_bins
lr_histogram
>> compute_lr_histogram('A', Alphabet, images, labels, 10) ans = 1 1 3 6 12 27 24 20 5 1
hist