Created
August 2, 2023 17:05
-
-
Save ashwani-rathee/4211eec75ebdc8becd31ac1c38f50a6b to your computer and use it in GitHub Desktop.
Pluto Interactivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.19.27 | |
using Markdown | |
using InteractiveUtils | |
# 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). | |
macro bind(def, element) | |
quote | |
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end | |
local el = $(esc(element)) | |
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) | |
el | |
end | |
end | |
# ╔═╡ 1ba1bac0-3151-11ee-050e-5f52eb517344 | |
using Pkg | |
# ╔═╡ ef88f808-b653-426f-ab45-8947216b04cd | |
Pkg.activate(".") | |
# ╔═╡ d4cd85a3-9630-4d95-8d6c-12a35ecbaf48 | |
using Images, FileIO, TestImages, PlutoUI | |
# ╔═╡ f9ce0f0f-b84f-4715-b353-ec368cad0828 | |
img = testimage("mandrill"); | |
# ╔═╡ b156b8e7-2cc9-4f30-8b09-636f49d191d1 | |
begin | |
x1 = @bind a Slider(1:5:512; default=1, show_value=true) | |
x2 = @bind b Slider(1:5:512; default=512, show_value=true) | |
y1 = @bind c Slider(1:5:512; default=1, show_value=true) | |
y2 = @bind d Slider(1:5:512; default=512, show_value=true) | |
color_img = @bind color Select([RGB, Gray, HSV, red, green, blue]) | |
x_size1 = @bind x_size Slider(1:5:512; default=512, show_value=true) | |
y_size1 = @bind y_size Slider(1:5:512; default=512, show_value=true) | |
rot_angle = @bind rot Slider(0:pi/30:2*pi; default=0, show_value=true) | |
md""" | |
**Image Cropping?** | |
| Start | End | Misc | | |
|:---------:|:---------:|:-----:| | |
| x1: $(x1) | x2: $(x2) | color: $(color_img) | | |
| y1: $(y1) | y2: $(y2) | r-xsize: $(x_size1) | | |
| | | r-ysize: $(y_size1) | | |
| | | rotate: $rot_angle) | | |
""" | |
end | |
# ╔═╡ 7610a2b1-9b62-4d53-bdbd-c60091c1ff95 | |
img_small = imrotate(imresize(color.(img[a:b, c:d]), (x_size,y_size)), rot) | |
# ╔═╡ Cell order: | |
# ╠═1ba1bac0-3151-11ee-050e-5f52eb517344 | |
# ╠═ef88f808-b653-426f-ab45-8947216b04cd | |
# ╠═d4cd85a3-9630-4d95-8d6c-12a35ecbaf48 | |
# ╠═f9ce0f0f-b84f-4715-b353-ec368cad0828 | |
# ╠═7610a2b1-9b62-4d53-bdbd-c60091c1ff95 | |
# ╟─b156b8e7-2cc9-4f30-8b09-636f49d191d1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment