Beruflich Dokumente
Kultur Dokumente
Topics
Image Data Types
Image Representation
Image and Video I/O
Matrix Access
Image Manipulation
MEX (in brief)
Data Visualization
Tips
Examples
"//"
Common Problem
I = imread(pears.png');
I2 = I-1.4;
diffI = I-I2;
fprintf('Max difference between images: %d\n',max(diffI(:)));
figure(1);
subplot(1,2,1);
imshow(I); title('I');
subplot(1,2,2);
imshow(I2); title('I2');
"//"
Common Problem
I = double(imread('pears.png'));
I2 = I-1.4;
diffI = I-I2;
fprintf('Max difference between images:
%2.1f\n',max(diffI(:)));
figure(1);
subplot(1,2,1);
imshow(I); title('I');
subplot(1,2,2);
imshow(I2); title('I2');
Possible Solution
I = double(imread('pears.png'));
I2 = I-1.4;
diffI = I-I2;
fprintf('Max difference between images:
%2.1f\n',max(diffI(:)));
figure(1);
subplot(1,2,1);
max_I = 255;
imshow(I/max_I); title('I');
subplot(1,2,2);
imshow(I2/max_I); title('I2');
"//"
Image Representation
2D Matrix
Intensity: Each pixel value in the dynamic range [minP, maxP].
Can represent a grayscale image, results of a 2d function etc.
Useful commands: imshow (), imagesc(), colormap().
Image Representation
2D Matrix
Indexed: Each pixel value in the range [1, M].
Points to a colormap containing true colors.
Can represent segmentation.
Useful commands: regionprops(), label2rgb()
"//"
Image Representation
3D Matrix
True Color: Three 2D matrices stacked. Each represents a color
component. (e.g. RGB)
Can represent an RGB color image, Ycbcr image, LAB image, etc.
Useful commands: imshow(), rgb2gray(), rgb2ind().
"//"
Matrix Access
Useful Commands:
sub2ind() convert subscript (e.g. (r,c,clr)) to index (n).
ind2sub() convert index (n) to subscipt (e.g. (r,c,clr)).
meshgrid() generate X,Y grids.
Image Manipulation
Useful Functions:
"//"
Data Visualization
Useful Commands:
scatter()/plot() Useful to plot points on image.
bar() Useful for plotting histograms.
print() Save figure as image on disk (careful with lossy
compressions)
"//"
General Tips
Avoid loops
Manage memory (Clear unused variables)
Useful command: clearvars()
Example 1
Steganography (Wikipedia)
The art of hiding a message within another larger message
Original
Result
"//"
Example 1
Steganography (Wikipedia)
The art of hiding a message within another larger message
I= imread('SteganographyOriginal.png');
I4=85*mod(I,4);
figure;
subplot(1,2,1)
imshow(I); title('Original');
subplot(1,2,2)
imshow(I4);title('Result');
Example 2
Almost Connected (Steve Eddins Blog)
"//"
Example 2
Almost Connected (Steve Eddins Blog)
bw = imread(url);
CC = bwconncomp(bw);
lbl = labelmatrix(CC);
figure; imagesc(lbl); axis image;
Example 2
Almost Connected (Steve Eddins Blog)
bw2 = bwdist(bw) <= 12.5;
CC2 = bwconncomp(bw2);
lbl2 = labelmatrix(CC2);
figure; imshow(bw2);
figure; imagesc(lbl2); axis image;
10
"//"
Example 2
Almost Connected (Steve Eddins Blog)
lbl3 = lbl2.*uint8(bw);
figure;
imagesc(lbl3); axis image;
11