Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz...
Transcript of Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz...
![Page 1: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/1.jpg)
Praktische Aspekte
der InformatikMoritz Mühlhausen
Prof. Marcus Magnor
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 2: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/2.jpg)
MatlabPrototyping and designing new algorithms
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 3: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/3.jpg)
Further Reading
Warning!The following slides are meant to give you
a very superficial introduction.
If you want to learn more, have a look at:http://www.mathworks.com/help/matlab/
http://www.cs.jhu.edu/CIRL/class/600.161/class2/shortmatlab.pdf
https://www.tu-braunschweig.de/it/service-interaktiv/software/liste#M
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 4: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/4.jpg)
Outline
Introduction
Matrices
Plotting
Programming Language
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 5: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/5.jpg)
Introduction
Benefits
• A large and widely used toolbox of numeric and
image functions.
• A great tool for prototyping
and developing new
algorithms.
• A lot of high-level features.
• You can link C/C++/cuda!
Drawbacks
• It can be slow.
• You need a license.
• Untyped variables.
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 6: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/6.jpg)
Introduction
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 7: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/7.jpg)
Outline
Introduction
Matrices
Plotting
Programming Language
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 8: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/8.jpg)
Matrices
• Variables and Data Types will be very familiar to you. char, int8, uint8, … int64, uint64, single, double, …
• Matlab treats all variables as matrices.
Vectors are matrices with only one row/column.
Values are matrices with only one entry.
>> M = [1,2,3; 4,5,6; 7,8,9]
M =
1 2 3
4 5 6
7 8 9
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 9: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/9.jpg)
Matrices
>> M = [1,2,3; 4,5,6; 7,8,9]
M =
1 2 3
4 5 6
7 8 9
>> M_sub = M(1:2,:)
M_sub =
1 2 3
4 5 6
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 10: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/10.jpg)
Matrices
j:k is the same as [j,j+1,...,k] is empty if j > k
j:i:k is the same as [j,j+i,j+2i, ..,k] is empty if i > 0 and j > k or if i < 0 and j < k.
A(:,j) is the j-th column of A.
A(i,:) is the i-th row of A.
A(:,:) is the equivalent two-dimensional array. For matrices this is A.
A(j:k) is A(j), A(j+1),...,A(k).
A(:,j:k) is A(:,j), A(:,j+1),...,A(:,k).
A(:,:,k) is the k-th page of three-dimensional array A.
A(i,j,k,:) is a vector in a four-dimensional array A.
A(:) is all the elements of A, as a single column.On the left side of an assignment statement, A(:) fills A.
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 11: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/11.jpg)
Matrices
X = M’ Transposed matrix M
X = inv(M) Inverse of an 𝑛 × 𝑛 matrix M
X = det(M) Determinant of M
[X,D] = eig(M) Eigenvalues and Eigenvectors of M
[r,c] = size(M) Size of M
[Q,R] = qr(M) QR decomposition of M
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 12: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/12.jpg)
Outline
Introduction
Matrices
Plotting
Programming Language
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 13: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/13.jpg)
Plotting
• Matlab can also quickly plot your data
>> X = [1,4,6,8];
>> Y = [7,3,5,2];
>> plot(X,Y)
• You can also plot a single vector,Matlab will just use it’s indices
>> V = [6,4,8,2];
>> plot(V)
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 14: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/14.jpg)
Plotting
• Bar Charts
>> V = [75 91 105 123.5 131 189];
>> bar(V)
• Scatter Plots
>> X = rand(1,100);
>> Y = rand(1,100);
>> plot(X,Y,'*')
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 15: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/15.jpg)
Outline
Introduction
Matrices
Plotting
Programming Language
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 16: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/16.jpg)
Programming Language
Conditional
if a == b,
…
elseif a > b
…
else
…
end
For-Loop
for i = 1:8
for j = {1:4,8,15}
…
end
end
While-Loop
while i < N
…
end
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 17: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/17.jpg)
Programming Language
You can often avoid simple loops…
for i = 1:10000
x(i) = sin(i);
end
… by doing something like this
n = 1:10000;
x = sin(n);
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 18: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/18.jpg)
Programming Language
You can also create reusable scripts and functions
imageDenoiseTest.m
image = imread('padi.png'); % RGB image
redChannel = image(:,:,1); % extract the first channel
redChannel = wiener2(redChannel,[5,5]); % denoising function
disp('Image denoised!');
imshow(redChannel); % show the result
>> imageDenoiseTest
Image denoised!
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 19: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/19.jpg)
Programming Language
You can also create reusable scripts and functions
functionTest.m
function [denoisedImage] = functionTest(imageName)
image = imread(imageName); % RGB image
denoisedImage = image(:,:,1); % extract the first channel
denoisedImage = wiener2(denoisedImage,[5,5]); % denoising function
disp('Image denoised!');
end
>> image = functionTest('padi.png')
Image denoised!
>> imshow(image)
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 20: Praktische Aspekte der Informatik - graphics.tu-bs.de filePraktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor](https://reader030.fdocuments.us/reader030/viewer/2022040713/5e18ae18140661125c3c1a33/html5/thumbnails/20.jpg)
Matlab
Introduction
Matrices
Plotting
Programming Language
https://graphics.tu-bs.de/teaching/ws1718/padi/