multichannel_demo.py 1.59 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2017-2018 Max-Planck-Society
# Author: Jakob Knollmueller
#
# Starblade is being developed at the Max-Planck-Institut fuer Astrophysik

Jakob Knollmueller's avatar
Jakob Knollmueller committed
19
import numpy as np
Jakob Knollmueller's avatar
Jakob Knollmueller committed
20
from matplotlib import pyplot as plt
Martin Reinecke's avatar
Martin Reinecke committed
21
import starblade as sb
Jakob Knollmueller's avatar
Jakob Knollmueller committed
22
23
24
25

if __name__ == '__main__':

    # data = plt.imread('10Keso1242a.tif')
Jakob Knollmueller's avatar
cleanup    
Jakob Knollmueller committed
26
    data = plt.imread('data/galaxy.jpg')
Jakob Knollmueller's avatar
Jakob Knollmueller committed
27
28
29

    data = data.astype(float)
    data = data.clip(0.0001)
Jakob Knollmueller's avatar
cleanup    
Jakob Knollmueller committed
30
    alpha = 1.3
Jakob Knollmueller's avatar
Jakob Knollmueller committed
31
    MultiStarblade = sb.build_multi_starblade(data, alpha=alpha)
Jakob Knollmueller's avatar
Jakob Knollmueller committed
32

Jakob Knollmueller's avatar
cleanup    
Jakob Knollmueller committed
33
34
    for i in range(50):
        MultiStarblade = sb.multi_starblade_iteration(MultiStarblade, processes=1)
Jakob Knollmueller's avatar
Jakob Knollmueller committed
35
36
37
38
39
40
41
42

        #plotting a three channel RGB image in each iteration
        diffuse = np.empty_like(data)
        point = np.empty_like(data)
        for i  in range(len(MultiStarblade)):
            diffuse[...,i] = np.exp(MultiStarblade[i].s.val)
            point[...,i] = np.exp(MultiStarblade[i].u.val)

Jakob Knollmueller's avatar
cleanup    
Jakob Knollmueller committed
43

Jakob Knollmueller's avatar
Jakob Knollmueller committed
44
45
        plt.imsave('rgb_diffuse.jpg',diffuse/255.)
        plt.imsave('rgb_point.jpg',point/255.)
Jakob Knollmueller's avatar
cleanup    
Jakob Knollmueller committed
46