Skip to content

Commit 93a2262

Browse files
MendeBadrafonsp
andauthored
fix the persistence of memory wiki link (#151)
* fix the persistence of memory wiki link * make it flexible --------- Co-authored-by: Fons van der Plas <fonsvdplas@gmail.com>
1 parent 581bda1 commit 93a2262

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/images_abstractions/seamcarving.jl

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.45
2+
# v0.20.5
33

44
#> [frontmatter]
55
#> chapter = 1
@@ -18,12 +18,14 @@ using InteractiveUtils
1818

1919
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
2020
macro bind(def, element)
21-
quote
21+
#! format: off
22+
return quote
2223
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
2324
local el = $(esc(element))
2425
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
2526
el
2627
end
28+
#! format: on
2729
end
2830

2931
# ╔═╡ 405a4f82-8116-11eb-1b35-2563b06b02a7
@@ -82,7 +84,11 @@ md"""
8284

8385
# ╔═╡ 3721e7f9-83fa-48cd-a1f5-e72e07b0f7a2
8486
image_urls = [
85-
"https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg",
87+
# it will try to get one of these images, top to bottom.
88+
# Comment out lines from the top to get another image
89+
"https://github.com/user-attachments/assets/605b1894-2e18-48a0-b02b-4fb2741ddc02",
90+
"https://www.singulart.com/blog/wp-content/uploads/2023/12/The-Persistence-of-Memory.jpg",
91+
"https://upload.wikimedia.org/wikipedia/en/d/dd/The_Persistence_of_Memory.jpg",
8692

8793
"https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Gustave_Caillebotte_-_Paris_Street%3B_Rainy_Day_-_Google_Art_Project.jpg/1014px-Gustave_Caillebotte_-_Paris_Street%3B_Rainy_Day_-_Google_Art_Project.jpg",
8894

@@ -97,11 +103,13 @@ image_urls = [
97103
"https://web.mit.edu/facilities/photos/construction/Projects/stata/1_large.jpg",
98104
]
99105

100-
# ╔═╡ 90f44be8-f35c-11ea-2fc6-c361fd4966af
101-
image_url = image_urls[1]
102-
103106
# ╔═╡ d2ae6dd2-eef9-11ea-02df-255ec3b46a36
104-
img = load(download(image_url))
107+
img = (() -> for u in image_urls
108+
try
109+
return load(download(u))
110+
catch
111+
end
112+
end)()
105113

106114
# ╔═╡ 0b6010a8-eef6-11ea-3ad6-c1f10e30a413
107115
# arbitrarily choose the brightness of a pixel as mean of rgb
@@ -254,12 +262,15 @@ let
254262
∇y = convolve(brightness.(img), Sy)
255263
∇x = convolve(brightness.(img), Sx)
256264

265+
# clock coordinate
266+
cc = round(Int, size(img, 1) * 0.45)
267+
257268
data = [
258269
md"``G_x``", md"``G_y``",
259270

260271
# zoom in on the clock
261-
img[300:end, 1:300], img[300:end, 1:300],
262-
show_colored_array.((∇x[300:end, 1:300], ∇y[300:end, 1:300]))...
272+
img[cc:end, 1:cc], img[cc:end, 1:cc],
273+
show_colored_array.((∇x[cc:end, 1:cc], ∇y[cc:end, 1:cc]))...
263274
]
264275

265276
# avoid collating the images into one big matrix

0 commit comments

Comments
 (0)