From fdba6da5f75c6f7e2bb613e4143f8004ce4f7b9d Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Fri, 4 Nov 2016 13:34:03 +0100 Subject: [PATCH] =?UTF-8?q?[BV]=20=C3=9Cbung=203=20Bearbeitung=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jim Martens --- bv/uebung3.m | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bv/uebung3.m diff --git a/bv/uebung3.m b/bv/uebung3.m new file mode 100644 index 0000000..128c291 --- /dev/null +++ b/bv/uebung3.m @@ -0,0 +1,42 @@ +% histogram distances +rice = imread('rice.png'); +cam = imread('cameraman.tif'); +rice_sp = imnoise(rice, 'salt & pepper', 0.02); +rice_g = imnoise(rice, 'gaussian'); +[h1,] = imhist(rice); +[h2,] = imhist(cam); +[h3,] = imhist(rice_sp); +[h4,] = imhist(rice_g); +dist_rice_camera = pdist2(h1', h2'); +dist_rice_rice_sp = pdist2(h1', h3'); +dist_rice_rice_g = pdist2(h1', h4'); +distman_rice_camera = pdist2(h1', h2', 'cityblock'); +distman_rice_rice_sp = pdist2(h1', h3', 'cityblock'); +distman_rice_rice_g = pdist2(h1', h4', 'cityblock'); +% colour spaces +peppers = imread('peppers.png'); +peppers_gray = rgb2gray(peppers); +peppers_hsv = rgb2hsv(peppers); +peppers_lab = rgb2lab(peppers); +%figure (1), imhist(peppers(:, :, 1)); +%figure (2), imhist(peppers(:, :, 2)); +%figure (3), imhist(peppers(:, :, 3)); +%figure (4), imshow(peppers_hsv); +%figure (5), imshow(peppers_lab); +%figure (6), imshow(peppers); +% binary images +coins = imread('coins.png'); +coins_bw = coins; +for i = 1 : numel(coins_bw) + if coins_bw(i) < 90 + coins_bw(i) = 0; + else + coins_bw(i) = 1; + end +end +coins_bw_l = logical(coins_bw); +level = graythresh(coins); +coins_bw_mat = imbinarize(coins, level); +figure (1), imhist(coins); +figure (2), imshow(coins_bw_l); +figure (3), imshow(coins_bw_mat);