You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/dtype_next/image_processing_with_tensors.clj
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@
42
42
;; because they're **typed numerical arrays with clear visual feedback**. Unlike generic
43
43
;; sequences where numbers are boxed, dtype-next gives us:
44
44
;;
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
46
46
;; - **Zero-copy views**: Slice channels, regions, or transforms without copying data
47
47
;; - **Functional operations**: Element-wise transformations that compose naturally
48
48
;; - **Type discipline**: Explicit control over precision and overflow
@@ -115,7 +115,7 @@ original-img
115
115
116
116
;; ## ⚠️ Important: Understanding Channel Order
117
117
;;
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
119
119
;; format depends on the image type and how it was loaded. Our image uses **BGR** order:
120
120
121
121
(bufimg/image-type original-img)
@@ -468,7 +468,7 @@ toy-cols
468
468
469
469
;; The [`tech.v3.datatype.functional`](https://cnuernber.github.io/dtype-next/tech.v3.datatype.functional.html)
470
470
;; 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.
472
472
473
473
;; **Element-wise operations:**
474
474
@@ -498,9 +498,9 @@ toy-cols
498
498
499
499
;; **Why dfn instead of regular Clojure functions?**
500
500
;; - Work on entire tensors efficiently (no boxing)
;; This is more efficient than calling individual functions like `dfn/mean`, `dfn/standard-deviation`, etc.,
583
583
;; when you need multiple statistics, as it computes them in a single pass over the data.
@@ -594,7 +594,7 @@ flat-tensor
594
594
(defnchannel-percentiles
595
595
"Compute percentiles for a single channel tensor.
596
596
Takes: [H W] tensor
597
-
Returns: map with percentiles"
597
+
Returns: map with percentiles ([percentile](https://en.wikipedia.org/wiki/Percentile))"
598
598
[channel]
599
599
(zipmap [:q25:median:q75]
600
600
(dfn/percentiles channel [255075])))
@@ -616,7 +616,7 @@ flat-tensor
616
616
;; Convert to grayscale using perceptual luminance formula.
617
617
;;
618
618
;; **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)
620
620
;; (0.299, 0.587, 0.114) approximate the [relative luminance](https://en.wikipedia.org/wiki/Relative_luminance)
621
621
;; formula from the [ITU-R BT.601](https://en.wikipedia.org/wiki/Rec._601) standard,
622
622
;; ensuring grayscale images preserve perceived brightness rather than simple
@@ -652,8 +652,8 @@ flat-tensor
652
652
;; ## Histograms
653
653
654
654
;; 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).
657
657
658
658
;; **Approach 1**: Overlaid BGR channels using the reshape→dataset pattern we just learned:
659
659
@@ -699,7 +699,7 @@ flat-tensor
699
699
700
700
;; ## Computing Gradients
701
701
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
703
703
;; comparing neighboring pixels using **slice offsets**.
704
704
705
705
(defngradient-x
@@ -762,7 +762,7 @@ edges
762
762
763
763
;; ## Sharpness Metric
764
764
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:
0 commit comments