2222
2323; ; # Introduction: Why dtype-next for Image Processing?
2424
25- ; ; Images are perfect for learning dtype-next because they're **typed numerical
26- ; ; arrays with clear visual feedback**. Unlike generic sequences where numbers
27- ; ; are boxed, dtype-next gives us:
25+ ; ; Images are perfect for learning [ dtype-next](https://github.com/cnuernber/dtype-next)
26+ ; ; because they're **typed numerical arrays with clear visual feedback**. Unlike generic
27+ ; ; sequences where numbers are boxed, dtype-next gives us:
2828; ;
2929; ; - **Efficient storage**: A 1000×1000 RGB image is 3MB of uint8 values, not 12MB+ of boxed objects
3030; ; - **Zero-copy views**: Slice channels, regions, or transforms without copying data
5050
5151; ; ## About This Tutorial
5252
53- ; ; [dtype-next](https://github.com/cnuernber/dtype-next) is a comprehensive library
54- ; ; for working with typed arrays, including buffers, functional operations, tensors,
55- ; ; and dataset integration. This tutorial focuses on **the tensor API**—multi-dimensional
56- ; ; views over typed buffers—because images provide clear visual feedback and natural
57- ; ; multi-dimensional structure.
53+ ; ; dtype-next is a comprehensive library for working with typed arrays, including buffers,
54+ ; ; functional operations, tensors, and dataset integration. This tutorial focuses on
55+ ; ; **the tensor API**—multi-dimensional views over typed buffers—because images provide
56+ ; ; clear visual feedback and natural multi-dimensional structure.
5857; ;
5958; ; The patterns you'll learn (zero-copy views, type discipline, functional composition)
6059; ; transfer directly to other dtype-next use cases: time series analysis, scientific
7978
8079; ; ## The bufimg Namespace
8180
82- ; ; The `tech.v3.libs.buffered-image` namespace (aliased as `bufimg`) provides
83- ; ; interop between Java's BufferedImage and dtype-next tensors:
81+ (require '[tech.v3.libs.buffered-image :as bufimg])
82+
83+ ; ; The [`tech.v3.libs.buffered-image`](https://cnuernber.github.io/dtype-next/tech.v3.libs.buffered-image.html)
84+ ; ; namespace (aliased as `bufimg`) provides interop between Java's BufferedImage and dtype-next tensors:
8485; ;
8586; ; - `bufimg/load` — load image file → BufferedImage
8687; ; - `bufimg/as-ubyte-tensor` — BufferedImage → uint8 tensor [H W C]
@@ -98,6 +99,11 @@ original-tensor
9899
99100; ; ## Understanding Tensor Shape
100101
102+ (require '[tech.v3.datatype :as dtype])
103+
104+ ; ; The [`tech.v3.datatype`](https://cnuernber.github.io/dtype-next/tech.v3.datatype.html)
105+ ; ; namespace provides core functions for inspecting and manipulating typed data.
106+
101107; ; **Shape** tells us dimensions:
102108
103109(dtype/shape original-tensor)
@@ -157,11 +163,18 @@ original-tensor
157163
158164; ; ## Tensors as Datasets
159165
166+ (require '[tech.v3.dataset.tensor :as ds-tensor])
167+ (require '[tablecloth.api :as tc])
168+
169+ ; ; The [`tech.v3.dataset.tensor`](https://cnuernber.github.io/dtype-next/tech.v3.dataset.tensor.html)
170+ ; ; namespace provides conversions between tensors and datasets. The `tablecloth.api`
171+ ; ; namespace also auto-converts 2D tensors.
172+
160173; ; Two-dimensional tensors convert naturally to tablecloth datasets, enabling
161174; ; tabular operations and plotting.
162175
163176; ; **Converting tensors ↔ datasets:**
164- ; ; - `ds-tensor/tensor->dataset` — explicit conversion (tech.v3.dataset.tensor)
177+ ; ; - `ds-tensor/tensor->dataset` — explicit conversion
165178; ; - `tc/dataset` — tablecloth auto-converts 2D tensors
166179; ; - `ds-tensor/dataset->tensor` — convert back to tensor
167180
@@ -198,6 +211,11 @@ original-tensor
198211
199212; ; ## Creating Tensors: tensor/compute-tensor
200213
214+ (require '[tech.v3.tensor :as tensor])
215+
216+ ; ; The [`tech.v3.tensor`](https://cnuernber.github.io/dtype-next/tech.v3.tensor.html)
217+ ; ; namespace provides multi-dimensional array operations.
218+
201219; ; `tensor/compute-tensor` creates a tensor by calling a function for each position.
202220; ; The function receives indices and returns the value for that position.
203221
@@ -257,9 +275,11 @@ toy-tensor
257275
258276; ; ## The dfn Namespace: Functional Operations with Broadcasting
259277
260- ; ; The `tech.v3.datatype.functional` (aliased as `dfn`) namespace provides
261- ; ; mathematical operations that work **element-wise** across entire tensors
262- ; ; and automatically **broadcast** when combining tensors of different shapes.
278+ (require '[tech.v3.datatype.functional :as dfn])
279+
280+ ; ; The [`tech.v3.datatype.functional`](https://cnuernber.github.io/dtype-next/tech.v3.datatype.functional.html)
281+ ; ; namespace (aliased as `dfn`) provides mathematical operations that work **element-wise**
282+ ; ; across entire tensors and automatically **broadcast** when combining tensors of different shapes.
263283
264284; ; **Element-wise operations:**
265285
@@ -445,6 +465,12 @@ flat-tensor
445465
446466; ; **Approach 2**: Separate histograms using `dtype/as-reader` for direct tensor access:
447467
468+ (require '[scicloj.kindly.v4.kind :as kind])
469+ (require '[scicloj.tableplot.v1.plotly :as plotly])
470+
471+ ; ; The `scicloj.kindly.v4.kind` namespace provides visualization directives for Clay.
472+ ; ; The `scicloj.tableplot.v1.plotly` namespace enables Plotly-based charting.
473+
448474(->> (assoc channels :gray grayscale)
449475 (map (fn [[k v]]
450476 (-> (tc/dataset {:x (dtype/as-reader v)})
0 commit comments