WolframAlpha.com
WolframCloud.com
All Sites & Public Resources...
Products & Services
Wolfram|One
Mathematica
Wolfram|Alpha Notebook Edition
Programming Lab
Finance Platform
SystemModeler
Wolfram Player
Wolfram Engine
WolframScript
Enterprise Private Cloud
Enterprise Mathematica
Wolfram|Alpha Appliance
Enterprise Solutions
Corporate Consulting
Technical Consulting
Wolfram|Alpha Business Solutions
Resource System
Data Repository
Neural Net Repository
Function Repository
Wolfram|Alpha
Wolfram|Alpha Pro
Problem Generator
API
Data Drop
Products for Education
Mobile Apps
Wolfram Player
Wolfram Cloud App
Wolfram|Alpha for Mobile
Wolfram|Alpha-Powered Apps
Services
Paid Project Support
Wolfram U
Summer Programs
All Products & Services »
Technologies
Wolfram Language
Revolutionary knowledge-based programming language.
Wolfram Cloud
Central infrastructure for Wolfram's cloud products & services.
Wolfram Science
Technology-enabling science of the computational universe.
Wolfram Notebooks
The preeminent environment for any technical workflows.
Wolfram Engine
Software engine implementing the Wolfram Language.
Wolfram Natural Language Understanding System
Knowledge-based broadly deployed natural language.
Wolfram Data Framework
Semantic framework for real-world data.
Wolfram Universal Deployment System
Instant deployment across cloud, desktop, mobile, and more.
Wolfram Knowledgebase
Curated computable knowledge powering Wolfram|Alpha.
All Technologies »
Solutions
Engineering, R&D
Aerospace & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Mechanical Engineering
Operations Research
More...
Finance, Statistics & Business Analysis
Actuarial Sciences
Bioinformatics
Data Science
Econometrics
Financial Risk Management
Statistics
More...
Education
All Solutions for Education
Trends
Machine Learning
Multiparadigm Data Science
Internet of Things
High-Performance Computing
Hackathons
Software & Web
Software Development
Authoring & Publishing
Interface Development
Web Development
Sciences
Astronomy
Biology
Chemistry
More...
All Solutions »
Learning & Support
Learning
Wolfram Language Documentation
Fast Introduction for Programmers
Wolfram U
Videos & Screencasts
Wolfram Language Introductory Book
Webinars & Training
Summer Programs
Books
Need Help?
Support FAQ
Wolfram Community
Contact Support
Premium Support
Premier Service
Technical Consulting
All Learning & Support »
Company
About
Company Background
Wolfram Blog
Events
Contact Us
Work with Us
Careers at Wolfram
Internships
Other Wolfram Language Jobs
Initiatives
Wolfram Foundation
MathWorld
Computer-Based Math
A New Kind of Science
Wolfram Technology for Hackathons
Student Ambassador Program
Wolfram for Startups
Demonstrations Project
Wolfram Innovator Awards
Wolfram + Raspberry Pi
Summer Programs
More...
All Company »
Search
Join
Sign In
Dashboard
Groups
People
Message Boards
Answer
(
Unmark
)
Mark as an Answer
GROUPS:
Image Processing
External Programs and Systems
Import and Export
Wolfram Language
Know-How
2
Shenghui Yang
Work with Julia Image Data in WL
Shenghui Yang, WOLFRAM
Posted
15 days ago
162 Views
|
0 Replies
|
2 Total Likes
Follow this post
|
Motivation
Some tips for image conversion and data serialization.
For anyone interested in image processing in both WL and Julia for
Introduction to Computational Thinking
18.S191 Fall 2020 course. Youtube Link
here
.
Prerequist
I install Julia-1.5.3 via homebrew on macOS for instance
$ brew install julia
Once installation is done I follow
this instruction
to install ZMQ and JSON in a terminal with Julia running. After they are installed, I can run
RegisterExternalEvaluator
to link Julia to WL
I
n
[
]
:
=
R
e
g
i
s
t
e
r
E
x
t
e
r
n
a
l
E
v
a
l
u
a
t
o
r
[
"
J
u
l
i
a
"
,
"
/
u
s
r
/
l
o
c
a
l
/
b
i
n
/
j
u
l
i
a
"
]
O
u
t
[
]
=
7
d
0
8
2
9
b
2
-
a
9
5
d
-
4
7
8
0
-
8
f
7
f
-
9
2
e
3
8
d
c
e
d
6
9
b
Verify registration
I
n
[
]
:
=
F
i
n
d
E
x
t
e
r
n
a
l
E
v
a
l
u
a
t
o
r
s
[
"
J
u
l
i
a
"
]
O
u
t
[
]
=
S
y
s
t
e
m
V
e
r
s
i
o
n
T
a
r
g
e
t
+
R
e
g
i
s
t
e
r
e
d
7
d
0
8
2
9
b
2
-
a
9
5
d
-
4
7
8
0
-
8
f
7
f
-
9
2
e
3
8
d
c
e
d
6
9
b
J
u
l
i
a
1
.
5
.
3
/
u
s
r
/
l
o
c
a
l
/
b
i
n
/
j
u
l
i
a
•
T
r
u
e
2
5
e
e
f
d
d
c
-
a
d
9
b
-
4
f
e
4
-
8
a
8
1
-
a
c
b
d
b
a
9
8
8
3
7
d
J
u
l
i
a
1
.
5
.
3
/
A
p
p
l
i
c
a
t
i
o
n
s
/
J
u
l
i
a
-
1
.
5
.
a
p
p
/
C
o
n
t
e
n
t
s
/
R
e
s
o
u
r
c
e
s
/
j
u
l
i
a
/
b
i
n
/
j
u
l
i
a
•
A
u
t
o
m
a
t
i
c
Check the version
〉
I
n
[
]
:
=
VERSION
O
u
t
[
]
=
m
a
j
o
r
1
,
m
i
n
o
r
5
,
p
a
t
c
h
3
,
p
r
e
r
e
l
e
a
s
e
{
}
,
b
u
i
l
d
{
}
Download extra packages
〉
Pkg.add("Images")
Pkg.add("QuartzImageIO")
Add the proper name space and modules before using Images package
〉
I
n
[
]
:
=
using Images
Check the current linked Julia session running on my machine
I
n
[
]
:
=
j
u
l
i
a
S
e
s
s
i
o
n
=
E
x
t
e
r
n
a
l
S
e
s
s
i
o
n
s
[
]
[
[
1
]
]
O
u
t
[
]
=
E
x
t
e
r
n
a
l
S
e
s
s
i
o
n
O
b
j
e
c
t
S
y
s
t
e
m
:
J
u
l
i
a
V
e
r
s
i
o
n
:
1
.
5
.
3
N
a
m
e
:
D
e
f
a
u
l
t
J
u
l
i
a
S
e
s
s
i
o
n
Import Image and Change Orientation
Sample input file from MIT computational thinking course 1.
〉
I
n
[
]
:
=
url = "https://i.imgur.com/VGPeJ6s.jpg"
download(url,"philip.jpg")
O
u
t
[
]
=
p
h
i
l
i
p
.
j
p
g
You can either import using Julia or WL. When I import image from Julia, I convert the image object to raw double array first with Julia’s
ImageCore.
channelview
function. If no conversion is specified, ZeroMQ will convert image pixel data into a very large list of millions lines of dictionary/association for JSON file, then WL imports the JSON file to display it with some format rearrangement. This data serialization-and-deserialization process take rather long time
I
n
[
]
:
=
i
m
g
D
a
t
a
J
u
l
i
a
=
E
x
t
e
r
n
a
l
E
v
a
l
u
a
t
e
[
j
u
l
i
a
S
e
s
s
i
o
n
,
"
i
m
g
=
l
o
a
d
(
\
"
p
h
i
l
i
p
.
j
p
g
\
"
)
;
c
h
a
n
n
e
l
v
i
e
w
(
i
m
g
)
"
]
;
I can save some notebook file size and improve response by rasterizing output image automatically with
$Post.
This only affect output. values in variables in imgJulia1 is intact
I
n
[
]
:
=
$
P
o
s
t
=
I
f
[
M
a
t
c
h
Q
[
#
,
_
I
m
a
g
e
|
_
B
y
t
e
A
r
r
a
y
|
_
N
u
m
e
r
i
c
A
r
r
a
y
]
,
R
a
s
t
e
r
i
z
e
[
#
,
R
a
s
t
e
r
S
i
z
e
3
0
0
]
,
#
]
&
O
u
t
[
]
=
I
f
[
M
a
t
c
h
Q
[
#
1
,
_
I
m
a
g
e
|
_
B
y
t
e
A
r
r
a
y
|
_
N
u
m
e
r
i
c
A
r
r
a
y
]
,
R
a
s
t
e
r
i
z
e
[
#
1
,
R
a
s
t
e
r
S
i
z
e
3
0
0
]
,
#
1
]
&
I
n
[
]
:
=
i
m
g
J
u
l
i
a
1
=
I
m
a
g
e
[
i
m
g
D
a
t
a
J
u
l
i
a
,
C
o
l
o
r
S
p
a
c
e
"
R
G
B
"
]
O
u
t
[
]
=
Notice that the convention is slightly different between WL and Julia. Comparing to what’s shown in the online video or direct import with WL code , Corgi’s head point downward instead of right.
I
n
[
]
:
=
i
m
g
W
L
=
I
m
p
o
r
t
[
"
h
t
t
p
s
:
/
/
i
.
i
m
g
u
r
.
c
o
m
/
V
G
P
e
J
6
s
.
j
p
g
"
]
O
u
t
[
]
=
I need to swap the first and second dimension of image data from Julia’s color channel multi-dimensional array
I
n
[
]
:
=
I
m
a
g
e
D
a
t
a
[
i
m
g
W
L
]
/
/
D
i
m
e
n
s
i
o
n
s
O
u
t
[
]
=
{
3
6
7
5
,
2
9
8
8
,
3
}
I
n
[
]
:
=
I
m
a
g
e
D
a
t
a
[
i
m
g
J
u
l
i
a
]
/
/
D
i
m
e
n
s
i
o
n
s
O
u
t
[
]
=
{
2
9
8
8
,
3
6
7
5
,
3
}
Now this is the image with correct orientation after transposition
I
n
[
]
:
=
i
m
g
J
u
l
i
a
2
=
I
m
a
g
e
[
T
r
a
n
s
p
o
s
e
[
i
m
g
D
a
t
a
J
u
l
i
a
,
{
2
,
1
,
3
}
]
,
C
o
l
o
r
S
p
a
c
e
"
R
G
B
"
]
O
u
t
[
]
=
Save and Share Large Array
High definition image is a large numeric array. I found the following function really useful in keep such data persistently on local machine and sharing across internet for data integrity purpose. WL automatically translate ImageData to packed array
I
n
[
]
:
=
D
e
v
e
l
o
p
e
r
`
P
a
c
k
e
d
A
r
r
a
y
Q
[
I
m
a
g
e
D
a
t
a
[
i
m
g
W
L
]
]
O
u
t
[
]
=
T
r
u
e
I can use NumericArray as well which also support functions like Take, Part or ListPlot
I
n
[
]
:
=
N
u
m
e
r
i
c
A
r
r
a
y
[
I
m
a
g
e
D
a
t
a
[
i
m
g
W
L
]
,
"
R
e
a
l
3
2
"
]
O
u
t
[
]
=
If I would like to save the data on disk or within notebook in a compact manner, either of function below works and I can export a WXF binary file later
I
n
[
]
:
=
b
i
n
=
B
i
n
a
r
y
S
e
r
i
a
l
i
z
e
[
I
m
a
g
e
D
a
t
a
[
i
m
g
W
L
]
,
P
e
r
f
o
r
m
a
n
c
e
G
o
a
l
"
S
i
z
e
"
,
M
e
t
h
o
d
{
"
P
a
c
k
e
d
A
r
r
a
y
R
e
a
l
T
y
p
e
"
"
R
e
a
l
3
2
"
}
]
O
u
t
[
]
=
Or
I
n
[
]
:
=
E
x
p
o
r
t
B
y
t
e
A
r
r
a
y
[
I
m
a
g
e
D
a
t
a
[
i
m
g
W
L
]
,
"
W
X
F
"
,
P
e
r
f
o
r
m
a
n
c
e
G
o
a
l
"
S
i
z
e
"
,
M
e
t
h
o
d
{
"
P
a
c
k
e
d
A
r
r
a
y
R
e
a
l
T
y
p
e
"
"
R
e
a
l
3
2
"
}
]
O
u
t
[
]
=
To save the ByteArray object, I just need to write them into a file
I
n
[
]
:
=
m
y
f
i
l
e
=
C
r
e
a
t
e
F
i
l
e
[
F
i
l
e
N
a
m
e
J
o
i
n
[
{
$
H
o
m
e
D
i
r
e
c
t
o
r
y
,
"
t
e
s
t
1
"
}
]
]
;
B
i
n
a
r
y
W
r
i
t
e
[
m
y
f
i
l
e
,
b
i
n
]
;
C
l
o
s
e
[
m
y
f
i
l
e
]
O
u
t
[
]
=
/
U
s
e
r
s
/
s
h
e
n
g
h
u
i
y
/
t
e
s
t
1
Import it again to check if the file is saved properly
I
n
[
]
:
=
I
m
p
o
r
t
[
m
y
f
i
l
e
]
/
/
I
m
a
g
e
O
u
t
[
]
=
Restore $Post to no definition so the front end no longer rasterize image output automatically
I
n
[
]
:
=
$
P
o
s
t
=
.
Summary
◼
Install Julia from your favorite repository and package management system
◼
Register Julia with WL and add required packages like ZMQ and JSON
◼
Transposition of Image data is needed between image process functions in both languages
POSTED BY:
Shenghui Yang
Answer
Mark as an Answer
Reply
|
Flag
Reply to this discussion
in reply to
Add Notebook
Community posts can be styled and formatted using the
Markdown syntax
.
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Publish anyway
Cancel
Reply Preview
Attachments
Remove
Add a file to this post
Follow this discussion
or
Discard
Group Abstract
Be respectful. Review our
Community Guidelines
to understand your role and responsibilities.
Community Terms of Use
Feedback
Enable JavaScript to interact with content and submit forms on Wolfram websites.
Learn how »