-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_3D.py
101 lines (69 loc) · 3.24 KB
/
image_3D.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'''
========================================================================
Image 3D Visualization
Copyright(c) 2020 QiangLi
All Right Reserved
Distributed under the (new) BSD License
=======================================================================-
Permission to use, copy, or modify this software and its documentation
for educational and research purposes only and without fee is here
granted, provided that this copyright notice and the original authors'
names appear on all copies and supporting documentation. This program
shall not be used, rewritten, or adapted as the basis of a commercial
software or hardware product without first obtaining permission of the
authors. The authors make no representations about the suitability of
this software for any purpose. It is provided "as is" without express
or implied warranty.
Source:https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
Install MATLAB Engine API for Python
Before you install, verify your Python and MATLAB configurations.
Check that your system has a supported version of Python and MATLAB R2014b or later.
To check that Python is installed on your system, run Python at the operating system prompt.
Add the folder that contains the Python interpreter to your path, if it is not already there.
Find the path to the MATLAB folder. Start MATLAB and type matlabroot in the command window.
Copy the path returned by matlabroot.
-----------------------------------------
[1] matlabroot
-----------------------------------------
To install the engine API, choose one of the following.
1. At a Windows operating system prompt —
----------------------------------------
[1] cd "matlabroot\extern\engines\python"
[2] python setup.py install
----------------------------------------
2. You might need administrator privileges to execute these commands.
At a macOS or Linux operating system prompt —
----------------------------------------
[1] cd "matlabroot/extern/engines/python"
[2] python setup.py install
----------------------------------------
You might need administrator privileges to execute these commands.
At the MATLAB command prompt —
------------------------------------------------------
[1] cd (fullfile(matlabroot,'extern','engines','python'))
[2] system('python setup.py install')
------------------------------------------------------
'''
#If you don't open Matlab in your local machine, then you can start a new
#matlab environment
import matlab.engine
#eng = matlab.engine.start_matlab()
# When there are multiple shared MATLAB sessions on your local machine,
# connect to two different sessions one at a time by specifying their names.
names = matlab.engine.find_matlab()
# Connect to a shared MATLAB session that is already running on your local machine.
eng = matlab.engine.connect_matlab()
eng.addpath(r'/home/liqiang/CVP/BioMulti-L-NL-Model/')
import io
import matplotlib.pyplot as plt
from imageio import imread
import numpy as np
from skimage.color import rgb2gray
from skimage.transform import resize, rescale
I = imread('/home/liqiang/CVP/BioMulti-L-NL-Model/imgs/clown.png')
I = rgb2gray(I)
I = resize(I, (256, 256))
s2 = eng.mat_image_3D(matlab.double(I.tolist()), 2, 'jet', 'gray')
while eng.isvalid(s2):
pass