Skip to content

Commit b7ad33c

Browse files
committed
image tensors - wip
1 parent 67cede0 commit b7ad33c

1 file changed

Lines changed: 50 additions & 18 deletions

File tree

src/dtype_next/image_processing_with_tensors.clj

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
[tablecloth.api :as tc]
2121
[scicloj.tableplot.v1.plotly :as plotly]))
2222

23+
^:kindly/hide-code
24+
(kind/hiccup
25+
[:style
26+
".clay-dataset {
27+
max-height:400px;
28+
overflow-y: auto;
29+
}
30+
.printed-clojure {
31+
max-height:400px;
32+
overflow-y: auto;
33+
}
34+
"])
35+
2336
;; # Introduction: Why dtype-next for Image Processing?
2437

2538
;; Images are perfect for learning [dtype-next](https://github.com/cnuernber/dtype-next)
@@ -61,12 +74,14 @@
6174

6275
;; ## What We'll Build
6376

77+
;; - **Working with Tensors** — reshaping, dataset conversion, core operations
78+
;; - **Tensor Operations Primer** — slicing, element-wise ops, type handling
6479
;; - **Image Statistics** — channel means, ranges, distributions, histograms
6580
;; - **Spatial Analysis** — gradients, edge detection, sharpness metrics
6681
;; - **Enhancement Pipeline** — white balance, contrast adjustment
6782
;; - **Accessibility** — color blindness simulation
6883
;; - **Convolution & Filtering** — blur, sharpen, Sobel edge detection
69-
;; - **Reshape & Downsampling** — pyramids, multi-scale processing
84+
;; - **Downsampling & Multi-Scale Processing** — pyramids, multi-resolution analysis
7085

7186
;; Each section demonstrates core dtype-next concepts with immediate practical value.
7287

@@ -168,7 +183,8 @@ original-tensor
168183

169184
;; The [`tech.v3.dataset.tensor`](https://cnuernber.github.io/dtype-next/tech.v3.dataset.tensor.html)
170185
;; namespace provides conversions between tensors and datasets. The `tablecloth.api`
171-
;; namespace also auto-converts 2D tensors.
186+
;; namespace of [Tablecloth](https://scicloj.github.io/tablecloth/)
187+
;; also auto-converts 2D tensors.
172188

173189
;; Two-dimensional tensors convert naturally to tablecloth datasets, enabling
174190
;; tabular operations and plotting.
@@ -1066,7 +1082,8 @@ gaussian-5x5
10661082

10671083
;; Visualize each level:
10681084

1069-
(mapv bufimg/tensor->image gray-pyramid)
1085+
(kind/fragment
1086+
(mapv bufimg/tensor->image gray-pyramid))
10701087

10711088
;; **Use case**: Multi-scale edge detection for finding features at different sizes.
10721089

@@ -1126,21 +1143,36 @@ gaussian-5x5
11261143

11271144
;; ## API Coverage
11281145

1129-
;; | Function | Use Case |
1130-
;; |----------|----------|
1131-
;; | `dtype/shape` | Inspect tensor dimensions |
1132-
;; | `dtype/elemwise-datatype` | Check element type |
1133-
;; | `dtype/elemwise-cast` | Convert between types |
1134-
;; | `dtype/ecount` | Total element count |
1135-
;; | `tensor/select` | Extract slices, channels |
1136-
;; | `tensor/compute-tensor` | Functionally construct tensors |
1137-
;; | `tensor/mget` | Read single elements |
1138-
;; | `dfn/mean`, `dfn/standard-deviation` | Statistics |
1139-
;; | `dfn/reduce-min`, `dfn/reduce-max` | Range finding |
1140-
;; | `dfn/+`, `dfn/-`, `dfn/*`, `dfn//` | Element-wise arithmetic |
1141-
;; | `dfn/sqrt`, `dfn/sq` | Mathematical operations |
1142-
;; | `dfn/min`, `dfn/max` | Clamping |
1143-
;; | `dfn/sum` | Counting (boolean buffers) |
1146+
;; Here are the key dtype-next functions we used throughout this tutorial:
1147+
1148+
;; **dtype namespace (tech.v3.datatype):**
1149+
;; - `dtype/shape` — Inspect tensor dimensions
1150+
;; - `dtype/elemwise-datatype` — Check element type
1151+
;; - `dtype/elemwise-cast` — Convert between types
1152+
;; - `dtype/ecount` — Total element count
1153+
;; - `dtype/as-reader` — Convert to readable sequence
1154+
;; - `dtype/get-value` — Extract scalar value
1155+
1156+
;; **tensor namespace (tech.v3.tensor):**
1157+
;; - `tensor/compute-tensor` — Functionally construct tensors
1158+
;; - `tensor/select` — Extract slices, channels (zero-copy)
1159+
;; - `tensor/mget` — Read single elements
1160+
;; - `tensor/reshape` — Reinterpret tensor shape (zero-copy)
1161+
;; - `tensor/reduce-axis` — Reduce along specific dimension
1162+
1163+
;; **dfn namespace (tech.v3.datatype.functional):**
1164+
;; - `dfn/+`, `dfn/-`, `dfn/*`, `dfn//` — Element-wise arithmetic
1165+
;; - `dfn/mean`, `dfn/standard-deviation` — Statistics
1166+
;; - `dfn/reduce-min`, `dfn/reduce-max` — Range finding
1167+
;; - `dfn/sqrt`, `dfn/sq` — Mathematical operations
1168+
;; - `dfn/min`, `dfn/max` — Clamping
1169+
;; - `dfn/sum` — Summation
1170+
1171+
;; **bufimg namespace (tech.v3.libs.buffered-image):**
1172+
;; - `bufimg/load` — Load image file
1173+
;; - `bufimg/as-ubyte-tensor` — BufferedImage → tensor
1174+
;; - `bufimg/tensor->image` — tensor → BufferedImage
1175+
;; - `bufimg/image-type` — Check image format
11441176

11451177
;; ## What Makes This Functional?
11461178

0 commit comments

Comments
 (0)