Mercurial > hg > medcouple
annotate talk/code/medc_naive.m @ 49:1676c032cde5
add images explaining the naïve algorithm
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 15 May 2016 13:21:56 -0400 |
parents | |
children |
rev | line source |
---|---|
49
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
1 # A particularly nice rand(1,9) output |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
2 x =[0.1434371910495317 0.7884491711159078 0.5303604008014775 0.6667158533830928 0.3678275414673733 0.0996218030091724 0.4403602735726169 0.7641625823436032 0.3729928446344657]; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
3 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
4 imshow(x); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
5 print -dpng x.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
6 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
7 sortx = sort(x); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
8 imshow(x); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
9 print -dpng sortx.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
10 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
11 RGB = repmat(sortx, 1, 1, 3); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
12 RGB(1,5,1) = 1; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
13 imshow(RGB); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
14 print -dpng sortx-red.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
15 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
16 z = (sortx - median(x))/(max(x) - min(x)); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
17 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
18 zp = z(z>=0); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
19 RGB = repmat(zp, 1, 1, 3); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
20 RGB(1,5,1) = 1; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
21 imshow(RGB); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
22 print -dpng zplus.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
23 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
24 zm = z(z<=0)'; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
25 RGB = repmat(zm, 1, 1, 3); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
26 RGB(5,1,1) = 1; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
27 imshow(RGB); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
28 print -dpng zminus.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
29 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
30 H = (zp + zm)./(zp - zm); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
31 H(isnan(H)) = 0; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
32 H = (H + 1)/2; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
33 imshow(H); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
34 print -dpng H.png |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
35 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
36 medc = median(H(:)); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
37 [i, j] = find(H == medc); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
38 |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
39 RGB = repmat(H, 1, 1, 3); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
40 RGB(i, j, 1) = 1; |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
41 imshow(RGB); |
1676c032cde5
add images explaining the naïve algorithm
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
42 print -dpng medc.png |