Skip to content

Commit 2970bbf

Browse files
committed
tensor images - added wikipedia links
1 parent 3261758 commit 2970bbf

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/dtype_next/image_processing_with_tensors.clj

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
;; because they're **typed numerical arrays with clear visual feedback**. Unlike generic
4343
;; sequences where numbers are boxed, dtype-next gives us:
4444
;;
45-
;; - **Efficient storage**: A 1000×1000 RGB image is 3MB of uint8 values, not 12MB+ of boxed objects
45+
;; - **Efficient storage**: A 1000×1000 [RGB](https://en.wikipedia.org/wiki/RGB_color_model) image is 3MB of [uint8](https://en.wikipedia.org/wiki/Integer_(computer_science)#Value_and_representation) values, not 12MB+ of [boxed](https://en.wikipedia.org/wiki/Object_type_(object-oriented_programming)#Boxing) objects
4646
;; - **Zero-copy views**: Slice channels, regions, or transforms without copying data
4747
;; - **Functional operations**: Element-wise transformations that compose naturally
4848
;; - **Type discipline**: Explicit control over precision and overflow
@@ -115,7 +115,7 @@ original-img
115115

116116
;; ## ⚠️ Important: Understanding Channel Order
117117
;;
118-
;; BufferedImage can use different pixel formats (RGB, BGR, ARGB, etc.). The specific
118+
;; BufferedImage can use different [pixel](https://en.wikipedia.org/wiki/Pixel) formats (RGB, BGR, ARGB, etc.). The specific
119119
;; format depends on the image type and how it was loaded. Our image uses **BGR** order:
120120

121121
(bufimg/image-type original-img)
@@ -468,7 +468,7 @@ toy-cols
468468

469469
;; The [`tech.v3.datatype.functional`](https://cnuernber.github.io/dtype-next/tech.v3.datatype.functional.html)
470470
;; namespace (aliased as `dfn`) provides mathematical operations that work **element-wise**
471-
;; across entire tensors and automatically **broadcast** when combining tensors of different shapes.
471+
;; across entire tensors and automatically **[broadcast](https://en.wikipedia.org/wiki/Broadcasting_(parallel_pattern))** when combining tensors of different shapes.
472472

473473
;; **Element-wise operations:**
474474

@@ -498,9 +498,9 @@ toy-cols
498498

499499
;; **Why dfn instead of regular Clojure functions?**
500500
;; - Work on entire tensors efficiently (no boxing)
501-
;; - Broadcast automatically
501+
;; - [Broadcast](https://en.wikipedia.org/wiki/Broadcasting_(parallel_pattern)) automatically
502502
;; - Type-aware (preserve numeric precision)
503-
;; - SIMD-optimized
503+
;; - [SIMD](https://en.wikipedia.org/wiki/Single_instruction,_multiple_data)-optimized
504504

505505
;; ## Type Handling: dtype/elemwise-cast
506506

@@ -577,7 +577,7 @@ flat-tensor
577577
;; namespace provides statistical functions optimized for typed arrays.
578578
;;
579579
;; Key function:
580-
;; - `stats/descriptive-statistics` — returns `:n-elems`, `:min`, `:max`, `:mean`, and `:standard-deviation`
580+
;; - `stats/descriptive-statistics` — returns `:n-elems`, `:min`, `:max`, `:mean`, and `:standard-deviation` ([standard deviation](https://en.wikipedia.org/wiki/Standard_deviation))
581581
;;
582582
;; This is more efficient than calling individual functions like `dfn/mean`, `dfn/standard-deviation`, etc.,
583583
;; when you need multiple statistics, as it computes them in a single pass over the data.
@@ -594,7 +594,7 @@ flat-tensor
594594
(defn channel-percentiles
595595
"Compute percentiles for a single channel tensor.
596596
Takes: [H W] tensor
597-
Returns: map with percentiles"
597+
Returns: map with percentiles ([percentile](https://en.wikipedia.org/wiki/Percentile))"
598598
[channel]
599599
(zipmap [:q25 :median :q75]
600600
(dfn/percentiles channel [25 50 75])))
@@ -616,7 +616,7 @@ flat-tensor
616616
;; Convert to grayscale using perceptual luminance formula.
617617
;;
618618
;; **Why these specific weights?** Human vision is most sensitive to green light,
619-
;; moderately sensitive to red, and least sensitive to blue. The coefficients
619+
;; moderately sensitive to red, and least sensitive to blue. The [coefficients](https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale)
620620
;; (0.299, 0.587, 0.114) approximate the [relative luminance](https://en.wikipedia.org/wiki/Relative_luminance)
621621
;; formula from the [ITU-R BT.601](https://en.wikipedia.org/wiki/Rec._601) standard,
622622
;; ensuring grayscale images preserve perceived brightness rather than simple
@@ -652,8 +652,8 @@ flat-tensor
652652
;; ## Histograms
653653

654654
;; A [histogram](https://en.wikipedia.org/wiki/Image_histogram) shows the distribution
655-
;; of pixel values. It's essential for understanding image brightness, contrast, and
656-
;; exposure. Peaks indicate common values; spread indicates dynamic range.
655+
;; of pixel values. It's essential for understanding image [brightness](https://en.wikipedia.org/wiki/Brightness), [contrast](https://en.wikipedia.org/wiki/Contrast_(vision)), and
656+
;; [exposure](https://en.wikipedia.org/wiki/Exposure_(photography)). Peaks indicate common values; spread indicates [dynamic range](https://en.wikipedia.org/wiki/Dynamic_range).
657657

658658
;; **Approach 1**: Overlaid BGR channels using the reshape→dataset pattern we just learned:
659659

@@ -699,7 +699,7 @@ flat-tensor
699699

700700
;; ## Computing Gradients
701701

702-
;; Gradients measure how quickly pixel values change. We compute them by
702+
;; [Gradients](https://en.wikipedia.org/wiki/Image_gradient) measure how quickly pixel values change. We compute them by
703703
;; comparing neighboring pixels using **slice offsets**.
704704

705705
(defn gradient-x
@@ -762,7 +762,7 @@ edges
762762

763763
;; ## Sharpness Metric
764764

765-
;; Measure image sharpness by averaging edge magnitude—higher = sharper:
765+
;; Measure image [sharpness](https://en.wikipedia.org/wiki/Acutance) by averaging edge magnitude—higher = sharper:
766766

767767
(defn sharpness-score
768768
"Compute sharpness as mean edge magnitude.
@@ -869,7 +869,7 @@ edges
869869
:=y :col-brightness
870870
:=mark-color "coral"}))
871871

872-
;; **Use case**: Detect vignetting, find composition center, identify vertical features.
872+
;; **Use case**: Detect [vignetting](https://en.wikipedia.org/wiki/Vignetting), find composition center, identify vertical features.
873873

874874
;; ## Efficient Aggregation with reduce-axis
875875

@@ -1055,7 +1055,7 @@ edges
10551055
;; Beyond enhancement, images need to be *accessible*. Let's simulate how images
10561056
;; appear to people with different types of color vision deficiency.
10571057
;;
1058-
;; This demonstrates dtype-next's linear algebra capabilities (applying 3×3 matrices
1058+
;; This demonstrates dtype-next's [linear algebra](https://en.wikipedia.org/wiki/Linear_algebra) capabilities (applying 3×3 matrices
10591059
;; to BGR channels) with practical real-world applications.
10601060

10611061
;; Apply 3×3 transformation matrices to simulate different types of color vision deficiency.
@@ -1170,7 +1170,7 @@ edges
11701170

11711171
;; ### Box Blur Example
11721172

1173-
;; Box blur averages all pixels in a neighborhood. A 3×3 box blur kernel weights
1173+
;; [Box blur](https://en.wikipedia.org/wiki/Box_blur) averages all pixels in a neighborhood. A 3×3 box blur kernel weights
11741174
;; all 9 pixels equally:
11751175

11761176
(defn box-blur-kernel
@@ -1277,7 +1277,7 @@ kernel-3x3
12771277
;; - N×M = image dimensions (height × width)
12781278
;; - Total work for image: O(N×M×k²) vs O(N×M×k)
12791279
;;
1280-
;; **Additional optimizations**: Library functions like `convolve/gaussian1d` may use FFT
1280+
;; **Additional optimizations**: Library functions like `convolve/gaussian1d` may use [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform)
12811281
;; (Fast Fourier Transform) for very large kernels or data, which can be even faster:
12821282
;; O(N×M×log(N×M)) regardless of kernel size. This happens automatically based on data size.
12831283

@@ -1443,7 +1443,7 @@ kernel-3x3
14431443

14441444
;; The [Sobel operator](https://en.wikipedia.org/wiki/Sobel_operator) is a classic
14451445
;; edge detection method that uses specialized kernels to compute gradients in X and Y
1446-
;; directions. It's more robust to noise than simple finite differences.
1446+
;; directions. It's more robust to noise than simple [finite differences](https://en.wikipedia.org/wiki/Finite_difference).
14471447

14481448
;; Sobel kernels detect edges in X and Y directions:
14491449

@@ -1497,7 +1497,7 @@ kernel-3x3
14971497

14981498
;; # Downsampling & Multi-Scale Processing
14991499

1500-
;; Finally, let's explore working with images at multiple scales. Downsampling
1500+
;; Finally, let's explore working with images at multiple scales. [Downsampling](https://en.wikipedia.org/wiki/Downsampling_(signal_processing))
15011501
;; reduces resolution for faster processing or multi-scale analysis (like detecting
15021502
;; features at different sizes).
15031503
;;
@@ -1507,7 +1507,7 @@ kernel-3x3
15071507
;; ## Downsampling by 2×
15081508

15091509
;; [Downsampling](https://en.wikipedia.org/wiki/Downsampling_(signal_processing))
1510-
;; (decimation) reduces image resolution by discarding pixels. We select every other
1510+
;; ([decimation](https://en.wikipedia.org/wiki/Decimation_(signal_processing))) reduces image resolution by discarding pixels. We select every other
15111511
;; pixel in each dimension, creating a half-size image.
15121512

15131513
(defn downsample-2x
@@ -1605,7 +1605,7 @@ kernel-3x3
16051605

16061606
;; Both are grayscale. `tensor->image` handles float32 → uint8 conversion automatically.
16071607

1608-
;; Average downsampling produces smoother results with less aliasing.
1608+
;; Average downsampling produces smoother results with less [aliasing](https://en.wikipedia.org/wiki/Aliasing).
16091609

16101610
;; **Verification**: Both produce same shape, but averaging reduces noise
16111611

0 commit comments

Comments
 (0)