Add image from my files

#1

I’m trying to load an image that I have on my computer, but I get this error … someone can audare me …

img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);

the image, this name is colibri.jpg

0 Likes

#2

This should work

using ImageView
img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);
imshow(img)
0 Likes

#3
julia> using ImageView

julia> img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg”);
ERROR: syntax: invalid character "“" near column 13

julia> img = load(“C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg");
ERROR: syntax: invalid character "“" near column 13

julia> img = load("C:\Users\gerso.julia\Imagenes_de_gerson\colibri.jpg");
ERROR: syntax: invalid escape sequence
0 Likes

#4

That’s look like some error in PATH. Just to make sure, go to the folder where the image is located

using ImageView

cd("C:\Users\gerso.julia\Imagenes_de_gerson")
# Confirm location 
pwd()
# Run again 
img = load("colibri.jpg")

See if that works.

0 Likes

#5

The problem is that discourse replaces the character " with the stylish “:

julia> '"'
'"': ASCII/Unicode U+0022 (category Po: Punctuation, other)

julia> '“'
'“': Unicode U+201c (category Pi: Punctuation, initial quote)

You need to replace it when copy pasting. A real misfeature of discourse…

0 Likes

#6

I think it is a nice feature. You just need to quote code with backticks.

0 Likes

#7

As you can see the first post had code quotes. I don’t know exactly how it happens but multiple times i have copied code and had to replace these quotes. Very annoying.

0 Likes

#8

I don’t think the OP used `s, that’s why when the second post copy-pasted the text (and quoted it), it ended up with s.

0 Likes

#9

I don’t really care how it happened, I just know it happens, and the annoyance it causes me far outweighs the pleasure of slightly curved quote characters.

2 Likes

#10
julia> using ImageView

julia> cd("C:\Users\gerso.julia\Imagenes_de_gerson")
ERROR: syntax: invalid escape sequence

julia> pwd
pwd (generic function with 1 method)

julia> img = load("colibri.jpg")
ERROR: UndefVarError: load not defined
Stacktrace:
 [1] top-level scope at none:0

julia>

0 Likes

#11

Probably you meant pwd(). And you may need to be using FileIO to get load.

0 Likes

#12

That’s good to know, I’ve never noticed that.

0 Likes

#13

You are on Windows. Need to escape the backslashs

cd("C:\\Users\\gerso.julia\\Imagenes_de_gerson")
0 Likes

#14

That’s why I use raw for something like this on Windows.

raw"C:\user\..."
0 Likes

#15

Simpler to use (works on Win too)

"c:/user/..."
1 Like

#16

True but I’ve used Windows for so long that \ is embedded in my brain!

However your approach is more portable.

0 Likes