From 95ee230d55d4f05fc8e605c865272ad257bb7af5 Mon Sep 17 00:00:00 2001 From: Troy Sornson Date: Fri, 1 Mar 2024 22:13:21 -0700 Subject: [PATCH] Regen docs --- docs/404.html | 4 +- docs/CrImage.html | 26 +- docs/CrImage/BlackView.html | 29 ++- docs/CrImage/ChannelType.html | 40 +-- docs/CrImage/Color.html | 46 ++-- docs/CrImage/ComplexMap.html | 125 +++++----- docs/CrImage/EdgePolicy.html | 34 ++- docs/CrImage/ErrorView.html | 29 ++- docs/CrImage/Exception.html | 33 ++- docs/CrImage/FftUtil.html | 34 +-- docs/CrImage/FloatMap.html | 115 +++++---- docs/CrImage/Format.html | 10 +- docs/CrImage/Format/JPEG.html | 18 +- docs/CrImage/Format/Open.html | 18 +- docs/CrImage/Format/PNG.html | 25 +- docs/CrImage/Format/PPM.html | 18 +- docs/CrImage/Format/Save.html | 18 +- docs/CrImage/Format/WebP.html | 18 +- docs/CrImage/GrayscaleImage.html | 229 ++++++++++++------ docs/CrImage/GrayscaleImage/Pixel.html | 31 ++- docs/CrImage/Image.html | 128 +++++----- docs/CrImage/IntMap.html | 115 +++++---- docs/CrImage/Map.html | 32 +-- docs/CrImage/MapImpl.html | 110 +++++---- docs/CrImage/Mask.html | 111 +++++---- docs/CrImage/NumericMap.html | 35 +-- docs/CrImage/OneMap.html | 57 +++-- docs/CrImage/Operation.html | 10 +- docs/CrImage/Operation/BilinearResize.html | 20 +- docs/CrImage/Operation/BoxBlur.html | 20 +- docs/CrImage/Operation/Brightness.html | 20 +- docs/CrImage/Operation/ChannelSwap.html | 20 +- docs/CrImage/Operation/Contrast.html | 20 +- docs/CrImage/Operation/Crop.html | 26 +- docs/CrImage/Operation/Draw.html | 36 +-- docs/CrImage/Operation/GaussianBlur.html | 20 +- docs/CrImage/Operation/HistogramEqualize.html | 22 +- .../HistogramEqualize/Histogram.html | 40 +-- docs/CrImage/Operation/HorizontalBlur.html | 20 +- docs/CrImage/Operation/MaskApply.html | 28 +-- docs/CrImage/Operation/Pad.html | 20 +- docs/CrImage/Operation/Rotate.html | 20 +- docs/CrImage/Operation/VerticalBlur.html | 20 +- docs/CrImage/RGBAImage.html | 185 +++++++++----- docs/CrImage/Region.html | 39 +-- docs/CrImage/RepeatView.html | 29 ++- docs/CrImage/UInt8Map.html | 97 ++++---- docs/CrImage/Window.html | 48 ++-- docs/Pluto.html | 10 +- docs/Pluto/ImageGA.html | 62 ++++- docs/Pluto/ImageRGBA.html | 62 ++++- docs/StumpyCore.html | 26 +- docs/StumpyCore/Canvas.html | 26 +- docs/Tutorial.html | 8 +- docs/Tutorial/ChromaKey.html | 8 +- docs/Tutorial/EdgeDetection.html | 8 +- docs/Tutorial/FindDifferences.html | 8 +- docs/css/style.css | 45 +++- docs/index.html | 8 +- docs/index.json | 2 +- docs/search-index.js | 2 +- 61 files changed, 1499 insertions(+), 1024 deletions(-) diff --git a/docs/404.html b/docs/404.html index bd0b7f1..260b8fd 100644 --- a/docs/404.html +++ b/docs/404.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ diff --git a/docs/CrImage.html b/docs/CrImage.html index 035af15..8cd21da 100644 --- a/docs/CrImage.html +++ b/docs/CrImage.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -428,77 +428,77 @@

- + cr-image.cr
- + cr-image/edge_policy.cr
- + cr-image/map.cr
- + cr-image/operation/bilinear_resize.cr
- + cr-image/region.cr
- + cr-image/window_view.cr
- + lib-formats/bindings/lib_jpeg_turbo.cr
- + lib-formats/bindings/lib_spng.cr
- + lib-formats/bindings/lib_webp.cr
- + pluto.cr
- + stumpy.cr diff --git a/docs/CrImage/BlackView.html b/docs/CrImage/BlackView.html index e2de356..7902b11 100644 --- a/docs/CrImage/BlackView.html +++ b/docs/CrImage/BlackView.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::BlackView(T) + class CrImage::BlackView(T)

@@ -430,7 +430,7 @@

- + cr-image/window_view.cr @@ -462,6 +462,8 @@

+ +

- -

@@ -616,6 +625,8 @@

+ +


- - diff --git a/docs/CrImage/ChannelType.html b/docs/CrImage/ChannelType.html index 952ebac..991892a 100644 --- a/docs/CrImage/ChannelType.html +++ b/docs/CrImage/ChannelType.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- enum CrImage::ChannelType + enum CrImage::ChannelType

@@ -429,7 +429,7 @@

- + cr-image/channel_type.cr @@ -483,6 +483,8 @@

+ +

- - @@ -614,7 +628,7 @@


@@ -630,7 +644,7 @@


@@ -646,7 +660,7 @@


@@ -662,7 +676,7 @@


@@ -678,15 +692,13 @@


- - diff --git a/docs/CrImage/Color.html b/docs/CrImage/Color.html index 02c5262..08fab05 100644 --- a/docs/CrImage/Color.html +++ b/docs/CrImage/Color.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::Color + class CrImage::Color

@@ -432,7 +432,7 @@

- + cr-image/color.cr @@ -483,6 +483,8 @@

+ +

- - @@ -604,7 +610,7 @@


@@ -631,7 +637,7 @@


@@ -652,7 +658,7 @@


@@ -662,6 +668,8 @@

+ +


@@ -703,7 +711,7 @@


@@ -719,7 +727,7 @@


@@ -735,7 +743,7 @@


@@ -751,7 +759,7 @@


@@ -772,7 +780,7 @@


@@ -788,7 +796,7 @@


@@ -804,15 +812,13 @@


- - diff --git a/docs/CrImage/ComplexMap.html b/docs/CrImage/ComplexMap.html index 4f0295d..20a66e1 100644 --- a/docs/CrImage/ComplexMap.html +++ b/docs/CrImage/ComplexMap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::ComplexMap + class CrImage::ComplexMap

@@ -433,7 +433,7 @@

- + cr-image/map.cr @@ -448,6 +448,25 @@

+

+ + + + Macro Summary +

+ + + +

-

- - - - Macro Summary -

- - - - @@ -848,7 +891,7 @@


@@ -864,7 +907,7 @@


@@ -880,35 +923,7 @@


- [View source] - -
- - - - - -

- - - - Macro Detail -

- -
-
- - macro method_missing(call) - - # -
- -
-
diff --git a/docs/CrImage/EdgePolicy.html b/docs/CrImage/EdgePolicy.html index 183fa6b..ef7db75 100644 --- a/docs/CrImage/EdgePolicy.html +++ b/docs/CrImage/EdgePolicy.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- enum CrImage::EdgePolicy + enum CrImage::EdgePolicy

@@ -428,7 +428,7 @@

- + cr-image/edge_policy.cr @@ -472,6 +472,8 @@

+ +

- - @@ -588,7 +602,7 @@


@@ -604,15 +618,13 @@


- - diff --git a/docs/CrImage/ErrorView.html b/docs/CrImage/ErrorView.html index 9cf305c..bb3bb06 100644 --- a/docs/CrImage/ErrorView.html +++ b/docs/CrImage/ErrorView.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::ErrorView(T) + class CrImage::ErrorView(T)

@@ -430,7 +430,7 @@

- + cr-image/window_view.cr @@ -462,6 +462,8 @@

+ +

- -

@@ -616,6 +625,8 @@

+ +


- - diff --git a/docs/CrImage/Exception.html b/docs/CrImage/Exception.html index ef919c6..9decfa5 100644 --- a/docs/CrImage/Exception.html +++ b/docs/CrImage/Exception.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::Exception + class CrImage::Exception

@@ -430,7 +430,7 @@

- + cr-image/exception.cr @@ -472,6 +472,8 @@

+ +

- - @@ -564,7 +573,7 @@


@@ -580,7 +589,7 @@


@@ -590,6 +599,8 @@

+ +


- - diff --git a/docs/CrImage/FftUtil.html b/docs/CrImage/FftUtil.html index e61760f..313840a 100644 --- a/docs/CrImage/FftUtil.html +++ b/docs/CrImage/FftUtil.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::FftUtil + class CrImage::FftUtil

@@ -431,7 +431,7 @@

- + cr-image/fft_util.cr @@ -541,12 +541,18 @@

+ + + + + + @@ -583,7 +589,7 @@


@@ -605,7 +611,7 @@


@@ -627,7 +633,7 @@


@@ -649,7 +655,7 @@


@@ -671,7 +677,7 @@


@@ -693,7 +699,7 @@


@@ -715,7 +721,7 @@


@@ -737,7 +743,7 @@


@@ -759,7 +765,7 @@


@@ -775,7 +781,7 @@


diff --git a/docs/CrImage/FloatMap.html b/docs/CrImage/FloatMap.html index 8f0b2e9..1e5dfec 100644 --- a/docs/CrImage/FloatMap.html +++ b/docs/CrImage/FloatMap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::FloatMap + class CrImage::FloatMap

@@ -444,7 +444,7 @@

- + cr-image/map.cr @@ -460,27 +460,17 @@

- + - Instance Method Summary + Macro Summary

diff --git a/docs/CrImage/GrayscaleImage.html b/docs/CrImage/GrayscaleImage.html index cd9c86e..e6415f6 100644 --- a/docs/CrImage/GrayscaleImage.html +++ b/docs/CrImage/GrayscaleImage.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::GrayscaleImage + class CrImage::GrayscaleImage

@@ -499,42 +499,42 @@

- + cr-image/grayscale_image.cr
- + jpeg.cr
- + pluto.cr
- + png.cr
- + stumpy.cr
- + webp.cr @@ -643,6 +643,8 @@

+ +

- - @@ -1683,7 +1758,7 @@


@@ -1704,7 +1779,7 @@


@@ -1725,7 +1800,7 @@


@@ -1735,6 +1810,8 @@

+ +


@@ -1771,7 +1848,7 @@


@@ -1787,7 +1864,7 @@


@@ -1812,7 +1889,7 @@


@@ -1828,7 +1905,7 @@


@@ -1844,7 +1921,7 @@


@@ -1860,7 +1937,7 @@


@@ -1881,7 +1958,7 @@


@@ -1902,7 +1979,7 @@


@@ -1926,7 +2003,7 @@


@@ -1947,7 +2024,7 @@


@@ -1963,7 +2040,7 @@


@@ -1984,7 +2061,7 @@


@@ -2005,7 +2082,7 @@


@@ -2021,7 +2098,7 @@


@@ -2037,7 +2114,7 @@


@@ -2053,7 +2130,7 @@


@@ -2069,7 +2146,7 @@


@@ -2090,7 +2167,7 @@


@@ -2111,7 +2188,7 @@


@@ -2127,7 +2204,7 @@


@@ -2143,7 +2220,7 @@


@@ -2164,7 +2241,7 @@


@@ -2189,7 +2266,7 @@


@@ -2205,7 +2282,7 @@


@@ -2229,7 +2306,7 @@


@@ -2253,7 +2330,7 @@


@@ -2269,7 +2346,7 @@


@@ -2285,7 +2362,7 @@


@@ -2301,7 +2378,7 @@


@@ -2317,7 +2394,7 @@


@@ -2338,7 +2415,7 @@


@@ -2359,7 +2436,7 @@


@@ -2388,7 +2465,7 @@


@@ -2409,7 +2486,7 @@


@@ -2430,7 +2507,7 @@


@@ -2451,7 +2528,7 @@


@@ -2472,7 +2549,7 @@


@@ -2488,7 +2565,7 @@


@@ -2516,7 +2593,7 @@


@@ -2538,7 +2615,7 @@


@@ -2554,7 +2631,7 @@


@@ -2579,7 +2656,7 @@


@@ -2595,15 +2672,13 @@


- - diff --git a/docs/CrImage/GrayscaleImage/Pixel.html b/docs/CrImage/GrayscaleImage/Pixel.html index 7b46974..5f08f92 100644 --- a/docs/CrImage/GrayscaleImage/Pixel.html +++ b/docs/CrImage/GrayscaleImage/Pixel.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- struct CrImage::GrayscaleImage::Pixel + struct CrImage::GrayscaleImage::Pixel

@@ -419,7 +419,7 @@

- + cr-image/grayscale_image.cr @@ -451,6 +451,8 @@

+ +

- - @@ -552,6 +561,8 @@

+ +


@@ -602,7 +613,7 @@


@@ -623,8 +634,6 @@

- - diff --git a/docs/CrImage/Image.html b/docs/CrImage/Image.html index 00e7d8c..fad129c 100644 --- a/docs/CrImage/Image.html +++ b/docs/CrImage/Image.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- abstract class CrImage::Image + abstract class CrImage::Image

@@ -447,7 +447,7 @@

- + cr-image/image.cr @@ -462,6 +462,25 @@

+

+ + + + Macro Summary +

+ + + +

-

- - - - Macro Summary -

- - -
- @@ -589,6 +592,9 @@

+ + + @@ -601,6 +607,34 @@

+

+ + + + Macro Detail +

+ +
+
+ + macro subsclasses_include(mod) + + # +
+ +
+
+ + [View source] + +
+
+ + + +


@@ -647,7 +681,7 @@


@@ -668,7 +702,7 @@


@@ -689,7 +723,7 @@


@@ -710,7 +744,7 @@


@@ -731,7 +765,7 @@


@@ -752,7 +786,7 @@


@@ -773,7 +807,7 @@


@@ -794,7 +828,7 @@


@@ -815,7 +849,7 @@


@@ -836,35 +870,7 @@


- [View source] - -
- - - - - -

- - - - Macro Detail -

- -
-
- - macro subsclasses_include(mod) - - # -
- -
-
diff --git a/docs/CrImage/IntMap.html b/docs/CrImage/IntMap.html index f861dcd..4831a15 100644 --- a/docs/CrImage/IntMap.html +++ b/docs/CrImage/IntMap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::IntMap + class CrImage::IntMap

@@ -444,7 +444,7 @@

- + cr-image/map.cr @@ -460,27 +460,17 @@

- + - Instance Method Summary + Macro Summary

@@ -642,7 +644,7 @@


@@ -658,15 +660,13 @@


- - diff --git a/docs/CrImage/MapImpl.html b/docs/CrImage/MapImpl.html index 65f6dd6..6c41cb7 100644 --- a/docs/CrImage/MapImpl.html +++ b/docs/CrImage/MapImpl.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::MapImpl(T) + module CrImage::MapImpl(T)

@@ -463,7 +463,7 @@

- + cr-image/map.cr @@ -510,6 +510,8 @@

+ +

- - @@ -923,7 +929,7 @@


@@ -939,7 +945,7 @@


@@ -955,7 +961,7 @@


@@ -971,7 +977,7 @@


@@ -981,6 +987,8 @@

+ +


@@ -1027,7 +1035,7 @@


@@ -1048,7 +1056,7 @@


@@ -1064,7 +1072,7 @@


@@ -1085,7 +1093,7 @@


@@ -1106,7 +1114,7 @@


@@ -1128,7 +1136,7 @@


@@ -1154,7 +1162,7 @@


@@ -1175,7 +1183,7 @@


@@ -1196,7 +1204,7 @@


@@ -1217,7 +1225,7 @@


@@ -1243,7 +1251,7 @@


@@ -1264,7 +1272,7 @@


@@ -1285,7 +1293,7 @@


@@ -1306,7 +1314,7 @@


@@ -1327,7 +1335,7 @@


@@ -1348,7 +1356,7 @@


@@ -1369,7 +1377,7 @@


@@ -1390,7 +1398,7 @@


@@ -1411,7 +1419,7 @@


@@ -1432,7 +1440,7 @@


@@ -1453,7 +1461,7 @@


@@ -1474,7 +1482,7 @@


@@ -1495,7 +1503,7 @@


@@ -1516,7 +1524,7 @@


@@ -1532,7 +1540,7 @@


@@ -1562,7 +1570,7 @@


@@ -1583,7 +1591,7 @@


@@ -1604,7 +1612,7 @@


@@ -1625,7 +1633,7 @@


@@ -1646,7 +1654,7 @@


@@ -1667,7 +1675,7 @@


@@ -1688,7 +1696,7 @@


@@ -1709,7 +1717,7 @@


@@ -1730,7 +1738,7 @@


@@ -1751,7 +1759,7 @@


@@ -1772,7 +1780,7 @@


@@ -1793,7 +1801,7 @@


@@ -1816,7 +1824,7 @@


@@ -1832,15 +1840,13 @@


- - diff --git a/docs/CrImage/Mask.html b/docs/CrImage/Mask.html index f1d2e57..6051624 100644 --- a/docs/CrImage/Mask.html +++ b/docs/CrImage/Mask.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::Mask + class CrImage::Mask

@@ -468,7 +468,7 @@

- + cr-image/mask.cr @@ -537,6 +537,8 @@

+ +

- - @@ -913,7 +922,7 @@


@@ -934,7 +943,7 @@


@@ -955,7 +964,7 @@


@@ -976,7 +985,7 @@


@@ -1000,7 +1009,7 @@


@@ -1010,6 +1019,8 @@

+ +


@@ -1052,7 +1063,7 @@


@@ -1073,7 +1084,7 @@


@@ -1094,7 +1105,7 @@


@@ -1115,7 +1126,7 @@


@@ -1137,7 +1148,7 @@


@@ -1158,7 +1169,7 @@


@@ -1183,7 +1194,7 @@


@@ -1208,7 +1219,7 @@


@@ -1233,7 +1244,7 @@


@@ -1258,7 +1269,7 @@


@@ -1274,7 +1285,7 @@


@@ -1290,7 +1301,7 @@


@@ -1306,7 +1317,7 @@


@@ -1327,7 +1338,7 @@


@@ -1348,7 +1359,7 @@


@@ -1369,7 +1380,7 @@


@@ -1385,7 +1396,7 @@


@@ -1406,7 +1417,7 @@


@@ -1427,7 +1438,7 @@


@@ -1448,7 +1459,7 @@


@@ -1469,7 +1480,7 @@


@@ -1490,7 +1501,7 @@


@@ -1511,7 +1522,7 @@


@@ -1532,7 +1543,7 @@


@@ -1548,7 +1559,7 @@


@@ -1569,7 +1580,7 @@


@@ -1593,7 +1604,7 @@


@@ -1614,7 +1625,7 @@


@@ -1635,7 +1646,7 @@


@@ -1661,7 +1672,7 @@


@@ -1706,7 +1717,7 @@


@@ -1727,7 +1738,7 @@


@@ -1748,7 +1759,7 @@


@@ -1769,7 +1780,7 @@


@@ -1790,7 +1801,7 @@


@@ -1806,15 +1817,13 @@


- - diff --git a/docs/CrImage/NumericMap.html b/docs/CrImage/NumericMap.html index a0f7324..53409f8 100644 --- a/docs/CrImage/NumericMap.html +++ b/docs/CrImage/NumericMap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::NumericMap(T) + module CrImage::NumericMap(T)

@@ -456,7 +456,7 @@

- + cr-image/map.cr @@ -471,6 +471,8 @@

+ +

- - @@ -580,6 +583,8 @@

Instance methods inherited from module C + +


@@ -616,7 +621,7 @@


@@ -632,7 +637,7 @@


@@ -648,7 +653,7 @@


@@ -664,7 +669,7 @@


@@ -680,7 +685,7 @@


@@ -696,7 +701,7 @@


@@ -712,15 +717,13 @@


- - diff --git a/docs/CrImage/OneMap.html b/docs/CrImage/OneMap.html index 9343635..e00ce2c 100644 --- a/docs/CrImage/OneMap.html +++ b/docs/CrImage/OneMap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::OneMap + class CrImage::OneMap

@@ -444,7 +444,7 @@

- + cr-image/map.cr @@ -476,6 +476,8 @@

+ +

- - @@ -666,6 +675,8 @@

+ +


@@ -702,7 +713,7 @@


@@ -718,7 +729,7 @@


@@ -734,7 +745,7 @@


@@ -750,7 +761,7 @@


@@ -766,7 +777,7 @@


@@ -782,7 +793,7 @@


@@ -798,7 +809,7 @@


@@ -814,7 +825,7 @@


@@ -830,7 +841,7 @@


@@ -846,7 +857,7 @@


@@ -862,7 +873,7 @@


@@ -878,7 +889,7 @@


@@ -894,7 +905,7 @@


@@ -910,15 +921,13 @@


- - diff --git a/docs/CrImage/Operation.html b/docs/CrImage/Operation.html index 69acf7e..abba3c2 100644 --- a/docs/CrImage/Operation.html +++ b/docs/CrImage/Operation.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation + module CrImage::Operation

@@ -428,14 +428,14 @@

- + cr-image/operation/bilinear_resize.cr
- + cr-image/operation/operation.cr diff --git a/docs/CrImage/Operation/BilinearResize.html b/docs/CrImage/Operation/BilinearResize.html index bdb8c38..2c0444f 100644 --- a/docs/CrImage/Operation/BilinearResize.html +++ b/docs/CrImage/Operation/BilinearResize.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::BilinearResize + module CrImage::Operation::BilinearResize

@@ -451,7 +451,7 @@

- + cr-image/operation/bilinear_resize.cr @@ -466,6 +466,8 @@

+ +

- -
@@ -505,6 +505,8 @@

+ +


@@ -551,15 +553,13 @@


- - diff --git a/docs/CrImage/Operation/BoxBlur.html b/docs/CrImage/Operation/BoxBlur.html index ff58557..090cb31 100644 --- a/docs/CrImage/Operation/BoxBlur.html +++ b/docs/CrImage/Operation/BoxBlur.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::BoxBlur + module CrImage::Operation::BoxBlur

@@ -450,7 +450,7 @@

- + cr-image/operation/box_blur.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -500,6 +500,8 @@

+ +


@@ -536,15 +538,13 @@


- - diff --git a/docs/CrImage/Operation/Brightness.html b/docs/CrImage/Operation/Brightness.html index 5453b05..9142c67 100644 --- a/docs/CrImage/Operation/Brightness.html +++ b/docs/CrImage/Operation/Brightness.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Brightness + module CrImage::Operation::Brightness

@@ -448,7 +448,7 @@

- + cr-image/operation/brightness.cr @@ -463,6 +463,8 @@

+ +

- -
@@ -498,6 +498,8 @@

+ +


@@ -534,15 +536,13 @@


- - diff --git a/docs/CrImage/Operation/ChannelSwap.html b/docs/CrImage/Operation/ChannelSwap.html index 4414ea1..c9a78f9 100644 --- a/docs/CrImage/Operation/ChannelSwap.html +++ b/docs/CrImage/Operation/ChannelSwap.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::ChannelSwap + module CrImage::Operation::ChannelSwap

@@ -448,7 +448,7 @@

- + cr-image/operation/channel_swap.cr @@ -463,6 +463,8 @@

+ +

- -
@@ -498,6 +498,8 @@

+ +


@@ -534,15 +536,13 @@


- - diff --git a/docs/CrImage/Operation/Contrast.html b/docs/CrImage/Operation/Contrast.html index 09738a7..16f9ceb 100644 --- a/docs/CrImage/Operation/Contrast.html +++ b/docs/CrImage/Operation/Contrast.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Contrast + module CrImage::Operation::Contrast

@@ -448,7 +448,7 @@

- + cr-image/operation/contrast.cr @@ -463,6 +463,8 @@

+ +

- -
@@ -498,6 +498,8 @@

+ +


@@ -534,15 +536,13 @@


- - diff --git a/docs/CrImage/Operation/Crop.html b/docs/CrImage/Operation/Crop.html index 049d12e..4a4e9c9 100644 --- a/docs/CrImage/Operation/Crop.html +++ b/docs/CrImage/Operation/Crop.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Crop + module CrImage::Operation::Crop

@@ -450,7 +450,7 @@

- + cr-image/operation/crop.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -515,6 +515,8 @@

+ +


@@ -551,7 +553,7 @@


@@ -567,7 +569,7 @@


@@ -583,7 +585,7 @@


@@ -599,15 +601,13 @@


- - diff --git a/docs/CrImage/Operation/Draw.html b/docs/CrImage/Operation/Draw.html index 586f46c..687edfe 100644 --- a/docs/CrImage/Operation/Draw.html +++ b/docs/CrImage/Operation/Draw.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Draw + module CrImage::Operation::Draw

@@ -453,7 +453,7 @@

- + cr-image/operation/draw.cr @@ -468,6 +468,8 @@

+ +

- -
@@ -551,6 +551,8 @@

+ +


@@ -597,7 +599,7 @@


@@ -613,7 +615,7 @@


@@ -634,7 +636,7 @@


@@ -650,7 +652,7 @@


@@ -671,7 +673,7 @@


@@ -687,7 +689,7 @@


@@ -703,7 +705,7 @@


@@ -719,7 +721,7 @@


@@ -735,15 +737,13 @@


- - diff --git a/docs/CrImage/Operation/GaussianBlur.html b/docs/CrImage/Operation/GaussianBlur.html index 7c060e7..a9bcd19 100644 --- a/docs/CrImage/Operation/GaussianBlur.html +++ b/docs/CrImage/Operation/GaussianBlur.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::GaussianBlur + module CrImage::Operation::GaussianBlur

@@ -450,7 +450,7 @@

- + cr-image/operation/gaussian_blur.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -500,6 +500,8 @@

+ +


@@ -536,15 +538,13 @@


- - diff --git a/docs/CrImage/Operation/HistogramEqualize.html b/docs/CrImage/Operation/HistogramEqualize.html index 122acda..0270a6f 100644 --- a/docs/CrImage/Operation/HistogramEqualize.html +++ b/docs/CrImage/Operation/HistogramEqualize.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::HistogramEqualize + module CrImage::Operation::HistogramEqualize

@@ -454,7 +454,7 @@

- + cr-image/operation/histogram.cr @@ -469,6 +469,8 @@

+ +

- -
@@ -509,6 +509,8 @@

+ +


@@ -545,7 +547,7 @@


@@ -561,15 +563,13 @@


- - diff --git a/docs/CrImage/Operation/HistogramEqualize/Histogram.html b/docs/CrImage/Operation/HistogramEqualize/Histogram.html index 7852673..6c7d874 100644 --- a/docs/CrImage/Operation/HistogramEqualize/Histogram.html +++ b/docs/CrImage/Operation/HistogramEqualize/Histogram.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::Operation::HistogramEqualize::Histogram + class CrImage::Operation::HistogramEqualize::Histogram

@@ -430,7 +430,7 @@

- + cr-image/operation/histogram.cr @@ -462,6 +462,8 @@

+ +

- - @@ -581,6 +587,8 @@

+ +


@@ -622,7 +630,7 @@


@@ -643,7 +651,7 @@


@@ -664,7 +672,7 @@


@@ -680,7 +688,7 @@


@@ -696,7 +704,7 @@


@@ -717,7 +725,7 @@


@@ -733,15 +741,13 @@


- - diff --git a/docs/CrImage/Operation/HorizontalBlur.html b/docs/CrImage/Operation/HorizontalBlur.html index 72bbc15..4624a39 100644 --- a/docs/CrImage/Operation/HorizontalBlur.html +++ b/docs/CrImage/Operation/HorizontalBlur.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::HorizontalBlur + module CrImage::Operation::HorizontalBlur

@@ -450,7 +450,7 @@

- + cr-image/operation/horizontal_blur.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -500,6 +500,8 @@

+ +


@@ -536,15 +538,13 @@


- - diff --git a/docs/CrImage/Operation/MaskApply.html b/docs/CrImage/Operation/MaskApply.html index 26249a9..fa8ec91 100644 --- a/docs/CrImage/Operation/MaskApply.html +++ b/docs/CrImage/Operation/MaskApply.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::MaskApply + module CrImage::Operation::MaskApply

@@ -462,7 +462,7 @@

- + cr-image/operation/mask_apply.cr @@ -477,6 +477,8 @@

+ +

- -
@@ -540,6 +540,8 @@

+ +


@@ -587,7 +589,7 @@


@@ -608,7 +610,7 @@


@@ -624,7 +626,7 @@


@@ -645,7 +647,7 @@


@@ -661,15 +663,13 @@


- - diff --git a/docs/CrImage/Operation/Pad.html b/docs/CrImage/Operation/Pad.html index 4ed1537..e29f282 100644 --- a/docs/CrImage/Operation/Pad.html +++ b/docs/CrImage/Operation/Pad.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Pad + module CrImage::Operation::Pad

@@ -450,7 +450,7 @@

- + cr-image/operation/pad.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -500,6 +500,8 @@

+ +


@@ -536,15 +538,13 @@


- - diff --git a/docs/CrImage/Operation/Rotate.html b/docs/CrImage/Operation/Rotate.html index 5d33c97..bc2b690 100644 --- a/docs/CrImage/Operation/Rotate.html +++ b/docs/CrImage/Operation/Rotate.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::Rotate + module CrImage::Operation::Rotate

@@ -450,7 +450,7 @@

- + cr-image/operation/rotate.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -504,6 +504,8 @@

+ +


@@ -558,15 +560,13 @@


- - diff --git a/docs/CrImage/Operation/VerticalBlur.html b/docs/CrImage/Operation/VerticalBlur.html index 0c54717..6725ca0 100644 --- a/docs/CrImage/Operation/VerticalBlur.html +++ b/docs/CrImage/Operation/VerticalBlur.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module CrImage::Operation::VerticalBlur + module CrImage::Operation::VerticalBlur

@@ -450,7 +450,7 @@

- + cr-image/operation/vertical_blur.cr @@ -465,6 +465,8 @@

+ +

- -
@@ -500,6 +500,8 @@

+ +


@@ -536,15 +538,13 @@


- - diff --git a/docs/CrImage/RGBAImage.html b/docs/CrImage/RGBAImage.html index 308a442..1935c55 100644 --- a/docs/CrImage/RGBAImage.html +++ b/docs/CrImage/RGBAImage.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::RGBAImage + class CrImage::RGBAImage

@@ -494,42 +494,42 @@

- + cr-image/rgba_image.cr
- + jpeg.cr
- + pluto.cr
- + png.cr
- + stumpy.cr
- + webp.cr @@ -622,6 +622,8 @@

+ +

- - @@ -1539,7 +1614,7 @@


@@ -1549,6 +1624,8 @@

+ +


@@ -1590,7 +1667,7 @@


@@ -1611,7 +1688,7 @@


@@ -1636,7 +1713,7 @@


@@ -1652,7 +1729,7 @@


@@ -1677,7 +1754,7 @@


@@ -1693,7 +1770,7 @@


@@ -1714,7 +1791,7 @@


@@ -1735,7 +1812,7 @@


@@ -1756,7 +1833,7 @@


@@ -1781,7 +1858,7 @@


@@ -1797,7 +1874,7 @@


@@ -1822,7 +1899,7 @@


@@ -1838,7 +1915,7 @@


@@ -1854,7 +1931,7 @@


@@ -1879,7 +1956,7 @@


@@ -1895,7 +1972,7 @@


@@ -1916,7 +1993,7 @@


@@ -1940,7 +2017,7 @@


@@ -1956,7 +2033,7 @@


@@ -1977,7 +2054,7 @@


@@ -1993,7 +2070,7 @@


@@ -2018,7 +2095,7 @@


@@ -2034,15 +2111,13 @@


- - diff --git a/docs/CrImage/Region.html b/docs/CrImage/Region.html index efad522..361702f 100644 --- a/docs/CrImage/Region.html +++ b/docs/CrImage/Region.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- struct CrImage::Region + struct CrImage::Region

@@ -431,7 +431,7 @@

- + cr-image/region.cr @@ -468,6 +468,8 @@

+ +

- - @@ -606,7 +615,7 @@


@@ -616,6 +625,8 @@

+ +


@@ -657,7 +668,7 @@


@@ -673,7 +684,7 @@


@@ -694,7 +705,7 @@


@@ -729,7 +740,7 @@


@@ -778,8 +789,6 @@

- - diff --git a/docs/CrImage/RepeatView.html b/docs/CrImage/RepeatView.html index a6f4c78..7c20a8d 100644 --- a/docs/CrImage/RepeatView.html +++ b/docs/CrImage/RepeatView.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::RepeatView(T) + class CrImage::RepeatView(T)

@@ -430,7 +430,7 @@

- + cr-image/window_view.cr @@ -462,6 +462,8 @@

+ +

- -

@@ -616,6 +625,8 @@

+ +


- - diff --git a/docs/CrImage/UInt8Map.html b/docs/CrImage/UInt8Map.html index 058a107..bd1fe06 100644 --- a/docs/CrImage/UInt8Map.html +++ b/docs/CrImage/UInt8Map.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class CrImage::UInt8Map + class CrImage::UInt8Map

@@ -444,7 +444,7 @@

- + cr-image/map.cr @@ -460,22 +460,17 @@

- + - Instance Method Summary + Macro Summary

@@ -722,7 +730,7 @@


@@ -738,7 +746,7 @@


@@ -759,7 +767,7 @@


@@ -780,7 +788,7 @@


@@ -801,7 +809,7 @@


@@ -822,7 +830,7 @@


@@ -838,15 +846,13 @@


- - diff --git a/docs/Pluto.html b/docs/Pluto.html index b305c3e..8524cff 100644 --- a/docs/Pluto.html +++ b/docs/Pluto.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -440,21 +440,21 @@

- + lib/pluto/src/pluto.cr
- + lib/pluto/src/pluto/channel_type.cr
- + pluto.cr diff --git a/docs/Pluto/ImageGA.html b/docs/Pluto/ImageGA.html index 2a265dd..1ceadb1 100644 --- a/docs/Pluto/ImageGA.html +++ b/docs/Pluto/ImageGA.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class Pluto::ImageGA + class Pluto::ImageGA

@@ -453,14 +453,14 @@

- + lib/pluto/src/pluto/image_ga.cr
- + pluto.cr @@ -475,6 +475,8 @@

+ +

- - - -

diff --git a/docs/Pluto/ImageRGBA.html b/docs/Pluto/ImageRGBA.html index e20033b..292e1f3 100644 --- a/docs/Pluto/ImageRGBA.html +++ b/docs/Pluto/ImageRGBA.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class Pluto::ImageRGBA + class Pluto::ImageRGBA

@@ -453,14 +453,14 @@

- + lib/pluto/src/pluto/image_rgba.cr
- + pluto.cr @@ -475,6 +475,8 @@

+ +

- - - -

diff --git a/docs/StumpyCore.html b/docs/StumpyCore.html index b2f69a4..6615c31 100644 --- a/docs/StumpyCore.html +++ b/docs/StumpyCore.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -428,77 +428,77 @@

- + lib/stumpy_core/src/stumpy_core/canvas.cr
- + lib/stumpy_core/src/stumpy_core/rgba.cr
- + lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr
- + lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr
- + lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr
- + lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr
- + lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr
- + lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr
- + lib/stumpy_core/src/stumpy_core/rgba/mixing.cr
- + lib/stumpy_core/src/stumpy_core/utils.cr
- + stumpy.cr diff --git a/docs/StumpyCore/Canvas.html b/docs/StumpyCore/Canvas.html index b3c8c85..380c8f5 100644 --- a/docs/StumpyCore/Canvas.html +++ b/docs/StumpyCore/Canvas.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- class StumpyCore::Canvas + class StumpyCore::Canvas

@@ -443,14 +443,14 @@

- + lib/stumpy_core/src/stumpy_core/canvas.cr
- + stumpy.cr @@ -465,6 +465,8 @@

+ +

- - - -

diff --git a/docs/Tutorial.html b/docs/Tutorial.html index f882f31..b7c1d90 100644 --- a/docs/Tutorial.html +++ b/docs/Tutorial.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -434,14 +434,14 @@

- + tutorials/chromakey_tutorial.cr
- + tutorials/tutorial.cr diff --git a/docs/Tutorial/ChromaKey.html b/docs/Tutorial/ChromaKey.html index 0e314d6..a45212b 100644 --- a/docs/Tutorial/ChromaKey.html +++ b/docs/Tutorial/ChromaKey.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module Tutorial::ChromaKey + module Tutorial::ChromaKey

@@ -453,7 +453,7 @@

- + tutorials/chromakey_tutorial.cr diff --git a/docs/Tutorial/EdgeDetection.html b/docs/Tutorial/EdgeDetection.html index 4ad051a..1155e51 100644 --- a/docs/Tutorial/EdgeDetection.html +++ b/docs/Tutorial/EdgeDetection.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module Tutorial::EdgeDetection + module Tutorial::EdgeDetection

@@ -455,7 +455,7 @@

- + tutorials/edge_detection_tutorial.cr diff --git a/docs/Tutorial/FindDifferences.html b/docs/Tutorial/FindDifferences.html index 3362557..882918a 100644 --- a/docs/Tutorial/FindDifferences.html +++ b/docs/Tutorial/FindDifferences.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -386,7 +386,7 @@

- module Tutorial::FindDifferences + module Tutorial::FindDifferences

@@ -472,7 +472,7 @@

- + tutorials/find_differences.cr diff --git a/docs/css/style.css b/docs/css/style.css index 2b91cf4..3d0a8a5 100644 --- a/docs/css/style.css +++ b/docs/css/style.css @@ -1,3 +1,7 @@ +:root { + color-scheme: light dark; +} + html, body { background: #FFFFFF; position: relative; @@ -729,6 +733,30 @@ img { max-width: 100%; } +table { + font-size: 14px; + display: block; + max-width: -moz-fit-content; + max-width: fit-content; + overflow-x: auto; + white-space: nowrap; + background: #fdfdfd; + text-align: center; + border: 1px solid #eee; + border-collapse: collapse; + padding: 0px 5px 0px 5px; +} + +table th { + padding: 10px; + letter-spacing: 1px; + border-bottom: 1px solid #eee; +} + +table td { + padding: 10px; +} + #sidebar-btn { height: 32px; width: 32px; @@ -794,10 +822,6 @@ img { } @media (prefers-color-scheme: dark) { - :root { - color-scheme: dark; - } - html, body { background: #1b1b1b; } @@ -824,6 +848,10 @@ img { border: 1px solid #353535; } + .project-versions-nav > option { + background-color: #222; + } + .superclass-hierarchy .superclass a, .superclass-hierarchy .superclass a:visited, .other-type a, @@ -935,13 +963,18 @@ img { color: white; } - pre { + pre, + table { color: white; background: #202020; border: 1px solid #353535; } + table th { + border-bottom: 1px solid #353535; + } + #sidebar-btn, #sidebar-btn-label { - color: white; + color: white; } } diff --git a/docs/index.html b/docs/index.html index 69e707f..ac96893 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ - + @@ -23,7 +23,7 @@ @@ -415,14 +415,14 @@

  • PPM
  • JPEG (requires libturbojpeg)
  • -
  • PNG (requirens libspng)
  • +
  • PNG (natively by default, or optionally through requires libspng)
  • WebP (requires libwebp)

For the formats that require a linked library, they must be required explicitly:

require "cr-image"
 require "cr-image/jpeg"
-require "cr-image/png"
 require "cr-image/webp"
+require "cr-image/png" # replaces native crystal with libspng
 
 # Or, alternatively
 require "cr-image/all_formats"
diff --git a/docs/index.json b/docs/index.json index 58a3e6e..9bd9ac2 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"Crystal Image","body":"

Crystal Image (Processing)

\n\nThis shard aims to provide feature rich image processing abilities, both for the purpose of\nimage manipulation as well as feature / information extraction from those images.\n\nThe code here originated as a fork from [Pluto](https://github.com/phenopolis/pluto) and further takes inspiration from [Stumpy](https://github.com/stumpycr/stumpy_core),\nand support converting to and from both of those libraries.\n\nAll sample images used are from [Unsplash](https://unsplash.com/).\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cr-image:\n github: vici37/cr-image\n ```\n\n2. Run `shards install`\n\n## Usage\n\nCrImage supports the formats:\n* PPM\n* JPEG (requires `libturbojpeg`)\n* PNG (requirens `libspng`)\n* WebP (requires `libwebp`)\n\nFor the formats that require a linked library, they must be `require`d explicitly:\n\n```crystal\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\nrequire \"cr-image/png\"\nrequire \"cr-image/webp\"\n\n# Or, alternatively\nrequire \"cr-image/all_formats\"\n```\n\n### Example\n\nAssuming an image `moon.jpg` already exists\n\n\"Picture\n\n```crystal\nrequire \"cr-image\"\n\nimage = CrImage::RGBAImage.open(\"moon.jpg\")\n\n# create a mask identifying all pixels with light (i.e. the moon)\nmoon_mask = image\n .to_gray\n .threshold(8) # pixels are UInt8, with 0 as black and 255 as white\n\n# Crop out the moon from the image, and save it to a new file\nimage.crop(\n moon_mask.region # smallest area that encompasses all true bits in mask\n).save(\"moon_cropped.jpg\")\n\n```\n\nYields this image:\n\n\"Cropped\n\n[See the tutorials](http://troy.sornson.io/cr-image/Tutorial.html) for more examples.\n\n### [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core) Conversion\n\nIf your library or application already uses Pluto or Stumpy and you want to use\nsome of the functionality of this library, CrImage also provides some optional\nconversion methods:\n\n```crystal\nrequire \"cr-image/pluto\"\npluto_image # => Pluto::ImageRGBA\npluto_image.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_pluto # => Pluto::ImageRGBA\n```\n\n**NOTE:** Currently Pluto and CrImage share the same bindings for `libturbojpeg`, `libspng`, and `libwebp`. If you\nuse Pluto, you _cannot_ use those formats from CrImage.\n\n\n```crystal\nrequire \"cr-image/stumpy\"\nstumpy_canvas # => StumpyCore::Canvas\nstumpy_canvas.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_stumpy # => StumpyCore::Canvas\n```\n\n**NOTE:** Stumpy uses `UInt16` for its underlying raw image storage per channel per pixel, while Pluto and\nCrImage uses `UInt8`. Converting from a Stumpy `Canvas` object to `RGBAImage` may lose quality if the original\nimage used 16 bit color channels (i.e. 16-bit PNG). Most image formats tend to use 8-bit color channels.\n\n## Development\n\nThis requires `libwebp`, `libspng`, and `libturbojpeg` to run. Then:\n\n```\n> make test\n```\n\nTo ensure all tests run and pass.\n\n## Contributing\n\n1. [Fork it](https://github.com/Vici37/cr-image/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Troy Sornson](https://github.com/Vici37) - creator and maintainer\n","program":{"html_id":"Crystal Image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"Crystal Image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"Crystal Image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image.cr#L20"},{"filename":"src/cr-image/edge_policy.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L1"},{"filename":"src/cr-image/map.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L1"},{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/region.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L1"},{"filename":"src/cr-image/window_view.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L1"},{"filename":"src/lib-formats/bindings/lib_jpeg_turbo.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_jpeg_turbo.cr#L1"},{"filename":"src/lib-formats/bindings/lib_spng.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_spng.cr#L1"},{"filename":"src/lib-formats/bindings/lib_webp.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_webp.cr#L1"},{"filename":"src/pluto.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L35"},{"filename":"src/stumpy.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This module by itself isn't very interesting. Try taking a look through the [tutorials](./Tutorial.html) for better examples.","summary":"

This module by itself isn't very interesting.

","types":[{"html_id":"Crystal Image/CrImage/BlackView","path":"CrImage/BlackView.html","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L76"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to zero (or black)","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to zero (or black)

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = BlackView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":77,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L77"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n return T.zero\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/channel_type.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Red","name":"Red","value":"0"},{"id":"Green","name":"Green","value":"1"},{"id":"Blue","name":"Blue","value":"2"},{"id":"Gray","name":"Gray","value":"3"},{"id":"Alpha","name":"Alpha","value":"4"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_color_channel` and `GrayscaleImage#each_color_channel`","summary":"

Enum representing different image channels supported by CrImage

","instance_methods":[{"html_id":"alpha?-instance-method","name":"alpha?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L9"},"def":{"name":"alpha?","visibility":"Public","body":"self == Alpha"}},{"html_id":"blue?-instance-method","name":"blue?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"html_id":"default:UInt8-instance-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L11"},"def":{"name":"default","return_type":"UInt8","visibility":"Public","body":"alpha? ? 255_u8 : 0_u8"}},{"html_id":"gray?-instance-method","name":"gray?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L8"},"def":{"name":"gray?","visibility":"Public","body":"self == Gray"}},{"html_id":"green?-instance-method","name":"green?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L6"},"def":{"name":"green?","visibility":"Public","body":"self == Green"}},{"html_id":"red?-instance-method","name":"red?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"Crystal Image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/color.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for parsing and representing colors that can be used for certain\nmethods in CrImage.\n\nSee `Operation::MaskApply#apply_color`, `Operation::Draw#draw_square`, or `Operation::Draw#draw_circle`","summary":"

Utility class for parsing and representing colors that can be used for certain methods in CrImage.

","constructors":[{"html_id":"default:Color-class-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L11"},"def":{"name":"default","return_type":"Color","visibility":"Public","body":"new(ChannelType::Red.default, ChannelType::Green.default, ChannelType::Blue.default, ChannelType::Alpha.default)"}},{"html_id":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=ChannelType::Alpha.default)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L8"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"of(color:String):Color-class-method","name":"of","doc":"Parse color from a hex string:\n\n```\nColor.of(\"#1\") # same as \"#11\" => Color.new(17, 17, 17, 255)\nColor.of(\"#01\") # => Color.new(1, 1, 1, 255)\nColor.of(\"#123\") # same as \"#112233\" => Color.new(17, 34, 51, 255)\nColor.of(\"#1234\") # same as \"#11223344\" => Color.new(34, 51, 68, 17)\nColor.of(\"#010203\") # => Color.new(1, 2, 3, 255)\nColor.of(\"#01020304\") # => Color.new(2, 3, 4, 1)\n```","summary":"

Parse color from a hex string:

","abstract":false,"args":[{"name":"color","external_name":"color","restriction":"String"}],"args_string":"(color : String) : Color","args_html":"(color : String) : Color","location":{"filename":"src/cr-image/color.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L49"},"def":{"name":"of","args":[{"name":"color","external_name":"color","restriction":"String"}],"return_type":"Color","visibility":"Public","body":"if ((!(color.starts_with?(\"#\"))) || (!({2, 3, 4, 5, 7, 9}.includes?(color.size)))) || (color.match(/^#[^0-9a-f]/i))\n raise(\"Invalid hex color '#{color}': must start with '#' followed by 1, 2, 3, 4, 6, or 9 alphanumeric characters (0-9 or a-f)\")\nend\ncase color.size\nwhen 2\n gray = (color[1].to_i(16)).to_u8\n gray = (gray << 4) + gray\n self.new(gray, gray, gray)\nwhen 3\n gray = (color[1, 2].to_i(16)).to_u8\n self.new(gray, gray, gray)\nwhen 4\n red = (color[1].to_i(16)).to_u8\n green = (color[2].to_i(16)).to_u8\n blue = (color[3].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue)\nwhen 5\n alpha = (color[1].to_i(16)).to_u8\n red = (color[2].to_i(16)).to_u8\n green = (color[3].to_i(16)).to_u8\n blue = (color[4].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue, (alpha << 4) + alpha)\nwhen 7\n red = (color[1, 2].to_i(16)).to_u8\n green = (color[3, 2].to_i(16)).to_u8\n blue = (color[5, 2].to_i(16)).to_u8\n self.new(red, green, blue)\nelse\n alpha = (color[1, 2].to_i(16)).to_u8\n red = (color[3, 2].to_i(16)).to_u8\n green = (color[5, 2].to_i(16)).to_u8\n blue = (color[7, 2].to_i(16)).to_u8\n self.new(red, green, blue, alpha)\nend\n"}},{"html_id":"random:Color-class-method","name":"random","doc":"Generate a random color with full (255) opacity","summary":"

Generate a random color with full (255) opacity

","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L16"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), ChannelType::Alpha.default)\n"}}],"instance_methods":[{"html_id":"==(other:Color):Bool-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"}],"args_string":"(other : Color) : Bool","args_html":"(other : Color) : Bool","location":{"filename":"src/cr-image/color.cr","line_number":93,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L93"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Color"}],"return_type":"Bool","visibility":"Public","body":"(((red == other.red) && (green == other.green)) && (blue == other.blue)) && (alpha == other.alpha)"}},{"html_id":"[](channel_type:ChannelType):UInt8-instance-method","name":"[]","doc":"Receive the UInt8 portion of this color corresponding to `channel_type`","summary":"

Receive the UInt8 portion of this color corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : UInt8","args_html":"(channel_type : ChannelType) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L29"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"UInt8","visibility":"Public","body":"case channel_type\nin ChannelType::Red\n red\nin ChannelType::Green\n green\nin ChannelType::Blue\n blue\nin ChannelType::Alpha\n alpha\nin ChannelType::Gray\n gray\nend"}},{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"alpha","visibility":"Public","body":"@alpha"}},{"html_id":"blue:UInt8-instance-method","name":"blue","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"html_id":"dist(other:Color,*,manhattan:Bool=false):Float64-instance-method","name":"dist","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"args_string":"(other : Color, *, manhattan : Bool = false) : Float64","args_html":"(other : Color, *, manhattan : Bool = false) : Float64","location":{"filename":"src/cr-image/color.cr","line_number":100,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L100"},"def":{"name":"dist","args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"splat_index":1,"return_type":"Float64","visibility":"Public","body":"if manhattan\n ((red.to_f - other.red).abs + (blue.to_i - other.blue).abs) + (green.to_i - other.green).abs\nelse\n Math.sqrt((((red.to_i - other.red) ** 2) + ((green.to_i - other.green) ** 2)) + ((blue.to_i - other.blue) ** 2))\nend"}},{"html_id":"gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):UInt8-instance-method","name":"gray","doc":"Convert this Color to a single UInt8 gray value","summary":"

Convert this Color to a single UInt8 gray value

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L22"},"def":{"name":"gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"UInt8","visibility":"Public","body":"Math.min(255_u8, (((red * red_multiplier) + (blue * blue_multiplier)) + (green * green_multiplier)).to_u8)"}},{"html_id":"green:UInt8-instance-method","name":"green","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"green","visibility":"Public","body":"@green"}},{"html_id":"red:UInt8-instance-method","name":"red","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"Crystal Image/CrImage/ComplexMap","path":"CrImage/ComplexMap.html","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":606,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L606"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"instance_methods":[{"html_id":"ifft:FloatMap-instance-method","name":"ifft","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":609,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L609"},"def":{"name":"ifft","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, (FftUtil.ifft2d(width, raw)).map(&.real))"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":613,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L613"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"self"}},{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":621,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L621"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to FloatMap\"))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":617,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L617"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to IntMap\"))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":607,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L607"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/EdgePolicy","path":"CrImage/EdgePolicy.html","kind":"enum","full_name":"CrImage::EdgePolicy","name":"EdgePolicy","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/edge_policy.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Black","name":"Black","value":"0"},{"id":"Repeat","name":"Repeat","value":"1"},{"id":"None","name":"None","value":"2"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A general enum for determining behavior around edges of `Image` or `Map`s. See also `Operator::Pad`","summary":"

A general enum for determining behavior around edges of Image or Maps.

","instance_methods":[{"html_id":"black?-instance-method","name":"black?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L4"},"def":{"name":"black?","visibility":"Public","body":"self == Black"}},{"html_id":"none?-instance-method","name":"none?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L6"},"def":{"name":"none?","visibility":"Public","body":"self == None"}},{"html_id":"repeat?-instance-method","name":"repeat?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L5"},"def":{"name":"repeat?","visibility":"Public","body":"self == Repeat"}}]},{"html_id":"Crystal Image/CrImage/ErrorView","path":"CrImage/ErrorView.html","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L61"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of teh underlying `Map` causes an error","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of teh underlying Map causes an error

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = ErrorView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":62,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L62"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n raise(Exception.new(\"Coordinates #{x}, #{y} correspond to #{adjusted_x}, #{adjusted_y} in sliding window sized #{width}x#{height} centered at #{@map_x}, #{@map_y}, which is outside\"))\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/exception.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Exception class for any errors thrown by CrImage","summary":"

Exception class for any errors thrown by CrImage

","constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/cr-image/exception.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L5"},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(error_code:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"args_string":"(error_code : Int32)","args_html":"(error_code : Int32)","location":{"filename":"src/cr-image/exception.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L9"},"def":{"name":"new","args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(error_code)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(handle:LibJPEGTurbo::Handle)-class-method","name":"new","abstract":false,"args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"args_string":"(handle : LibJPEGTurbo::Handle)","args_html":"(handle : LibJPEGTurbo::Handle)","location":{"filename":"src/cr-image/exception.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L13"},"def":{"name":"new","args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"visibility":"Public","body":"_ = allocate\n_.initialize(handle)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"error_code:Int32|Nil-instance-method","name":"error_code","abstract":false,"location":{"filename":"src/cr-image/exception.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"Crystal Image/CrImage/FftUtil","path":"CrImage/FftUtil.html","kind":"class","full_name":"CrImage::FftUtil","name":"FftUtil","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/fft_util.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for Fast Fourier Transforms\n\nAt some point in the future, this may be moved to its own shard.","summary":"

Utility class for Fast Fourier Transforms

","class_methods":[{"html_id":"fft1d(inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L59"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if buf = buffer\nelse\n buf = Array(Complex).new(inp.size) do\n Complex.zero\n end\nend\nFftUtil.fft1d(Array(Complex).new(inp.size) do |i|\n Complex.new(inp.unsafe_fetch(i))\nend, buf)\n"}},{"html_id":"fft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L68"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.fft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"fft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)|Slice(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"fft1d_unsafe","doc":"Calculates Fast Fourier Transform of `ret`. Uses and modifies `ret` in place.\n\nCan optionally pass in `buffer` which must be the same length as `inp`. This method makes no bound checks or error checks.","summary":"

Calculates Fast Fourier Transform of ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L76"},"def":{"name":"fft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = (-Math::PI.i) / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret\n"}},{"html_id":"fft2d(width:Int32,inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L10"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"FftUtil.fft2d(width, inp.map(&.to_c), buffer)"}},{"html_id":"fft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L15"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.fft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"fft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"fft2d_unsafe","doc":"Perform Fast Fourier Transform, using and rewriting `ret` for the output, as a 2 dimensional array with `width`. `buffer` must be an array\nof length at least the longer of `width` or `height` of the input array.","summary":"

Perform Fast Fourier Transform, using and rewriting ret for the output, as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L28"},"def":{"name":"fft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.fft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.fft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}},{"html_id":"ifft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"ifft1d","doc":"Perform Inverse Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`.","summary":"

Perform Inverse Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L165"},"def":{"name":"ifft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.ifft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"ifft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"ifft1d_unsafe","doc":"Perform Inverse Fast Fourier Transform on `ret`. Will use and overwrite the original values in `ret` to do so.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`. This method makes no bound checks or error checks.","summary":"

Perform Inverse Fast Fourier Transform on ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L173"},"def":{"name":"ifft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = Math::PI.i / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret.map!(&./(ret.size))\n"}},{"html_id":"ifft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"ifft2d","doc":"Perform Inverse Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Inverse Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":124,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L124"},"def":{"name":"ifft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.ifft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"ifft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"ifft2d_unsafe","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":135,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L135"},"def":{"name":"ifft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.ifft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.ifft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}}]},{"html_id":"Crystal Image/CrImage/FloatMap","path":"CrImage/FloatMap.html","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":508,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L508"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Float64` types.","summary":"

Implementation of MapImpl for Float64 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":519,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L519"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"self"}},{"html_id":"to_f64:self-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":511,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L511"},"def":{"name":"to_f64","return_type":"self","visibility":"Public","body":"self"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":515,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L515"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":509,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L509"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Format","path":"CrImage/Format.html","kind":"module","full_name":"CrImage::Format","name":"Format","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}, {extension: \".jpeg\", method: \"jpeg\"}, {extension: \".jpg\", method: \"jpeg\"}, {extension: \".png\", method: \"png\"}, {extension: \".webp\", method: \"webp\"}] of Nil"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Provides a convenience method for saving image files to the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage.save(\"image.jpg\")\n```\nSee `Open` for a convenience method to read images from the filesystem","summary":"

Provides a convenience method for saving image files to the filesystem.

","types":[{"html_id":"Crystal Image/CrImage/Format/JPEG","path":"CrImage/Format/JPEG.html","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG","abstract":false,"locations":[{"filename":"src/lib-formats/jpeg.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/jpeg.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to jpeg. Requires `libturbojpeg` to function.\n\n```\nimage = File.open(\"image.jpg\") { |file| CrImage::RGBAImage.from_jpeg(file) }\nFile.open(\"other_image.jpg\") { |file| image.to_jpeg(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\nimage.save(\"other_image.jpg\")\n```","summary":"

Provides methods to read from and write to jpeg.

","instance_methods":[{"html_id":"to_jpeg(io:IO,quality:Int32=100):Nil-instance-method","name":"to_jpeg","doc":"Output the image as JPEG to `io`","summary":"

Output the image as JPEG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, quality : Int32 = 100) : Nil","args_html":"(io : IO, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/jpeg.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/jpeg.cr#L74"},"def":{"name":"to_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"handle = LibJPEGTurbo.init_compress\nimage_data = IO::Memory.new(size * 3)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\nend\nbuffer = Pointer(UInt8).null\ncheck_jpeg(handle, LibJPEGTurbo.compress2(handle, image_data.buffer, @width, 0, @height, LibJPEGTurbo::PixelFormat::RGB, pointerof(buffer), out size, LibJPEGTurbo::Subsampling::S444, quality, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibJPEGTurbo.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Open","path":"CrImage/Format/Open.html","kind":"module","full_name":"CrImage::Format::Open","name":"Open","abstract":false,"locations":[{"filename":"src/cr-image/format/open.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/open.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides a convenience method for opening up image files from the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\n```\nSee `Save` for a convenience method to write to the filesystem.","summary":"

Provides a convenience method for opening up image files from the filesystem.

","instance_methods":[{"html_id":"open(filename:String):self-instance-method","name":"open","doc":"Reads this image from file using the provided filename.","summary":"

Reads this image from file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/open.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/open.cr#L14"},"def":{"name":"open","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"{% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then File.open(filename) { |file| self.from_{{ format[:method].id }}(file) }\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\nend.join(\", \")).id }}\"\n end\n {% end %}"}}]},{"html_id":"Crystal Image/CrImage/Format/PNG","path":"CrImage/Format/PNG.html","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG","abstract":false,"locations":[{"filename":"src/lib-formats/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/png.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PNG. Requires `libspng` to function.\n\n```\nimage = File.open(\"image.png\") { |file| CrImage::RGBAImage.from_png(file) }\nFile.open(\"other_image.png\") { |file| image.to_png(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.png\")\nimage.save(\"other_image.png\")\n```","summary":"

Provides methods to read from and write to PNG.

","instance_methods":[{"html_id":"to_png(io:IO):Nil-instance-method","name":"to_png","doc":"Output the image as PNG to `io`","summary":"

Output the image as PNG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/lib-formats/png.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/png.cr#L72"},"def":{"name":"to_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::Encoder)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_option(ctx, LibSPNG::Option::EncodeToBuffer, true)\nLibSPNG.set_png_buffer(ctx, image_data.buffer, image_data.size)\nihdr = LibSPNG::IHDR.new\nihdr.width = @width\nihdr.height = @height\nihdr.color_type = LibSPNG::ColorType::TrueColorAlpha\nihdr.bit_depth = 8\nLibSPNG.set_ihdr(ctx, pointerof(ihdr))\nerror = LibSPNG.encode_image(ctx, image_data.buffer, image_data.size, LibSPNG::Format::PNG, LibSPNG::EncodeFlags::Finalize)\ncheck_png(error)\nbuffer = LibSPNG.get_png_buffer(ctx, out size, pointerof(error))\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to get a buffer\"))\nend\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibC.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/PPM","path":"CrImage/Format/PPM.html","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM","abstract":false,"locations":[{"filename":"src/cr-image/format/ppm.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/ppm.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PPM.\n\n```\nimage = File.open(\"image.ppm\") { |file| CrImage::RGBAImage.from_ppm(file) }\nFile.open(\"other_image.ppm\") { |file| image.to_ppm(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.ppm\")\nimage.save(\"other_image.ppm\")\n```","summary":"

Provides methods to read from and write to PPM.

","instance_methods":[{"html_id":"to_ppm(io:IO):Nil-instance-method","name":"to_ppm","doc":"Output this image to `io` using PPM image encoding","summary":"

Output this image to io using PPM image encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/cr-image/format/ppm.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/ppm.cr#L56"},"def":{"name":"to_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"io << \"P6\\n\"\n(((io << @width) << \" \") << @height) << \"\\n\"\nio << \"255\\n\"\nsize.times do |index|\n io.write_byte(red.unsafe_fetch(index))\n io.write_byte(green.unsafe_fetch(index))\n io.write_byte(blue.unsafe_fetch(index))\nend\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Save","path":"CrImage/Format/Save.html","kind":"module","full_name":"CrImage::Format::Save","name":"Save","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"instance_methods":[{"html_id":"save(filename:String):self-instance-method","name":"save","doc":"Write this image to file using the provided filename.\n\nThis method _will not_ create intermediate directory paths. This method will throw an\nerror if they don't exist.","summary":"

Write this image to file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/save.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L20"},"def":{"name":"save","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"File.open(filename, \"w\") do |file|\n {% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then to_{{ format[:method].id }}(file)\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\n end.join(\", \")).id }}\"\n end\n {% end %}\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Format/WebP","path":"CrImage/Format/WebP.html","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP","abstract":false,"locations":[{"filename":"src/lib-formats/webp.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/webp.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to WebP. Requires `libwebp` to function.\n\n```\nimage = File.open(\"image.webp\") { |file| CrImage::RGBAImage.from_webp(file) }\nFile.open(\"other_image.webp\") { |file| image.to_webp(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.webp\")\nimage.save(\"other_image.webp\")\n```","summary":"

Provides methods to read from and write to WebP.

","instance_methods":[{"html_id":"to_webp(io:IO,*,lossy:Bool=false,quality:Int32=100):Nil-instance-method","name":"to_webp","doc":"Write image to `io` using WebP encoding","summary":"

Write image to io using WebP encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","args_html":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/webp.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/webp.cr#L59"},"def":{"name":"to_webp","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"splat_index":1,"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nsize, buffer = lossy ? lossy_encode(image_data, quality) : lossless_encode(image_data)\ncheck_webp(size)\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibWebP.free(buffer)\n"}}]}]},{"html_id":"Crystal Image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L13"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L42"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L38"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image in Grayscale. These image types are the easiest to perform feature and information extraction from, where\nthere is only one channel to examine, and so has methods for constructing `Mask`s from (see `#threshold` below).\n\nAn `RGBAImage` would become a `GrayscaleImage` this way:\n```\nimage.to_gray\n```\n\n\"Woman\n\"Woman","summary":"

An image in Grayscale.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage from a set of color channels (delegates to `RGBAImage#to_gray`)","summary":"

Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray)

","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L20"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"(RGBAImage.new(red, green, blue, alpha, width, height)).to_gray"}},{"html_id":"new(gray:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L24"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32)","args_html":"(gray : Array(UInt8), width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L38"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"<(*args,**options)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.<(*args, **options)"}},{"html_id":"<(*args,**options,&)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.<(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"<=(arg)-instance-method","name":"<=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! <= arg"}},{"html_id":"==(arg)-instance-method","name":"==","doc":"Returns `false` (other can only be a `Value` here).","summary":"

Returns false (other can only be a Value here).

","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"==","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! == arg"}},{"html_id":">(*args,**options)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.>(*args, **options)"}},{"html_id":">(*args,**options,&)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.>(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":">=(arg)-instance-method","name":">=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! >= arg"}},{"html_id":"[](x:Int32,y:Int32):Pixel-instance-method","name":"[]","doc":"Return a `Pixel` representing this cell in the image.","summary":"

Return a Pixel representing this cell in the image.

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Pixel","args_html":"(x : Int32, y : Int32) : Pixel","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Pixel","visibility":"Public","body":"index = (y * width) + x\nPixel.new(gray[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the `Array(UInt8)` corresponding to `channel_type`","summary":"

Return the Array(UInt8) corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L97"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"if channel_type == ChannelType::Alpha\n return @alpha\nend\n@gray\n"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the underlying `Array(UInt8)` of `channel_type` to the new `channel`.\n\nWarning: this method does not check the size of the incoming array, and if it's a different\nsize from what the current image represents, this could break it. We recommend against using\nthis method except for from other methods that will be updating the `width` and `height` immediately after.","summary":"

Set the underlying Array(UInt8) of channel_type to the new channel.

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L107"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Gray\n self.gray = channel\nwhen ChannelType::Alpha\n self.alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for GrayscaleImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return `alpha` channel","summary":"

Return #alpha channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":69,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L69"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L15"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the \"`blue`\" channel (returns `gray`)","summary":"

Return the "#blue" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L64"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"clone:GrayscaleImage-instance-method","name":"clone","doc":"Create a new GrayscaleImage as a copy of this one","summary":"

Create a new GrayscaleImage as a copy of this one

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L44"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone, @width, @height)"}},{"html_id":"cross_correlate(map:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":221,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L221"},"def":{"name":"cross_correlate","args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"to_imap.cross_correlate(map, edge_policy: edge_policy)"}},{"html_id":"cross_correlate(*args,**options)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options)"}},{"html_id":"cross_correlate(*args,**options,&)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"cross_correlate_fft(map:Map)-instance-method","name":"cross_correlate_fft","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"}],"args_string":"(map : Map)","args_html":"(map : Map)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":225,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L225"},"def":{"name":"cross_correlate_fft","args":[{"name":"map","external_name":"map","restriction":"Map"}],"visibility":"Public","body":"to_imap.cross_correlate_fft(map)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L80"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L74"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nnil\n"}},{"html_id":"gray:Array(UInt8)-instance-method","name":"gray","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"gray=(gray:Array(UInt8))-instance-method","name":"gray=","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"args_string":"(gray : Array(UInt8))","args_html":"(gray : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray=","args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@gray = gray"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the \"`green`\" channel (returns `gray`)","summary":"

Return the "#green" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L59"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"invert-instance-method","name":"invert","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`).\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":171,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L171"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`). Modifies self.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L182"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(*args,**options)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mask_from(*args, **options)"}},{"html_id":"mask_from(*args,**options,&)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mask_from(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"mean(*args,**options)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mean(*args, **options)"}},{"html_id":"mean(*args,**options,&)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mean(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the \"`red`\" channel (returns `gray`)","summary":"

Return the "#red" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L54"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels this image contains","summary":"

Return the number of pixels this image contains

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":160,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"threshold(threshold:Int):Mask-instance-method","name":"threshold","doc":"Construct a simple threshold `Mask` containing all pixels with a `UInt8` value greater than `threshold`\nGiven sample image:\n\n\"Woman\n\n```\nimage\n .to_gray # convert color image to grayscale one\n .threshold(128) # generate a mask using threshold operator\n .to_gray # convert mask to grayscale image\n .save(\"threshold_example.jpg\") # save mask as grayscale\n```\n\"Black","summary":"

Construct a simple threshold Mask containing all pixels with a UInt8 value greater than #threshold Given sample image:

","abstract":false,"args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"args_string":"(threshold : Int) : Mask","args_html":"(threshold : Int) : Mask","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":200,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L200"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"self >= threshold"}},{"html_id":"to_a:Array(UInt8)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `Array(UInt8)` corresponding to the `ChannelType::Gray` channel","summary":"

Receive a copy of the underlying Array(UInt8) corresponding to the ChannelType::Gray channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":217,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L217"},"def":{"name":"to_a","return_type":"Array(UInt8)","visibility":"Public","body":"gray.dup"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":155,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L155"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"html_id":"to_imap:IntMap-instance-method","name":"to_imap","doc":"Convert this image into a `IntMap`","summary":"

Convert this image into a IntMap

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":207,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L207"},"def":{"name":"to_imap","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, gray.map(&.to_i))"}},{"html_id":"to_map!:UInt8Map-instance-method","name":"to_map!","doc":"Convert this image into a `UInt8Map`. Does not clone underlying `gray` channel, both this image and map share the same data.","summary":"

Convert this image into a UInt8Map.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":212,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L212"},"def":{"name":"to_map!","return_type":"UInt8Map","visibility":"Public","body":"UInt8Map.new(width, @gray)"}},{"html_id":"to_pluto:Pluto::ImageGA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L43"},"def":{"name":"to_pluto","return_type":"Pluto::ImageGA","visibility":"Public","body":"Pluto::ImageGA.new(gray.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba(color_map:Hash(UInt8,Color),*,default:Color=Color.default):RGBAImage-instance-method","name":"to_rgba","doc":"Convert this grayscale image to an RGBA one using the provided color map.\n\nThe provided map should have a key for all 0-255 possible gray pixel values, otherwise the `default`\n`Color` will be used instead (default is black).\n\n```\ncolors = 256.times.to_a.map { |i| {i.to_u8, CrImage::Color.random} }.to_h\ngray_image.to_rgba(colors).save(\"to_rgba_color_map_sample.jpg\")\n```\n\n\"Woman\n\nBecomes\n\n\"Random","summary":"

Convert this grayscale image to an RGBA one using the provided color map.

","abstract":false,"args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"args_string":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","args_html":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L137"},"def":{"name":"to_rgba","args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"splat_index":1,"return_type":"RGBAImage","visibility":"Public","body":"red = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\ngray.each do |pixel|\n color = color_map[pixel]? || default\n red << color.red\n green << color.green\n blue << color.blue\n alpha << color.alpha\nend\nRGBAImage.new(red, green, blue, alpha, width, height)\n"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Convert this `GrayscaleImage` to an `RGBAImage`.\n\nNo color will be provided, all pixels will remain gray.","summary":"

Convert this GrayscaleImage to an RGBAImage.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":118,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L118"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L39"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}],"types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage/Pixel","path":"CrImage/GrayscaleImage/Pixel.html","kind":"struct","full_name":"CrImage::GrayscaleImage::Pixel","name":"Pixel","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},"constructors":[{"html_id":"new(gray:UInt8,alpha:UInt8)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"args_string":"(gray : UInt8, alpha : UInt8)","args_html":"(gray : UInt8, alpha : UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"def":{"name":"alpha","return_type":"UInt8","visibility":"Public","body":"@alpha"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone)"}},{"html_id":"copy_with(gray_gray=@gray,alpha_alpha=@alpha)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"args_string":"(gray _gray = @gray, alpha _alpha = @alpha)","args_html":"(gray _gray = @gray, alpha _alpha = @alpha)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"copy_with","args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"visibility":"Public","body":"self.class.new(_gray, _alpha)"}},{"html_id":"gray:UInt8-instance-method","name":"gray","abstract":false,"def":{"name":"gray","return_type":"UInt8","visibility":"Public","body":"@gray"}}]}]},{"html_id":"Crystal Image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Common base class for `GrayscaleImage` and `RGBAImage`. All `Image`s are readable and saveable\nto the filesystem or `IO` stream.","summary":"

Common base class for GrayscaleImage and RGBAImage.

","instance_methods":[{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Get the `Array(UInt8)` corresponding to `channel_type`)","summary":"

Get the Array(UInt8) corresponding to channel_type)

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L56"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the `Array(UInt8)` corresponding to `channel_type`) to `channel`","summary":"

Set the Array(UInt8) corresponding to channel_type) to channel

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L58"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L41"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L39"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L53"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":50,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L50"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L37"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L45"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L35"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size (total pixels) in image (`width` * `height`)","summary":"

Size (total pixels) in image (#width * #height)

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L47"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L43"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}],"macros":[{"html_id":"subsclasses_include(mod)-macro","name":"subsclasses_include","abstract":false,"args":[{"name":"mod","external_name":"mod","restriction":""}],"args_string":"(mod)","args_html":"(mod)","location":{"filename":"src/cr-image/image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L4"},"def":{"name":"subsclasses_include","args":[{"name":"mod","external_name":"mod","restriction":""}],"visibility":"Public","body":" \n{% for sub in @type.subclasses %}\n class ::{{ sub }}\n include {{ mod }}\n end\n {% end %}\n\n \n"}}]},{"html_id":"Crystal Image/CrImage/IntMap","path":"CrImage/IntMap.html","kind":"class","full_name":"CrImage::IntMap","name":"IntMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L478"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Int32` types.","summary":"

Implementation of MapImpl for Int32 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":485,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L485"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"to_f64"}},{"html_id":"to_f64:FloatMap-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":481,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L481"},"def":{"name":"to_f64","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f64))"}},{"html_id":"to_i:self-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":489,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L489"},"def":{"name":"to_i","return_type":"self","visibility":"Public","body":"self"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":479,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L479"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Map","path":"CrImage/Map.html","kind":"module","full_name":"CrImage::Map(T)","name":"Map","abstract":false,"locations":[{"filename":"src/cr-image/map.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/Mask","kind":"class","full_name":"CrImage::Mask","name":"Mask"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/OneMap","kind":"class","full_name":"CrImage::OneMap","name":"OneMap"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An interface for 2 dimensional data. Used for various masking and correlation methods.","summary":"

An interface for 2 dimensional data.

","instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L9"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L8"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L11"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L10"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L5"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L7"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L6"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L4"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/MapImpl","path":"CrImage/MapImpl.html","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L45"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"}],"including_types":[{"html_id":"Crystal Image/CrImage/ComplexMap","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap"},{"html_id":"Crystal Image/CrImage/FloatMap","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap"},{"html_id":"Crystal Image/CrImage/IntMap","kind":"class","full_name":"CrImage::IntMap","name":"IntMap"},{"html_id":"Crystal Image/CrImage/UInt8Map","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A collection of implementations of `NumericMap(T)`, intended to be included in base classes.\n\nSee `IntMap`, `FloatMap`, and `ComplexMap`.","summary":"

A collection of implementations of NumericMap(T), intended to be included in base classes.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:T)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"args_string":"(width : Int32, height : Int32, initial : T)","args_html":"(width : Int32, height : Int32, initial : T)","location":{"filename":"src/cr-image/map.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L82"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,raw:Array(T))-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"args_string":"(width : Int32, raw : Array(T))","args_html":"(width : Int32, raw : Array(T))","location":{"filename":"src/cr-image/map.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L63"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other:Array(Array(T)))-class-method","name":"new","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"args_string":"(other : Array(Array(T)))","args_html":"(other : Array(Array(T)))","location":{"filename":"src/cr-image/map.cr","line_number":67,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L67"},"def":{"name":"new","args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &)","args_html":"(width : Int32, height : Int32, &)","location":{"filename":"src/cr-image/map.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L76"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":1,"block_arity":1,"visibility":"Public","body":"_ = allocate\n_.initialize(width, height) do |_arg0|\n yield _arg0\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"*(num:Int|Float):self-instance-method","name":"*","doc":"Multiply each point in this `Map` by `num`","summary":"

Multiply each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":284,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L284"},"def":{"name":"*","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i * num\nend)"}},{"html_id":"+(num:Int|Float):self-instance-method","name":"+","doc":"Add each point in this `Map` by `num`","summary":"

Add each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":289,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L289"},"def":{"name":"+","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i + num\nend)"}},{"html_id":"+(other:self):self-instance-method","name":"+","doc":"Add each point of this `Map` with each point in `other`","summary":"

Add each point of this Map with each point in other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : self","args_html":"(other : self) : self","location":{"filename":"src/cr-image/map.cr","line_number":304,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L304"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Dimensions should match (caller: #{width}x#{height}, callee: #{other.width}x#{other.height})\"))\nend\nself.class.new(width, @raw.map_with_index do |val, i|\n val + other[i]\nend)\n"}},{"html_id":"-(other:NumericMap(T)):self-instance-method","name":"-","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : self","args_html":"(other : NumericMap(T)) : self","location":{"filename":"src/cr-image/map.cr","line_number":196,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L196"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Unable to subtract a map of different dimensions: #{width}x#{height} vs #{other.width}x#{other.height}\"))\nend\nself.class.new(width, raw.map_with_index do |v, i|\n v - other.raw[i]\nend)\n"}},{"html_id":"-(num:Int):self-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int"}],"args_string":"(num : Int) : self","args_html":"(num : Int) : self","location":{"filename":"src/cr-image/map.cr","line_number":294,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L294"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Int"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"-(num:Float):FloatMap-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Float"}],"args_string":"(num : Float) : FloatMap","args_html":"(num : Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":299,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L299"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"/(num:Int|Float):FloatMap-instance-method","name":"/","doc":"Divides each point in this `Map` by `num`\n\nTODO: ComplexMap shouldn't return a FloatMap","summary":"

Divides each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : FloatMap","args_html":"(num : Int | Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":279,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L279"},"def":{"name":"/","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i / num\nend)"}},{"html_id":"<(num:Int|Float):Mask-instance-method","name":"<","doc":"Construct a `Mask` identifying all pixels smaller than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray < 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels smaller than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":257,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L257"},"def":{"name":"<","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val < num\nend"}},{"html_id":"<=(num:Int|Float):Mask-instance-method","name":"<=","doc":"Construct a `Mask` identifying all pixels smaller than or equal to `num`. See `#<` for example.","summary":"

Construct a Mask identifying all pixels smaller than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":262,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L262"},"def":{"name":"<=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val <= num\nend"}},{"html_id":"==(num:Int|Float):Mask-instance-method","name":"==","doc":"Construct a `Mask` identifying all pixels equal to `num`","summary":"

Construct a Mask identifying all pixels equal to num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":267,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L267"},"def":{"name":"==","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val == num\nend"}},{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Check if this `Map` is equal to `other`","summary":"

Check if this Map is equal to other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/cr-image/map.cr","line_number":272,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L272"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"(other.width == width) && (@raw == other.raw)"}},{"html_id":">(num:Int|Float):Mask-instance-method","name":">","doc":"Construct a `Mask` identifying all pixels larger than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray > 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels larger than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":238,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L238"},"def":{"name":">","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val > num\nend"}},{"html_id":">=(num:Int|Float):Mask-instance-method","name":">=","doc":"Construct a `Mask` identify all pixels larger than or equal to `num`. See `#>` for near example.","summary":"

Construct a Mask identify all pixels larger than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":243,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L243"},"def":{"name":">=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val >= num\nend"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):self-instance-method","name":"[]","doc":"Crop the map to the values contained from `xstart` out by `xcount`, and `ystart` out by `ycount`","summary":"

Crop the map to the values contained from xstart out by xcount, and ystart out by ycount

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":152,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L152"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, xcount, ystart, ycount)"}},{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","doc":"Get element at coordinates `x` and `y`","summary":"

Get element at coordinates x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":106,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L106"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"if x >= width || x < 0\n raise(Exception.new(\"X coordinate #{x} is outside of Map width #{width}\"))\nend\nif y >= height || y < 0\n raise(Exception.new(\"Y coordinate #{y} is outside of Map height #{height}\"))\nend\nindex = (y * width) + x\nself[index]\n"}},{"html_id":"[](xrange:Range,ystart:Int32):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in row at `ystart`","summary":"

Crop the map, returning only the values in row at ystart

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : self","args_html":"(xrange : Range, ystart : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L137"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), ystart, 1)"}},{"html_id":"[](xstart:Int32,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in column at `xstart`","summary":"

Crop the map, returning only the values in column at xstart

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : self","args_html":"(xstart : Int32, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":142,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L142"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, 1, *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map to the values contained in `xrange` and `yrange`","summary":"

Crop the map to the values contained in xrange and yrange

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":147,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L147"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","doc":"Get element at `index` from underlying `raw` Array.","summary":"

Get element at index from underlying #raw Array.

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":101,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L101"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"@raw[index]"}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","doc":"Get lement at coordinates `x` and `y`, or `nil` if coordinates are out of bounds","summary":"

Get lement at coordinates x and y, or nil if coordinates are out of bounds

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":119,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L119"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"if x < 0 || x >= width\n return nil\nend\nif y < 0 || y >= height\n return nil\nend\nindex = (y * width) + x\n@raw[index]?\n"}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","doc":"Get element at `index`, or `nil` if out of bounds","summary":"

Get element at index, or nil if out of bounds

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":114,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L114"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"@raw[index]?"}},{"html_id":"column(x:Int32):self-instance-method","name":"column","doc":"Get a single dimensional `Map` representing teh column at `x`","summary":"

Get a single dimensional Map representing teh column at x

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"}],"args_string":"(x : Int32) : self","args_html":"(x : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":132,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L132"},"def":{"name":"column","args":[{"name":"x","external_name":"x","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(x, 1, 0, height)"}},{"html_id":"cross_correlate(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","doc":"Perform a brute force cross correlation calculation with provided `template`.","summary":"

Perform a brute force cross correlation calculation with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":393,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L393"},"def":{"name":"cross_correlate","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"half_width = template.width >> 1\nhalf_height = template.height >> 1\nstart_x, start_y = (edge_policy.none? ? {half_width, half_height} : {0, 0})\nend_x, end_y = (edge_policy.none? ? {(width - half_width) - 1, (height - half_height) - 1} : {width - 1, height - 1})\nret = Array(Float64).new((end_x - start_x) * (end_y - start_y))\n(start_y.upto(end_y)).each do |y|\n (start_x.upto(end_x)).each do |x|\n view = case edge_policy\n in EdgePolicy::Repeat\n RepeatView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::Black\n BlackView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::None\n ErrorView(T).new(template.width, template.height, self, x, y)\n end\n ret << view.sum do |pixel, vx, vy|\n template[vx, vy] * pixel\n end\n end\nend\nretf = FloatMap.new((end_x - start_x) + 1, ret)\nretf\n"}},{"html_id":"cross_correlate_fft(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Black):FloatMap-instance-method","name":"cross_correlate_fft","doc":"Perform a Fast Fourier Transform cross correlation (convolution?) with provided `template`. See `FftUtil`","summary":"

Perform a Fast Fourier Transform cross correlation (convolution?) with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":421,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L421"},"def":{"name":"cross_correlate_fft","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"max_width, max_height = Math.pw2ceil(width + template.width), Math.pw2ceil(height + template.height)\npad_type = edge_policy.none? ? EdgePolicy::Black : edge_policy\nwidth_range, height_range = case edge_policy\nin EdgePolicy::Black, EdgePolicy::Repeat\n {(template.width)...(width + template.width), (template.height)...(height + template.height)}\nin EdgePolicy::None\n {(template.width + (template.width // 2))..(((template.width + width) - template.width) + 1), (template.height + (template.height // 2))..(((template.height + height) - template.height) + 1)}\nend\norig_pad_fft = pad(top: (template.height // 2) + (template.height % 2), bottom: (max_height - height) - ((template.height // 2) + (template.height % 2)), right: (max_width - width) - ((template.width // 2) + (template.width % 2)), left: (template.width // 2) + (template.width % 2), pad_type: pad_type).to_c\nmap_pad_fft = template.pad(bottom: max_height - template.height, right: max_width - template.width).to_c\nbuffer = Array(Complex).new(Math.max(max_width, max_height)) do\n Complex.zero\nend\nFftUtil.fft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nFftUtil.fft2d_unsafe(max_width, map_pad_fft.raw, buffer)\norig_pad_fft.raw.map_with_index! do |o, i|\n o * map_pad_fft[i]\nend\nFftUtil.ifft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nret = (FloatMap.new(max_width, orig_pad_fft.raw.map(&.real)))[width_range, height_range]\nret\n"}},{"html_id":"fft:ComplexMap-instance-method","name":"fft","doc":"Performe a Fast Fourier Transform, padding out this `Map` so dimensions are a power of 2. See `FftUtil`","summary":"

Performe a Fast Fourier Transform, padding out this Map so dimensions are a power of 2.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":461,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L461"},"def":{"name":"fft","return_type":"ComplexMap","visibility":"Public","body":"map = pad(bottom: (Math.pw2ceil(height)) - height, right: (Math.pw2ceil(width)) - width).to_c\nbuffer = Array(Complex).new(Math.max(map.height, map.width)) do\n Complex.zero\nend\nComplexMap.new(map.width, FftUtil.fft2d_unsafe(map.width, map.raw, buffer))\n"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L86"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@raw.size // @width"}},{"html_id":"mask_from(&block:T,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","doc":"Construct a `Mask` from this `GrayscaleImage` using the passed in block to determine if a given pixel should be true or not\n\n```\n# Construct a mask identifying the bright pixels in the bottom left corner of image\nimage.to_gray.mask_from do |pixel, x, y|\n x < image.width // 2 && # left half of image\n y > (image.height // 2) && # bottom half of image\n pixel > 128 # only \"bright\" pixels\nend\n```\n\"Woman\n->\n\"Mask","summary":"

Construct a Mask from this GrayscaleImage using the passed in block to determine if a given pixel should be true or not

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":214,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L214"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(T, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(@raw[i], x, y)\nend)\n"}},{"html_id":"max:T-instance-method","name":"max","doc":"Return the maximum value in this `Map`","summary":"

Return the maximum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":187,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L187"},"def":{"name":"max","return_type":"T","visibility":"Public","body":"@raw.max"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Return the average of the elements in this `Map`","summary":"

Return the average of the elements in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":177,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L177"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@raw.sum / size"}},{"html_id":"min:T-instance-method","name":"min","doc":"Return the minimum value in this `Map`","summary":"

Return the minimum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L182"},"def":{"name":"min","return_type":"T","visibility":"Public","body":"@raw.min"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):self-instance-method","name":"pad","doc":"Pad the borders of this `Map` corresponding to `pad_type`.","summary":"

Pad the borders of this Map corresponding to pad_type.

","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","location":{"filename":"src/cr-image/map.cr","line_number":336,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L336"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"top = top > 0 ? top : all\nbottom = bottom > 0 ? bottom : all\nleft = left > 0 ? left : all\nright = right > 0 ? right : all\nnew_width = (left + width) + right\nnew_raw = initial_raw_pad(pad_type, new_width, top, bottom, left, right, pad_black_value)\nheight.times do |y|\n adjusted_y = y + top\n ((new_raw.to_unsafe + (adjusted_y * new_width)) + left).copy_from(raw.to_unsafe + (y * width), width)\nend\nif pad_type.repeat?\n if top > 0\n copy = new_raw[new_width * top, new_width]\n top.times do |i|\n new_raw[i * new_width, new_width] = copy\n end\n end\n if bottom > 0\n copy = new_raw[new_width * ((top + height) - 1), new_width]\n bottom.times do |i|\n new_raw[((i + top) + height) * new_width, new_width] = copy\n end\n end\nend\nself.class.new(new_width, new_raw)\n"}},{"html_id":"raw:Array(T)-instance-method","name":"raw","doc":"Return the raw array underlying the map","summary":"

Return the raw array underlying the map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L61"},"def":{"name":"raw","return_type":"Array(T)","visibility":"Public","body":"@raw"}},{"html_id":"row(y:Int32):self-instance-method","name":"row","doc":"Get a single dimensional `Map` representing the row at `y`","summary":"

Get a single dimensional Map representing the row at y

","abstract":false,"args":[{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(y : Int32) : self","args_html":"(y : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":127,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L127"},"def":{"name":"row","args":[{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(0, width, y, 1)"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Return the shape of the map - `{width, height}`","summary":"

Return the shape of the map - {width, height}

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L91"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size of the map - `width * height`","summary":"

Size of the map - width * height

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":96,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L96"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@raw.size"}},{"html_id":"sum:T-instance-method","name":"sum","doc":"Return the sum of all values in this `Map`","summary":"

Return the sum of all values in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":192,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L192"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":"@raw.sum"}},{"html_id":"to_a:Array(T)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `raw` array.","summary":"

Receive a copy of the underlying #raw array.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":326,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L326"},"def":{"name":"to_a","return_type":"Array(T)","visibility":"Public","body":"@raw.dup"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":331,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L331"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, raw.map(&.to_c))"}},{"html_id":"to_gray(*,scale:Bool=false):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Map` to a `GrayscaleImage`.\n\nSet `scale: true` so that all of the values will scale, such that `max` will become `255u8`, and `min` will become `0u8`. All other values will be\nlinearly scaled between those values.","summary":"

Convert this Map to a GrayscaleImage.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"args_string":"(*, scale : Bool = false) : GrayscaleImage","args_html":"(*, scale : Bool = false) : GrayscaleImage","location":{"filename":"src/cr-image/map.cr","line_number":313,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L313"},"def":{"name":"to_gray","args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"splat_index":0,"return_type":"GrayscaleImage","visibility":"Public","body":"if scale\n max_val = max\n min_val = min\n multiplier = 255 / (max_val - min_val)\n GrayscaleImage.new(@raw.map do |v|\n (((v - min_val) * multiplier).clamp(0, 255)).to_u8\n end, width)\nelse\n GrayscaleImage.new(@raw.map(&.to_u8), width)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L58"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/mask.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L39"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel\nfrom an image. This can include whether a particular pixel has a value within certain conditions, OR\nif that pixel should be zeroed out or not.\n\nSee `[]=` methods below for examples of how to manually construct masks.\n\n(x,y) - coordinates. Represent these positions in a Mask of size 10x10:\n\n```\n[\n (0,0), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7), (0,8), (0,9),\n (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9),\n (2,0), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,7), (2,8), (2,9),\n (3,0), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (3,7), (3,8), (3,9),\n (4,0), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (4,7), (4,8), (4,9),\n (5,0), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (5,7), (5,8), (5,9),\n (6,0), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6), (6,7), (6,8), (6,9),\n (7,0), (7,1), (7,2), (7,3), (7,4), (7,5), (7,6), (7,7), (7,8), (7,9),\n (8,0), (8,1), (8,2), (8,3), (8,4), (8,5), (8,6), (8,7), (8,8), (8,9),\n (9,0), (9,1), (9,2), (9,3), (9,4), (9,5), (9,6), (9,7), (9,8), (9,9),\n]\n```\n\nAnd every position is a Bool value.\n\nDifferent ways to refer to coordinates:\n```\nmask.at(0, 0) # => (0,0)\nmask[0, 0] # => (0,0), same as .at(0, 0)\nmask[0..1, 4] # => (4,0), (4,1)\nmask[3, 3..5] # => (3,3), (3,4), (3,5)\nmask[2..3, 4..5] # => (2,4), (2,5), (3,4), (3,5)\n```\n\nSee `Operation::Crop` and `Operation::MaskApply` for how this can be useful","summary":"

Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel from an image.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` of width x height, preset to `initial`","summary":"

Construct a new Mask of width x height, preset to initial

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(width : Int32, height : Int32, initial : Bool = true)","args_html":"(width : Int32, height : Int32, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L54"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,int:Int)-class-method","name":"new","doc":"Construct a new `Mask` from an integer (useful for testing or small mask construction)","summary":"

Construct a new Mask from an integer (useful for testing or small mask construction)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"args_string":"(width : Int32, height : Int32, int : Int)","args_html":"(width : Int32, height : Int32, int : Int)","location":{"filename":"src/cr-image/mask.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L66"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, int)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(image:Image,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` from the dimensions of passed in `image` with an initial bit","summary":"

Construct a new Mask from the dimensions of passed in image with an initial bit

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(image : Image, initial : Bool = true)","args_html":"(image : Image, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L72"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,bits:BitArray)-class-method","name":"new","doc":"Construct a new `Mask` with a set width and bits from `bits`","summary":"

Construct a new Mask with a set width and bits from #bits

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"args_string":"(width : Int32, bits : BitArray)","args_html":"(width : Int32, bits : BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L49"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&block:Int32,Int32->Bool)-class-method","name":"new","doc":"Construct a new `Mask` of width x height using `&block` to determine if a bit should be true or not (passed in `x` and `y` coordinates)","summary":"

Construct a new Mask of width x height using &block to determine if a bit should be true or not (passed in x and y coordinates)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","args_html":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","location":{"filename":"src/cr-image/mask.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L59"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":2,"block_arity":2,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32 -> Bool)"},"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, &block) do |_arg0, _arg1|\n yield _arg0, _arg1\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other_bits:Array(BitArray))-class-method","name":"new","doc":"Construct a new `Mask` from an array of `BitArray`. See `#[](xs : Range, ys : Range) : Array(BitArray)`\n\nThis assumes `other_bits[0]` corresponds to `x == 0` in the mask, and the corresponding\n`BitArray` represents all bits for that row. All `BitArray`s must be of the same size in\n`other_bits`.","summary":"

Construct a new Mask from an array of BitArray.

","abstract":false,"args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"args_string":"(other_bits : Array(BitArray))","args_html":"(other_bits : Array(BitArray))","location":{"filename":"src/cr-image/mask.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L82"},"def":{"name":"new","args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other_bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:Mask)-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask)","args_html":"(other : Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":188,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L188"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":180,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L180"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"Array(BitArray)","visibility":"Public","body":"ycount.times.to_a.map do |y|\n BitArray.new(xcount) do |x|\n self[x + xstart, y + ystart]\n end\nend"}},{"html_id":"[](x:Int32,y:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `x` and `y`","summary":"

Return the bit at x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool","args_html":"(x : Int32, y : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":153,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L153"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\n@bits[(y * width) + x]\n"}},{"html_id":"[](xs:Range,y:Int32):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial row specified","summary":"

Return a new BitArray corresponding to the partial row specified

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(xs : Range, y : Int32) : BitArray","args_html":"(xs : Range, y : Int32) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":159,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L159"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(xs, width)\nBitArray.new(count) do |x|\n self[x + start, y]\nend\n"}},{"html_id":"[](x:Int32,ys:Range):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial column specified","summary":"

Return a new BitArray corresponding to the partial column specified

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(x : Int32, ys : Range) : BitArray","args_html":"(x : Int32, ys : Range) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L165"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(ys, height)\nBitArray.new(count) do |y|\n self[x, y + start]\nend\n"}},{"html_id":"[](xs:Range,ys:Range):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(xs : Range, ys : Range) : Array(BitArray)","args_html":"(xs : Range, ys : Range) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L173"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xs, width)\nystart, ycount = resolve_to_start_and_count(ys, height)\nself[xstart, xcount, ystart, ycount]\n"}},{"html_id":"[](index:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":140,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L140"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"@bits[index]"}},{"html_id":"[]=(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bit for coordinate `x` and `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20, 20] = true\nmask.to_gray.save(\"mask_point.jpg\")\n```\n\"Black","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":208,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L208"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"self.set(x, y, value)"}},{"html_id":"[]=(xs:Range,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial row `xs` at column `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_row.jpg\")\n```\n\"Black","summary":"

Set the bits for partial row xs at column y

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, y : Int32, value : Bool) : Bool","args_html":"(xs : Range, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":220,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L220"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if y >= height\n raise(IndexError.new(\"Out of bounds: #{y} is beyond the bounds of this mask's height of #{height}\"))\nend\nstart_x, count_x = resolve_to_start_and_count(xs, width)\n@bits.fill(value, (y * width) + start_x, count_x)\nclear_caches\nvalue\n"}},{"html_id":"[]=(x:Int32,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for row `x` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for row x and partial columns ys

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, ys : Range, value : Bool) : Bool","args_html":"(x : Int32, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":236,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L236"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width\n raise(IndexError.new(\"Out of bounds: #{x} is beyond the bounds of this mask's width of #{width}\"))\nend\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n set(x, y + start_y, value)\nend\nvalue\n"}},{"html_id":"[]=(xs:Range,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial rows `xs` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20..40] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for partial rows xs and partial columns ys

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, ys : Range, value : Bool) : Bool","args_html":"(xs : Range, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":253,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L253"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"start_x, count_x = resolve_to_start_and_count(xs, width)\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n @bits.fill(value, ((y + start_y) * width) + start_x, count_x)\nend\nclear_caches\nvalue\n"}},{"html_id":"[]?(x:Int32,y:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool | Nil","args_html":"(x : Int32, y : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":148,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L148"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[(y * width) + x]?"}},{"html_id":"[]?(index:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool | Nil","args_html":"(index : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":144,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L144"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[index]?"}},{"html_id":"|(other:Mask):Mask-instance-method","name":"|","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask) : Mask","args_html":"(other : Mask) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":487,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L487"},"def":{"name":"|","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n bits[i] | other.bits[i]\nend)"}},{"html_id":"apply(image:Image):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":269,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L269"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.apply(self)"}},{"html_id":"apply(image:Image,&block:UInt8,ChannelType,Int32,Int32->UInt8):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","args_html":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":274,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L274"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8)"},"return_type":"Image","visibility":"Public","body":"image.apply(self, &block)"}},{"html_id":"at(index:Int32):Bool-instance-method","name":"at","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L134"},"def":{"name":"at","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if index >= size\n raise(\"Index #{index} exceeds mask size #{@bits.size}\")\nend\n@bits[index]\n"}},{"html_id":"bits:BitArray-instance-method","name":"bits","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L43"},"def":{"name":"bits","return_type":"BitArray","visibility":"Public","body":"@bits"}},{"html_id":"clone-instance-method","name":"clone","doc":"Create a new `Mask` from this one without modifying it","summary":"

Create a new Mask from this one without modifying it

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L107"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"closing(*,diagonal:Bool=true):Mask-instance-method","name":"closing","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L478"},"def":{"name":"closing","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.closing!(diagonal: diagonal)"}},{"html_id":"closing!(*,diagonal:Bool=true):Mask-instance-method","name":"closing!","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":483,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L483"},"def":{"name":"closing!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"dilate!(diagonal: diagonal).erode!(diagonal: diagonal)"}},{"html_id":"dilate(*,diagonal:Bool=true):Mask-instance-method","name":"dilate","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":419,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L419"},"def":{"name":"dilate","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.dilate!(diagonal: diagonal)"}},{"html_id":"dilate!(*,diagonal:Bool=true):self-instance-method","name":"dilate!","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : self","args_html":"(*, diagonal : Bool = true) : self","location":{"filename":"src/cr-image/mask.cr","line_number":424,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L424"},"def":{"name":"dilate!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"self","visibility":"Public","body":"clear_caches\nnew_bits = bits.dup\nx = -1\ny = 0\nbits.size.times do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n if bits[i]\n next\n end\n new_bits[i] = (((((x != 0) && bits[i - 1]) || ((x != (width - 1)) && bits[i + 1])) || ((y != 0) && bits[i - width])) || ((y != (height - 1)) && bits[i + width])) || (diagonal && ((((((x != 0) && (y != 0)) && bits[(i - width) - 1]) || (((x != (width - 1)) && (y != 0)) && bits[(i - width) + 1])) || (((x != 0) && (y != (height - 1))) && bits[(i + width) - 1])) || (((x != (width - 1)) && (y != (height - 1))) && bits[(i + width) + 1])))\nend\n@bits = new_bits\nself\n"}},{"html_id":"erode(*,diagonal:Bool=true):Mask-instance-method","name":"erode","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":458,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L458"},"def":{"name":"erode","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.erode!(diagonal: diagonal)"}},{"html_id":"erode!(*,diagonal:Bool=true):Mask-instance-method","name":"erode!","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":463,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L463"},"def":{"name":"erode!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"invert!.dilate!(diagonal: diagonal).invert!"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L111"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@bits.size // width"}},{"html_id":"invert-instance-method","name":"invert","doc":"Return a new `Mask` that's a copy of this one with all bits inverted.","summary":"

Return a new Mask that's a copy of this one with all bits inverted.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":129,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L129"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert all bits in this instance of `Mask`. Modifies self.\n\n\"Black\n\nBecomes\n\n\"White","summary":"

Invert all bits in this instance of Mask.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":122,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L122"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"html_id":"opening(*,diagonal:Bool=true):Mask-instance-method","name":"opening","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":468,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L468"},"def":{"name":"opening","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.opening!(diagonal: diagonal)"}},{"html_id":"opening!(*,diagonal:Bool=true):Mask-instance-method","name":"opening!","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":473,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L473"},"def":{"name":"opening!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"erode!(diagonal: diagonal).dilate!(diagonal: diagonal)"}},{"html_id":"region:Region-instance-method","name":"region","doc":"Returns the bounding box of the mask where all true bits are contained. Any pixels outside of the region are false\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask[20, 20..40] = true\nmask.region # => Region(x: 20, y: 20, width: 20, height: 20)\n```\n\n\"Black","summary":"

Returns the bounding box of the mask where all true bits are contained.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":296,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L296"},"def":{"name":"region","return_type":"Region","visibility":"Public","body":"@region || (@region = calculate_region)"}},{"html_id":"segments(*,diagonal:Bool=true):Array(Mask)-instance-method","name":"segments","doc":"Return an array of `Mask`s, each one corresponding to an area of contiguous true bits (identified from flood fills).\n\nMay specify `diagonal: false` for only 4-way (up, down, left, right) flood fill instead of default 8-way.\nStarting with sample mask:\n```\nmask = CrImage::Mask.new(50, 50, false)\n\nmask[5..45, 5..45] = true\nmask[15..35, 15..35] = false\nmask[21..25, 21..25] = true\nmask[26..30, 26..30] = true\n```\n\n\"Black\n\nIts segments look like:\n```\nmask.segments.each_with_index do |segment, i|\n segment.to_gray.save(\"mask_8-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\nUsing `diagonal: false` yields:\n```\nmask.segments(diagonal: false).each_with_index do |segment, i|\n segment.to_gray.save(\"mask_4-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\"Black","summary":"

Return an array of Masks, each one corresponding to an area of contiguous true bits (identified from flood fills).

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Array(Mask)","args_html":"(*, diagonal : Bool = true) : Array(Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":360,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L360"},"def":{"name":"segments","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Array(Mask)","visibility":"Public","body":"diagonal ? (@segments_8_way || (@segments_8_way = calculate_segments(diagonal))) : (@segments_4_way || (@segments_4_way = calculate_segments(diagonal)))"}},{"html_id":"set(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"set","doc":"Set the bit for coordinate `x` and `y`","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":194,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L194"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\nclear_caches\n@bits[(y * width) + x] = value\n"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Returns the dimension of this mask (width x height)","summary":"

Returns the dimension of this mask (width x height)

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":102,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L102"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L97"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"bits.size"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Mask` to a `GrayscaleImage`, with false bits becoming 0, and true bits becoming 255","summary":"

Convert this Mask to a GrayscaleImage, with false bits becoming 0, and true bits becoming 255

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":264,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L264"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(bits.map do |b|\n b ? 255_u8 : 0_u8\nend, width, height)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L42"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/NumericMap","path":"CrImage/NumericMap.html","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"including_types":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Additional methods for `Map` that assume `T` is a numeric type. See `MapImpl`","summary":"

Additional methods for Map that assume T is a numeric type.

","instance_methods":[{"html_id":"+(other:NumericMap(T)):NumericMap(T)-instance-method","name":"+","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L39"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"-(other:NumericMap(T)):NumericMap(T)-instance-method","name":"-","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L38"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"max:T-instance-method","name":"max","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L35"},"def":{"name":"max","return_type":"T","visibility":"Public","body":""}},{"html_id":"min:T-instance-method","name":"min","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L36"},"def":{"name":"min","return_type":"T","visibility":"Public","body":""}},{"html_id":"sum:T-instance-method","name":"sum","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":34,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L34"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":""}},{"html_id":"to_c:NumericMap(Complex)-instance-method","name":"to_c","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L31"},"def":{"name":"to_c","return_type":"NumericMap(Complex)","visibility":"Public","body":""}},{"html_id":"to_f:NumericMap(Float64)-instance-method","name":"to_f","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L32"},"def":{"name":"to_f","return_type":"NumericMap(Float64)","visibility":"Public","body":""}},{"html_id":"to_i:NumericMap(Int32)-instance-method","name":"to_i","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L30"},"def":{"name":"to_i","return_type":"NumericMap(Int32)","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/OneMap","path":"CrImage/OneMap.html","kind":"class","full_name":"CrImage::OneMap","name":"OneMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":525,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L525"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Memory efficient implementation of `MapImpl` when all values are equal to `1`","summary":"

Memory efficient implementation of MapImpl when all values are equal to 1

","constructors":[{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/map.cr","line_number":531,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L531"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":574,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L574"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"OneMap.new(xcount, ycount)"}},{"html_id":"[](x:Int32,y:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":550,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L550"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[](xstart:Int32,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : OneMap","args_html":"(xstart : Int32, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":558,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L558"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, ycount = range_to_index_and_count(yrange)\nOneMap.new(1, ycount)\n"}},{"html_id":"[](xrange:Range,ystart:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : OneMap","args_html":"(xrange : Range, ystart : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":563,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L563"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\nOneMap.new(xcount, 1)\n"}},{"html_id":"[](xrange:Range,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : OneMap","args_html":"(xrange : Range, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":568,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L568"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\n_, ycount = range_to_index_and_count(yrange)\nOneMap.new(xcount, ycount)\n"}},{"html_id":"[](index:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":542,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L542"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(x:Int32,y:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":554,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L554"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(index:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":546,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L546"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":529,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L529"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):OneMap|IntMap-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","location":{"filename":"src/cr-image/map.cr","line_number":582,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L582"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"OneMap | IntMap","visibility":"Public","body":"case pad_type\nin EdgePolicy::Black\n to_i.pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: pad_black_value)\nin EdgePolicy::Repeat\n top = top > 0 ? top : all\n bottom = bottom > 0 ? bottom : all\n left = left > 0 ? left : all\n right = right > 0 ? right : all\n @width = @width + (left + right)\n @height = @height + (top + bottom)\n self\nin EdgePolicy::None\n raise(Exception.new(\"Pad method doesn't support edge policy None\"))\nend"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":534,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L534"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":538,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L538"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"width * height"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":601,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L601"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, Array(Complex).new(size) do\n Complex.new(1)\nend)"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":597,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L597"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, Array(Int32).new(size) do\n 1\nend)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":528,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L528"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Operation","path":"CrImage/Operation.html","kind":"module","full_name":"CrImage::Operation","name":"Operation","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/operation/operation.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/operation.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Module for containing individual operations for `Image` classes.","summary":"

Module for containing individual operations for Image classes.

","types":[{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","path":"CrImage/Operation/BilinearResize.html","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Resize an image using a bilinear resizing algorithm.\n\nTaking sample `image`:\n\n\"Woman\n\n```\nputs image.width, image.height # => 159x199\nimage.bilinear_resize(40, 50).save(\"small_sample.jpg\")\nimage.bilinear_resize(200, 250).save(\"larger_sample.jpg\")\n```\n\"Sample\n\"Sample","summary":"

Resize an image using a bilinear resizing algorithm.

","instance_methods":[{"html_id":"bilinear_resize(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize","doc":"Resizes image to new dimensions","summary":"

Resizes image to new dimensions

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L16"},"def":{"name":"bilinear_resize","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.bilinear_resize!(width, height)"}},{"html_id":"bilinear_resize!(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize!","doc":"Resizes image to new dimensions. Modifies self.","summary":"

Resizes image to new dimensions.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L21"},"def":{"name":"bilinear_resize!","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"x_ratio = width > 1 ? (@width - 1) / (width - 1) : 0\ny_ratio = height > 1 ? (@height - 1) / (height - 1) : 0\neach_channel do |channel, channel_type|\n resized_channel = Array.new(width * height) do\n 0_u8\n end\n height.times do |h|\n width.times do |w|\n x = w * x_ratio\n y = h * y_ratio\n x_ceil = Math.min(@width - 1, x.ceil.to_i)\n x_floor = x.floor.to_i\n y_ceil = Math.min(@height - 1, y.ceil.to_i)\n y_floor = y.floor.to_i\n value = case\n when (x_ceil == x_floor) && (y_ceil == y_floor)\n x_index = x.to_i\n y_index = y.to_i\n channel.unsafe_fetch((@width * y_index) + x_index)\n when x_ceil == x_floor\n x_index = x.to_i\n q_1 = channel.unsafe_fetch((@width * y_ceil) + x_index)\n q_2 = channel.unsafe_fetch((@width * y_floor) + x_index)\n ((q_2 * (y_ceil - y)) + (q_1 * (y - y_floor))).to_u8\n when y_ceil == y_floor\n y_index = y.to_i\n q_1 = channel.unsafe_fetch((@width * y_index) + x_ceil)\n q_2 = channel.unsafe_fetch((@width * y_index) + x_floor)\n ((q_2 * (x_ceil - x)) + (q_1 * (x - x_floor))).to_u8\n else\n v_1 = channel.unsafe_fetch((@width * y_floor) + x_floor)\n v_2 = channel.unsafe_fetch((@width * y_floor) + x_ceil)\n v_3 = channel.unsafe_fetch((@width * y_ceil) + x_floor)\n v_4 = channel.unsafe_fetch((@width * y_ceil) + x_ceil)\n q_1 = (v_1 * (x_ceil - x)) + (v_2 * (x - x_floor))\n q_2 = (v_3 * (x_ceil - x)) + (v_4 * (x - x_floor))\n ((q_1 * (y_ceil - y)) + (q_2 * (y - y_floor))).to_u8\n end\n resized_channel.unsafe_put((width * h) + w, value)\n end\n end\n self[channel_type] = resized_channel\nend\n@width = width\n@height = height\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","path":"CrImage/Operation/BoxBlur.html","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/box_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blurs the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.box_blur(1).save(\"blurred_1_sample.jpg\")\nimage.box_blur(5).save(\"blurred_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blurs the image

","instance_methods":[{"html_id":"box_blur(value:Int32):self-instance-method","name":"box_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L14"},"def":{"name":"box_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.box_blur!(value)"}},{"html_id":"box_blur!(value:Int32):self-instance-method","name":"box_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L18"},"def":{"name":"box_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"horizontal_blur!(value)\nvertical_blur!(value)\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Brightness","path":"CrImage/Operation/Brightness.html","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness","abstract":false,"locations":[{"filename":"src/cr-image/operation/brightness.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Brightens an image (increases white value)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.brightness(2.0)\n```\n\"Brightened","summary":"

Brightens an image (increases white value)

","instance_methods":[{"html_id":"brightness(value:Float64):self-instance-method","name":"brightness","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L12"},"def":{"name":"brightness","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.brightness!(value)"}},{"html_id":"brightness!(value:Float64):self-instance-method","name":"brightness!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L16"},"def":{"name":"brightness!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"each_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, ( (channel.unsafe_fetch(index)) * value))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","path":"CrImage/Operation/ChannelSwap.html","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap","abstract":false,"locations":[{"filename":"src/cr-image/operation/channel_swap.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Swaps channels of `ChannelType` supported by an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.channel_swap(:green, :red) # Crystal autocasting of symbols to Pluto::ChannelType enum is magic\n```\n\"Channel","summary":"

Swaps channels of ChannelType supported by an image

","instance_methods":[{"html_id":"channel_swap(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L12"},"def":{"name":"channel_swap","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"clone.channel_swap!(a, b)"}},{"html_id":"channel_swap!(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap!","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L16"},"def":{"name":"channel_swap!","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"ch_a, ch_b = self[a], self[b]\nself[a] = ch_b\nself[b] = ch_a\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Contrast","path":"CrImage/Operation/Contrast.html","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast","abstract":false,"locations":[{"filename":"src/cr-image/operation/contrast.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Increases contrast of an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.contrast(20)\n```\n\"Contrasted","summary":"

Increases contrast of an image

","instance_methods":[{"html_id":"contrast(value:Float64):self-instance-method","name":"contrast","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L12"},"def":{"name":"contrast","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.contrast!(value)"}},{"html_id":"contrast!(value:Float64):self-instance-method","name":"contrast!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L16"},"def":{"name":"contrast!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"factor = (259 * (value + 255)) / (255 * (259 - value))\neach_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, Math.max(0, (factor * ((channel.unsafe_fetch(index)).to_i - 128)) + 128))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Crop","path":"CrImage/Operation/Crop.html","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop","abstract":false,"locations":[{"filename":"src/cr-image/operation/crop.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Crops an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\n# These calls are equivalent\nimage.crop(40, 30, 80, 80)\nimage[40...120, 30...110]\n```\n\"Cropped","summary":"

Crops an image

","instance_methods":[{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xrange, width)\nystart, ycount = resolve_to_start_and_count(yrange, height)\ncrop(xstart, ystart, xcount, ycount)\n"}},{"html_id":"crop(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L18"},"def":{"name":"crop","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.crop!(x, y, new_width, new_height)"}},{"html_id":"crop(region:Region):self-instance-method","name":"crop","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L14"},"def":{"name":"crop","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop(*region.to_tuple)"}},{"html_id":"crop!(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L32"},"def":{"name":"crop!","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"each_channel do |channel, channel_type|\n self[channel_type] = (UInt8Map.new(width, channel))[x, new_width, y, new_height].raw\nend\n@width = new_width\n@height = new_height\nself\n"}},{"html_id":"crop!(region:Region):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L28"},"def":{"name":"crop!","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop!(*region.to_tuple)"}}]},{"html_id":"Crystal Image/CrImage/Operation/Draw","path":"CrImage/Operation/Draw.html","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw","abstract":false,"locations":[{"filename":"src/cr-image/operation/draw.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L17"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Draws shapes in the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.draw_square(40, 30, 80, 80, CrImage::Color.of(\"#00f\"))\nimage.draw_circle(80, 70, 40, CrImage::Color.of(\"#00f\"))\nimage.draw_line(50, 50, 70, 90, CrImage::Color.of(\"#0f0\"))\n```\n\"Woman\n\"Woman\n\"Woman\n\nCan also use the `fill: true` parameter to fill in the drawn shapes","summary":"

Draws shapes in the image

","instance_methods":[{"html_id":"draw_circle(x:Int,y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle centered at x, y with radius","summary":"

Draw a circle centered at x, y with radius

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L59"},"def":{"name":"draw_circle","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(x, y, radius, color, fill: fill)"}},{"html_id":"draw_circle(region:Region,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L54"},"def":{"name":"draw_circle","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":3,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_circle!(center_x:Int,center_y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle!","abstract":false,"args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L68"},"def":{"name":"draw_circle!","args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"min_x = Math.max(0, center_x - radius)\nmax_x = Math.min(width - 1, center_x + radius)\nmax_y = Math.min(height - 1, center_y + radius)\neach_color_channel do |channel, channel_type|\n 0.upto(radius) do |y|\n theta_0 = Math.asin((Math.max(0, ( y - 1))) / radius.to_f)\n theta_1 = Math.asin(y / radius.to_f)\n x_0 = (radius * (Math.cos(theta_0))).round\n x_1 = (radius * (Math.cos(theta_1))).round\n lower_x_outer = (Math.max(min_x, center_x - x_0)).to_i\n lower_x_inner = (Math.max(min_x, center_x - x_1)).to_i\n upper_x_outer = (Math.min(max_x, center_x + x_0)).to_i\n upper_x_inner = (Math.min(max_x, center_x + x_1)).to_i\n lower_y = center_y - y\n upper_y = center_y + y\n lower_y_outside_of_image = (center_y - y) < 0 || (center_y - y) > max_y\n upper_y_outside_of_image = (center_y + y) < 0 || (center_y + y) > max_y\n left_outer_x_beyond_right_of_image = (center_x - x_0) > max_x\n right_outer_x_beyond_left_of_image = (center_x + x_0) < 0\n left_inner_x_beyond_left_of_image = (center_x - x_1) < 0\n right_inner_x_beyond_right_of_image = (center_x + x_1) > max_x\n if fill\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n else\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(upper_x_inner, lower_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(upper_x_inner, upper_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n end\n end\nend\nself\n"}},{"html_id":"draw_circle!(region:Region,color:Color,*,fill:Bool=false,radius:Int32|Nil=nil):self-instance-method","name":"draw_circle!","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L64"},"def":{"name":"draw_circle!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_line(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L134"},"def":{"name":"draw_line","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.draw_line!(x1, y1, x2, y2, color)"}},{"html_id":"draw_line!(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line!","doc":"Implementation of http://www.edepot.com/linec.html","summary":"

Implementation of http://www.edepot.com/linec.html

","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":139,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L139"},"def":{"name":"draw_line!","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"if (0 <= x1 && x1 < width) && (0 <= y1 && y1 < height)\nelse\n raise(Exception.new(\"First point (#{x1},#{y1}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nif (0 <= x2 && x2 < width) && (0 <= y2 && y2 < height)\nelse\n raise(Exception.new(\"Second point (#{x2},#{y2}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nrise_by_height = false\nshort = y2 - y1\nlong = x2 - x1\nif short.abs > long.abs\n short, long = long, short\n rise_by_height = true\nend\nend_val = long\ngradient = long == 0 ? short : short / long.abs.to_f\nif rise_by_height\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + jump.to_i, y1 + i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nelse\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + i, y1 + jump.to_i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nend\nself\n"}},{"html_id":"draw_square(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L22"},"def":{"name":"draw_square","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"clone.draw_square!(x, y, box_width, box_height, color, fill: fill)"}},{"html_id":"draw_square(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L18"},"def":{"name":"draw_square","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"clone.draw_square!(region, color, fill: fill)"}},{"html_id":"draw_square!(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L30"},"def":{"name":"draw_square!","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"if (x + box_width) > width\n raise(\"Box dimensions extend #{((x + box_width) - width) + 1} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{((y + box_height) - height) + 1} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_color_channel do |channel, channel_type|\n channel[( (y_i * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n channel[((y_i + box_height) * width) + x_i, box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n box_height.times do |i|\n if i == 0\n next\n end\n if fill\n channel[( ((y_i + i) * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n else\n channel.unsafe_put(((y_i + i) * width) + x_i, color[channel_type])\n channel.unsafe_put(((((y_i + i) * width) + x_i) + box_width) - 1, color[channel_type])\n end\n end\nend\nself\n"}},{"html_id":"draw_square!(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L26"},"def":{"name":"draw_square!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_square!(*region.to_tuple, color, fill: fill)"}}]},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","path":"CrImage/Operation/GaussianBlur.html","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Applies a 3x3 Gaussian blur. Implementation derived from [here](https://blog.ivank.net/fastest-gaussian-blur.html)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.gaussian_blur(1).save(\"gaussian_1_sample.jpg\")\nimage.gaussian_blur(5).save(\"gaussian_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Applies a 3x3 Gaussian blur.

","instance_methods":[{"html_id":"gaussian_blur(sigma:Int32):self-instance-method","name":"gaussian_blur","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L14"},"def":{"name":"gaussian_blur","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.gaussian_blur!(sigma)"}},{"html_id":"gaussian_blur!(sigma:Int32):self-instance-method","name":"gaussian_blur!","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L18"},"def":{"name":"gaussian_blur!","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"n = 3\nw_ideal = Math.sqrt((((12 * sigma) * sigma) / n) + 1)\nw_l = w_ideal.floor.to_i\nif (w_l % 2) == 0\n w_l = w_l - 1\nend\nm_ideal = (((((12 * sigma) * sigma) - ((n * w_l) * w_l)) - ((4 * n) * w_l)) - (3 * n)) / ((-4 * w_l) - 4)\nm = m_ideal.round\nsizes = [] of Int32\nn.times do |i|\n sizes << (if i < m\n w_l\n else\n w_l + 2\n end)\nend\nbox_blur!(((sizes.unsafe_fetch(0)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(1)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(2)) - 1) // 2)\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","path":"CrImage/Operation/HistogramEqualize.html","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize","abstract":false,"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":19,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Provides methods for histogram and histogram equalization. Follows method outlined [here](https://www.sci.utah.edu/~acoste/uou/Image/project1/Arthur_COSTE_Project_1_report.html)\n\nIf an image is particularly dark or particularly bright with low contrast, the `Operation::Contrast#contrast` method will only\nmake the image darker or lighter. For images like these, equalizing the image along its histogram will produce better results.\n\n\"A\n\n```\nimage.contrast(10).save(\"contrast.jpg\")\nimage.histogram_equalize.save(\"equalized.jpg\")\n```\n\"Darker\n\"A\n\nThis method does not work well when a given method has a bimodal distribution of color pixels. For example:\n\n\"Woman\n\"Highly","summary":"

Provides methods for histogram and histogram equalization.

","instance_methods":[{"html_id":"histogram(channel_type:ChannelType):Histogram-instance-method","name":"histogram","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Histogram","args_html":"(channel_type : ChannelType) : Histogram","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L107"},"def":{"name":"histogram","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Histogram","visibility":"Public","body":"Histogram.new(self, channel_type)"}},{"html_id":"histogram_equalize:self-instance-method","name":"histogram_equalize","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L111"},"def":{"name":"histogram_equalize","return_type":"self","visibility":"Public","body":"clone.histogram_equalize!"}},{"html_id":"histogram_equalize!:self-instance-method","name":"histogram_equalize!","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":115,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L115"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_color_channel do |channel, channel_type|\n if channel_type.alpha?\n next\n end\n remap = (histogram(channel_type)).equalize\n size.times do |i|\n channel.unsafe_put(i, remap[channel.unsafe_fetch(i)])\n end\nend\nself\n"}}],"types":[{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize/Histogram","path":"CrImage/Operation/HistogramEqualize/Histogram.html","kind":"class","full_name":"CrImage::Operation::HistogramEqualize::Histogram","name":"Histogram","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},"doc":"A histogram of an `Image` for a specific `ChannelType`","summary":"

A histogram of an Image for a specific ChannelType

","constructors":[{"html_id":"new(image:Image,channel_type:ChannelType)-class-method","name":"new","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(image : Image, channel_type : ChannelType)","args_html":"(image : Image, channel_type : ChannelType)","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L24"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, channel_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"cdf:Hash(UInt8,Float64)-instance-method","name":"cdf","doc":"Get the cumulative distribution for the image's histogram","summary":"

Get the cumulative distribution for the image's histogram

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L56"},"def":{"name":"cdf","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"total = 0_f64\n@cumulative_distribution_histogram || (@cumulative_distribution_histogram = normalize.map do |pixel, probability|\n original = total\n total = total + probability\n {pixel, original}\nend.to_h)\n"}},{"html_id":"channel_type:CrImage::ChannelType-instance-method","name":"channel_type","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"channel_type","visibility":"Public","body":"@channel_type"}},{"html_id":"counts:Hash(UInt8,Int32)-instance-method","name":"counts","doc":"Get the raw counts for a given pixel value (0-255) in the image","summary":"

Get the raw counts for a given pixel value (0-255) in the image

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L30"},"def":{"name":"counts","return_type":"Hash(UInt8, Int32)","visibility":"Public","body":"@internal_hist || (@internal_hist = calculate_counts)"}},{"html_id":"equalize:Hash(UInt8,UInt8)-instance-method","name":"equalize","doc":"Remap the cumalitive distribution of pixels to get a new, more spread out pixel value","summary":"

Remap the cumalitive distribution of pixels to get a new, more spread out pixel value

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L66"},"def":{"name":"equalize","return_type":"Hash(UInt8, UInt8)","visibility":"Public","body":"cdf.map do |pixel, cumalative|\n {pixel, ((cumalative * 255).clamp(0, 255)).to_u8}\nend.to_h"}},{"html_id":"image:CrImage::Image-instance-method","name":"image","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"image","visibility":"Public","body":"@image"}},{"html_id":"mean:Float64-instance-method","name":"mean","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L74"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@mean || (@mean = counts.sum do |pixel, count|\n pixel.to_i64 * count\nend.to_f64 / @image.size)"}},{"html_id":"normalize:Hash(UInt8,Float64)-instance-method","name":"normalize","doc":"Get pixel counts normalized - all values between 0.0 and 1.0","summary":"

Get pixel counts normalized - all values between 0.0 and 1.0

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L47"},"def":{"name":"normalize","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"counts.map do |pixel, count|\n {pixel, count.to_f / @image.size}\nend.to_h"}},{"html_id":"std_dev:Float64-instance-method","name":"std_dev","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L80"},"def":{"name":"std_dev","return_type":"Float64","visibility":"Public","body":"@std_dev || (@std_dev = Math.sqrt(counts.sum do |value, count|\n count * ((value.to_i64 - mean) ** 2)\nend.to_f64 / @image.size))"}}]}]},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","path":"CrImage/Operation/HorizontalBlur.html","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the horizontal axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.horizontal_blur(1).save(\"horizontal_1_sample.jpg\")\nimage.horizontal_blur(5).save(\"horizontal_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the horizontal axis

","instance_methods":[{"html_id":"horizontal_blur(k:Int32):self-instance-method","name":"horizontal_blur","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(k)"}},{"html_id":"horizontal_blur!(k:Int32):self-instance-method","name":"horizontal_blur!","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_blur!","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((k + k) + 1)\neach_color_channel do |channel|\n @height.times do |y|\n center_index : Int32 = y * @width\n left__bound : Int32 = center_index\n right_bound : Int32 = center_index + k\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last__value : Int32 = (channel.unsafe_fetch((center_index + @width) - 1)).to_i\n current_sum : Int32 = (k + 1) * first_value\n (0..(k - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + i))\n end\n (0..k).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n center_index = center_index + 1\n end\n ((k + 1)..((@width - k) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n ((@width - k)..(@width - 1)).each do\n current_sum = current_sum + (last__value - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","path":"CrImage/Operation/MaskApply.html","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply","abstract":false,"locations":[{"filename":"src/cr-image/operation/mask_apply.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Apply a mask to an image\n\nTaking sample `image`:\n\n\"Woman\n\nAnd mask\n\n\"Black\n\n```\nmask = CrImage::Mask.new(image, false)\nmask[50..90, 65..75] = true\nmask.to_gray.save(\"apply_mask_mask.jpg\")\n\nimage.apply(mask).save(\"apply_mask.jpg\")\n\nimage.apply_color(mask, CrImage::Color.of(\"#00f\")).save(\"apply_mask_color.jpg\")\n\nimage.apply(mask) do |pixel, channel_type, x, y|\n Math.min(255, pixel + 50).to_u8 if channel_type.blue?\nend.save(\"apply_mask_block.jpg\")\n```\n\"Image\n\"Thin\n\"Thin","summary":"

Apply a mask to an image

","instance_methods":[{"html_id":"apply(mask:Mask):self-instance-method","name":"apply","doc":"Black out all pixels but those found in the mask","summary":"

Black out all pixels but those found in the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L29"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"clone.apply!(mask)"}},{"html_id":"apply(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply","doc":"Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.\n\nDoes not change values not matched by the mask","summary":"

Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L36"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"clone.apply!(mask, &block)"}},{"html_id":"apply!(mask:Mask):self-instance-method","name":"apply!","doc":"TODO: add apply version that accepts 1+ ChannelType that the mask should apply to (i.e. make a background completely transparent, not just transparent black)","summary":"

TODO add apply version that accepts 1+ ChannelType that the mask should apply to (i.e.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L46"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? pixel : 0_u8\n end\nend\nself\n"}},{"html_id":"apply!(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L55"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel, channel_type|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? (block.call(pixel, channel_type, i % width, i // width)) || pixel : pixel\n end\nend\nself\n"}},{"html_id":"apply_color(mask:Mask,color:Color):self-instance-method","name":"apply_color","doc":"Change the color of all pixels that match the mask","summary":"

Change the color of all pixels that match the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L41"},"def":{"name":"apply_color","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.apply_color!(mask, color)"}},{"html_id":"apply_color!(mask:Mask,color:Color):self-instance-method","name":"apply_color!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L66"},"def":{"name":"apply_color!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"apply!(mask) do |_, channel_type|\n color[channel_type]\nend"}}]},{"html_id":"Crystal Image/CrImage/Operation/Pad","path":"CrImage/Operation/Pad.html","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad","abstract":false,"locations":[{"filename":"src/cr-image/operation/pad.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Pads an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.pad(left: 50, right: 50)\nimage.pad(left: 50, right: 50, pad_type: CrImage::EdgePolicy::Repeat)\n```\n\"Picture\n\"Picture","summary":"

Pads an image

","instance_methods":[{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L14"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.pad!(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type)"}},{"html_id":"pad!(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad!","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L18"},"def":{"name":"pad!","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"orig_width = width\neach_channel do |channel, channel_type|\n padded = (UInt8Map.new(orig_width, channel)).pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: channel_type.default)\n self[channel_type] = padded.raw\n @width = padded.width\n @height = padded.height\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Rotate","path":"CrImage/Operation/Rotate.html","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate","abstract":false,"locations":[{"filename":"src/cr-image/operation/rotate.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Rotates an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.rotate(45)\nimage.rotate(45, pad: true)\n```\n\"Rotated\n\"Rotated","summary":"

Rotates an image

","instance_methods":[{"html_id":"rotate(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate","doc":"Rotates an image by `degrees`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L20"},"def":{"name":"rotate","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.rotate!(degrees, center_x: center_x, center_y: center_y, radius: radius, pad: pad, pad_type: pad_type)"}},{"html_id":"rotate!(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate!","doc":"Rotates an image by `degrees`. Modifies `self`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees.

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L38"},"def":{"name":"rotate!","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"if pad_type.none?\n raise(Exception.new(\"Edge policy None doesn't apply to rotation\"))\nend\nif pad && radius >= 0\n raise(Exception.new(\"Can't pad image and limit rotation by radius\"))\nend\nradians = ((-Math::PI) * degrees) / 180\nsin = Math.sin(radians)\ncos = Math.cos(radians)\nradius_sq = radius * radius\nnew_width, new_size, out_center_x, out_center_y = output_dimensions(pad, degrees, center_x, center_y)\neach_channel do |channel, channel_type|\n new_x = -1\n new_y = 0\n self[channel_type] = Array.new(new_size) do |i|\n new_x = new_x + 1\n if new_x == new_width\n new_x = 0\n new_y = new_y + 1\n end\n if radius >= 0 && (((new_x - center_x) ** 2) + ((new_y - center_y) ** 2)) > radius_sq\n next channel.unsafe_fetch(i)\n end\n orig_x = (((cos * (new_x - out_center_x)) - (sin * (new_y - out_center_y))) + center_x).round.to_i\n orig_y = (((sin * (new_x - out_center_x)) + (cos * (new_y - out_center_y))) + center_y).round.to_i\n if pad_type.black?\n if ((orig_x < 0 || orig_x >= width) || orig_y < 0) || orig_y >= height\n next channel_type.default\n end\n else\n orig_x = orig_x.clamp(0, width - 1)\n orig_y = orig_y.clamp(0, height - 1)\n end\n channel.unsafe_fetch((orig_y * width) + orig_x)\n end\nend\n@width = new_width\n@height = new_size // new_width\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","path":"CrImage/Operation/VerticalBlur.html","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the vertical axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.vertical_blur(1).save(\"vertical_1_sample.jpg\")\nimage.vertical_blur(5).save(\"vertical_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the vertical axis

","instance_methods":[{"html_id":"vertical_blur(value:Int32):self-instance-method","name":"vertical_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L14"},"def":{"name":"vertical_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.vertical_blur!(value)"}},{"html_id":"vertical_blur!(value:Int32):self-instance-method","name":"vertical_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L18"},"def":{"name":"vertical_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((value + value) + 1)\neach_color_channel do |channel|\n @width.times do |x|\n center_index : Int32 = x\n left_bound : Int32 = center_index\n right_bound : Int32 = center_index + (value * @width)\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last_value : Int32 = (channel.unsafe_fetch(center_index + (@width * (@height - 1)))).to_i\n current_sum : Int32 = (value + 1) * first_value\n (0..(value - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + (i * @width)))\n end\n (0..value).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n current_sum = current_sum + (last_value - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n center_index = center_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"Crystal Image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a rectangular area on an `Image` from its upper left corner `x` and `y` coordinates, and a `width` and `height`.\n\nSee `Operation::Crop#crop` and `Operation::Draw#draw_square` for examples using it.","summary":"

Represents a rectangular area on an Image from its upper left corner #x and #y coordinates, and a #width and #height.

","constructors":[{"html_id":"center(x:UInt16,y:UInt16,width:UInt16,height:UInt16):Region-class-method","name":"center","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","location":{"filename":"src/cr-image/region.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L11"},"def":{"name":"center","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"return_type":"Region","visibility":"Public","body":"new(x - (width // 2), y - (height // 2), width, height)"}},{"html_id":"new(x:UInt16,y:UInt16,width:UInt16,height:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"new","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(x, y, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"center:Tuple(Int32,Int32)-instance-method","name":"center","doc":"Return the `{x, y}` tuple of the center coordinates of this `Region`","summary":"

Return the {x, y} tuple of the center coordinates of this Region

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L21"},"def":{"name":"center","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{(width.to_i // 2) + x.to_i, (height.to_i // 2) + y.to_i}"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@x.clone, @y.clone, @width.clone, @height.clone)"}},{"html_id":"copy_with(x_x=@x,y_y=@y,width_width=@width,height_height=@height)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"args_string":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","args_html":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"copy_with","args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"visibility":"Public","body":"self.class.new(_x, _y, _width, _height)"}},{"html_id":"crop(image:Image):Image-instance-method","name":"crop","doc":"Crop a provided `Image` with this region, using `Operation::Crop#crop`","summary":"

Crop a provided Image with this region, using Operation::Crop#crop

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/region.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L16"},"def":{"name":"crop","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.crop(self)"}},{"html_id":"height:UInt16-instance-method","name":"height","abstract":false,"def":{"name":"height","return_type":"UInt16","visibility":"Public","body":"@height"}},{"html_id":"to_tuple:Tuple(Int32,Int32,Int32,Int32)-instance-method","name":"to_tuple","doc":"Return this `Region` as a `x`, `y`, `width`, and `height` tuple","summary":"

Return this Region as a #x, #y, #width, and #height tuple

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L26"},"def":{"name":"to_tuple","return_type":"Tuple(Int32, Int32, Int32, Int32)","visibility":"Public","body":"{x.to_i, y.to_i, width.to_i, height.to_i}"}},{"html_id":"width:UInt16-instance-method","name":"width","abstract":false,"def":{"name":"width","return_type":"UInt16","visibility":"Public","body":"@width"}},{"html_id":"x:UInt16-instance-method","name":"x","abstract":false,"def":{"name":"x","return_type":"UInt16","visibility":"Public","body":"@x"}},{"html_id":"y:UInt16-instance-method","name":"y","abstract":false,"def":{"name":"y","return_type":"UInt16","visibility":"Public","body":"@y"}}]},{"html_id":"Crystal Image/CrImage/RepeatView","path":"CrImage/RepeatView.html","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":52,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L52"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to the nearest edge of that `Map`","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to the nearest edge of that Map

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = RepeatView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L53"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = ((x - @half_width) + @map_x).clamp(0, @map.width - 1)\nadjusted_y = ((y - @half_height) + @map_y).clamp(0, @map.height - 1)\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/rgba_image.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L2"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L36"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L29"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image with red, green, blue, and alpha color channels (i.e. a color image). This image type is likely the one read from and written to file (or `IO`).","summary":"

An image with red, green, blue, and alpha color channels (i.e.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L10"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L13"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):Color-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Color","args_html":"(x : Int32, y : Int32) : Color","location":{"filename":"src/cr-image/rgba_image.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L49"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Color","visibility":"Public","body":"index = (y * width) + x\nColor.new(red[index], green[index], blue[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the channel corresponding to `channel_type`","summary":"

Return the channel corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L55"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red\nwhen ChannelType::Green\n @green\nwhen ChannelType::Blue\n @blue\nwhen ChannelType::Alpha\n @alpha\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the corresponding `channel_type` with `channel`","summary":"

Set the corresponding channel_type with channel

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L66"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red = channel\nwhen ChannelType::Green\n @green = channel\nwhen ChannelType::Blue\n @blue = channel\nwhen ChannelType::Alpha\n @alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@blue"}},{"html_id":"blue=(blue:Array(UInt8))-instance-method","name":"blue=","abstract":false,"args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"args_string":"(blue : Array(UInt8))","args_html":"(blue : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue=","args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@blue = blue"}},{"html_id":"clone:RGBAImage-instance-method","name":"clone","doc":"Create a copy of this image","summary":"

Create a copy of this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L21"},"def":{"name":"clone","return_type":"RGBAImage","visibility":"Public","body":"self.class.new(@red.clone, @green.clone, @blue.clone, @alpha.clone, @width, @height)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L41"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L33"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nnil\n"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@green"}},{"html_id":"green=(green:Array(UInt8))-instance-method","name":"green=","abstract":false,"args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"args_string":"(green : Array(UInt8))","args_html":"(green : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green=","args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@green = green"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"mask_from(&block:Color,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":103,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L103"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Color, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(Color.new(red.unsafe_fetch(i), green.unsafe_fetch(i), blue.unsafe_fetch(i), alpha.unsafe_fetch(i)), x, y)\nend)\n"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@red"}},{"html_id":"red=(red:Array(UInt8))-instance-method","name":"red=","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"args_string":"(red : Array(UInt8))","args_html":"(red : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red=","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@red = red"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels in this image","summary":"

Return the number of pixels in this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L99"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"to_gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert color image to `GrayscaleImage`, using the NTSC formula as default values.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Convert color image to GrayscaleImage, using the NTSC formula as default values.

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","location":{"filename":"src/cr-image/rgba_image.cr","line_number":83,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L83"},"def":{"name":"to_gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(red.map_with_index do |red_pix, i|\n (Math.min(255, ((red_pix * red_multiplier) + (@green[i] * green_multiplier)) + (@blue[i] * blue_multiplier))).to_u8\nend, width, height)"}},{"html_id":"to_pluto:Pluto::ImageRGBA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L37"},"def":{"name":"to_pluto","return_type":"Pluto::ImageRGBA","visibility":"Public","body":"Pluto::ImageRGBA.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":94,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L94"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"self"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L30"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.red.to_u16 << 8, color.green.to_u16 << 8, color.blue.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"Crystal Image/CrImage/UInt8Map","path":"CrImage/UInt8Map.html","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":495,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L495"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `UInt8` types. This type is useful for `MapImpl` operations around channels.","summary":"

Implementation of MapImpl for UInt8 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":502,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L502"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":498,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L498"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":496,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L496"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Window","path":"CrImage/Window.html","kind":"class","full_name":"CrImage::Window(T)","name":"Window","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L8"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/BlackView","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView"},{"html_id":"Crystal Image/CrImage/ErrorView","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView"},{"html_id":"Crystal Image/CrImage/RepeatView","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a read-only view on top of a `Map`.\n\nConstructing one of these over a larger `Map` allows for a re-indexed view within that map. If needing to sum all values\nwithin a certain area, a `Window` can be constructed around that area and then summed from that.\n\nSee `RepeatView`, `ErrorView`, and `BlackView` for specific edge handling cases.","summary":"

Represents a read-only view on top of a Map.

","constructors":[{"html_id":"new(width:Int32,height:Int32,map:CrImage::Map(T),map_x:Int32,map_y:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","args_html":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"visibility":"Public","body":"_ = Window(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L22"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"half_height:Int32-instance-method","name":"half_height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L10"},"def":{"name":"half_height","return_type":"Int32","visibility":"Public","body":"@half_height"}},{"html_id":"half_width:Int32-instance-method","name":"half_width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L9"},"def":{"name":"half_width","return_type":"Int32","visibility":"Public","body":"@half_width"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L12"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"map:Map(T)-instance-method","name":"map","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L13"},"def":{"name":"map","return_type":"Map(T)","visibility":"Public","body":"@map"}},{"html_id":"map_x:Int32-instance-method","name":"map_x","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L14"},"def":{"name":"map_x","return_type":"Int32","visibility":"Public","body":"@map_x"}},{"html_id":"map_y:Int32-instance-method","name":"map_y","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L15"},"def":{"name":"map_y","return_type":"Int32","visibility":"Public","body":"@map_y"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Calculate the mean for all values in the window","summary":"

Calculate the mean for all values in the window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L41"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"sum / size"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the size of this window","summary":"

Return the size of this window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L46"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"sum:Float64-instance-method","name":"sum","doc":"Sum all values in the window together","summary":"

Sum all values in the window together

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":25,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L25"},"def":{"name":"sum","return_type":"Float64","visibility":"Public","body":"sum(&.itself)"}},{"html_id":"sum(&:T,Int32,Int32,self->T):Float64-instance-method","name":"sum","doc":"Iterate over all values within the window and sum the result of the passed in block","summary":"

Iterate over all values within the window and sum the result of the passed in block

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L30"},"def":{"name":"sum","yields":4,"block_arity":4,"block_arg":{"name":"","external_name":"","restriction":"(T, Int32, Int32, self -> T)"},"return_type":"Float64","visibility":"Public","body":"ret = 0_f64\nheight.times do |y|\n width.times do |x|\n ret = ret + (yield self[x, y], x, y, self).to_f64\n end\nend\nret\n"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L11"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]}]},{"html_id":"Crystal Image/Pluto","path":"Pluto.html","kind":"module","full_name":"Pluto","name":"Pluto","abstract":false,"locations":[{"filename":"lib/pluto/src/pluto.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto.cr#L3"},{"filename":"lib/pluto/src/pluto/channel_type.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/channel_type.cr#L1"},{"filename":"src/pluto.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L20"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This project was initially a fork of [Pluto](https://github.com/phenopolis/pluto/), and so can very easily convert\nbetween the underlying format used by `CrImage` and `Pluto`. To easily convert a `Pluto` image to `CrImage`, simply:\n\n```\nrequire \"cr-image/pluto\"\n\nimage # => Pluto::ImageRGBA\nimage.to_crimage # => CrImage::RGBAImage\nimage.to_crimage.to_pluto # => Pluto::ImageRGBA\n```\nThis also works with `Pluto::ImageGA` and `CrImage::GrayscaleImage`, respectively.\n\n> Why are `ImageRGBA` and `RGBAImage` names mirrored?\n\nThe current `CrImage` names are a carry over from when originally forked from `Pluto`. However, after `Pluto` renamed `RGBAImage` to `ImageRGBA`, I noticed it became\nmore difficult to visually distinguish between `ImageRGBA` and `ImageGA`, as opposed to `RGBAImage` and `GrayscaleImage`, so I kept the older names.","summary":"

This project was initially a fork of Pluto, and so can very easily convert between the underlying format used by CrImage and Pluto.

","types":[{"html_id":"Crystal Image/Pluto/ImageGA","path":"Pluto/ImageGA.html","kind":"class","full_name":"Pluto::ImageGA","name":"ImageGA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_ga.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/image_ga.cr#L3"},{"filename":"src/pluto.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::GrayscaleImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/pluto.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L29"},"def":{"name":"to_crimage","return_type":"CrImage::GrayscaleImage","visibility":"Public","body":"new(gray.clone, alpha.clone, width, height)"}}]},{"html_id":"Crystal Image/Pluto/ImageRGBA","path":"Pluto/ImageRGBA.html","kind":"class","full_name":"Pluto::ImageRGBA","name":"ImageRGBA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_rgba.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/image_rgba.cr#L3"},{"filename":"src/pluto.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","doc":"Con","summary":"

Con

","abstract":false,"location":{"filename":"src/pluto.cr","line_number":23,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L23"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"CrImage::RGBAImage.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}}]}]},{"html_id":"Crystal Image/StumpyCore","path":"StumpyCore.html","kind":"module","full_name":"StumpyCore","name":"StumpyCore","abstract":false,"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/canvas.cr#L3"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba.cr#L4"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/mixing.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/mixing.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/utils.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/utils.cr#L1"},{"filename":"src/stumpy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"A module owned by [StumpyCr](https://github.com/stumpycr/stumpy_core)","summary":"

A module owned by StumpyCr

","types":[{"html_id":"Crystal Image/StumpyCore/Canvas","path":"StumpyCore/Canvas.html","kind":"class","full_name":"StumpyCore::Canvas","name":"Canvas","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/canvas.cr#L31"},{"filename":"src/stumpy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L6"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/StumpyCore","kind":"module","full_name":"StumpyCore","name":"StumpyCore"},"doc":"A canvas is 2D array of `RGBA` pixels\n\nTo create a canvas of size `400` x `200`\n\n```\ncanvas = StumpyCore::Canvas.new(400, 200)\n```\n\nThe default background color is transparent,\nbut it can be passed in as a parameter or as a block\nthat returns the color value for each `{x, y}` pair.\n\n```\ncanvas2 = StumpyCore::Canvas.new(400, 200, RGBA::WHITE)\n```\n\n```\ncanvas3 = StumpyCore::Canvas.new(256, 256) do |x, y|\n RGBA.from_rgb_n(x, y, 255, 8)\nend\n```\n![image](https://github.com/stumpycr/stumpy_core/blob/feature/images/rainbow.png?raw=true)\n\nBecause of the way pixels are stored in a `Slice`,\n`Canvas`es are limited to `Int32::MAX = 2147483647` pixels in total,\ne.g. a maximal size of 46340x46340 for a square image.","summary":"

A canvas is 2D array of RGBA pixels

","instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L7"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"size = width * height\nred = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\neach_row do |row|\n row.each do |rgba|\n red << (rgba.r >> 8).to_u8\n green << (rgba.g >> 8).to_u8\n blue << (rgba.b >> 8).to_u8\n alpha << (rgba.a >> 8).to_u8\n end\nend\nCrImage::RGBAImage.new(red, green, blue, alpha, width, height)\n"}}]}]},{"html_id":"Crystal Image/Tutorial","path":"Tutorial.html","kind":"module","full_name":"Tutorial","name":"Tutorial","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/chromakey_tutorial.cr#L35"},{"filename":"src/tutorials/tutorial.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/tutorial.cr#L7"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This fictional module exists to provide tutorials for using CrImage in the documentation\n\nSee:\n* `EdgeDetection`\n* `ChromaKey`\n* `FindDifferences`","summary":"

This fictional module exists to provide tutorials for using CrImage in the documentation

","types":[{"html_id":"Crystal Image/Tutorial/ChromaKey","path":"Tutorial/ChromaKey.html","kind":"module","full_name":"Tutorial::ChromaKey","name":"ChromaKey","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/chromakey_tutorial.cr#L35"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can swap out the background by creating a mask representing the pixels that are close in color, and replacing them using an `MaskApply#apply_color` method.\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"sample.jpg\")\n\n# Grab a color from the background, for comparison\nbackground = image[10, 10]\n\n# Construct a mask of all pixels within a color distance of our background\nbackground_mask = image.mask_from do |color|\n # 25 chosen through trial-and-error\n color.dist(background) < 25\nend\n .closing! # Remove small `true` regions\n .opening! # Remove small `false` regions\n\n# Now make the background blue\nimage\n .apply_color(background_mask, CrImage::Color.of(\"#0000cc\"))\n .save(\"chromakey.jpg\")\n```\n\nResults in image:\n\n\"Background\n\nThis script ran on my machine in `4ms` in `--release` mode.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/EdgeDetection","path":"Tutorial/EdgeDetection.html","kind":"module","full_name":"Tutorial::EdgeDetection","name":"EdgeDetection","abstract":false,"locations":[{"filename":"src/tutorials/edge_detection_tutorial.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/edge_detection_tutorial.cr#L38"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can run the [Sobel Operator](https://en.wikipedia.org/wiki/Sobel_operator) to detect edges in it:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nvertical_sobel = CrImage::IntMap.new([\n [-1, -2, -1],\n [0, 0, 0],\n [1, 2, 1],\n])\n\nhorizontal_sobel = CrImage::IntMap.new([\n [-1, 0, 1],\n [-2, 0, 2],\n [-1, 0, 1],\n])\n\nimage = CrImage::GrayscaleImage.open(\"sample.jpg\")\n\ndx = image.cross_correlate(horizontal_sobel)\ndy = image.cross_correlate(vertical_sobel)\n\n(dx ** 2 + dy ** 2).to_gray(scale: true).save(\"edge_detection.jpg\")\n```\n\nResults in image:\n\n\"Black\n\nThis script ran on my machine in `11ms` in `--release` mode.\n\n**Note**: This tutorial is using `cross_correlate`. For large images (or medium-to-large operators), the `cross_correlate_fft` may perform better.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/FindDifferences","path":"Tutorial/FindDifferences.html","kind":"module","full_name":"Tutorial::FindDifferences","name":"FindDifferences","abstract":false,"locations":[{"filename":"src/tutorials/find_differences.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/find_differences.cr#L55"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `differences.jpg` image:\n\n\"Two\n\nWe can programatically detect _most_ of the differences between these two images:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"differences.jpg\")\nret = image.clone\n\n# Perform a blur to remove random noise\nimg1 = image.gaussian_blur(1)[2...340, ..]\nimg2 = image.gaussian_blur(1)[361...699, ..]\n\n# Convert each color channel into a IntMap\nred_img1 = CrImage::UInt8Map.new(img1.width, img1.red).to_i\ngre_img1 = CrImage::UInt8Map.new(img1.width, img1.green).to_i\nblu_img1 = CrImage::UInt8Map.new(img1.width, img1.blue).to_i\nred_img2 = CrImage::UInt8Map.new(img2.width, img2.red).to_i\ngre_img2 = CrImage::UInt8Map.new(img2.width, img2.green).to_i\nblu_img2 = CrImage::UInt8Map.new(img2.width, img2.blue).to_i\n\n# Calculate a pixel by pixel difference calculation, convert it to a `Mask`\nred_mask = (red_img1 - red_img2).abs.>(50)\ngre_mask = (gre_img1 - gre_img2).abs.>(50)\nblu_mask = (blu_img1 - blu_img2).abs.>(50)\n\n# Combine the different color channel masks\ncombo_mask = (red_mask | blu_mask | gre_mask).dilate!\n\n# Expensive way to make a thick box.\n3.times do\n combo_mask.dilate!.segments.each do |v|\n # Draw a box in the first image\n ret.draw_square!(v.region.x + 2, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n # ... and the second image\n ret.draw_square!(v.region.x + 361, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n end\nend\n\nret.save(\"differences_end.jpg\")\n```\n\nResults in image:\n\n\"Two\n\nThis script ran on my machine in `66ms` in `--release` mode.\n\n**NOTE**: There's a difference in the seeds on one of the watermelons that don't survive the blurring process, and so aren't picked\nup by the differences algorithm above.","summary":"

Given differences.jpg image:

"}]}]}} \ No newline at end of file +{"repository_name":"Crystal Image","body":"

Crystal Image (Processing)

\n\nThis shard aims to provide feature rich image processing abilities, both for the purpose of\nimage manipulation as well as feature / information extraction from those images.\n\nThe code here originated as a fork from [Pluto](https://github.com/phenopolis/pluto) and further takes inspiration from [Stumpy](https://github.com/stumpycr/stumpy_core),\nand support converting to and from both of those libraries.\n\nAll sample images used are from [Unsplash](https://unsplash.com/).\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cr-image:\n github: vici37/cr-image\n ```\n\n2. Run `shards install`\n\n## Usage\n\nCrImage supports the formats:\n* PPM\n* JPEG (requires `libturbojpeg`)\n* PNG (natively by default, or optionally through requires `libspng`)\n* WebP (requires `libwebp`)\n\nFor the formats that require a linked library, they must be `require`d explicitly:\n\n```crystal\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\nrequire \"cr-image/webp\"\nrequire \"cr-image/png\" # replaces native crystal with libspng\n\n# Or, alternatively\nrequire \"cr-image/all_formats\"\n```\n\n### Example\n\nAssuming an image `moon.jpg` already exists\n\n\"Picture\n\n```crystal\nrequire \"cr-image\"\n\nimage = CrImage::RGBAImage.open(\"moon.jpg\")\n\n# create a mask identifying all pixels with light (i.e. the moon)\nmoon_mask = image\n .to_gray\n .threshold(8) # pixels are UInt8, with 0 as black and 255 as white\n\n# Crop out the moon from the image, and save it to a new file\nimage.crop(\n moon_mask.region # smallest area that encompasses all true bits in mask\n).save(\"moon_cropped.jpg\")\n\n```\n\nYields this image:\n\n\"Cropped\n\n[See the tutorials](http://troy.sornson.io/cr-image/Tutorial.html) for more examples.\n\n### [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core) Conversion\n\nIf your library or application already uses Pluto or Stumpy and you want to use\nsome of the functionality of this library, CrImage also provides some optional\nconversion methods:\n\n```crystal\nrequire \"cr-image/pluto\"\npluto_image # => Pluto::ImageRGBA\npluto_image.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_pluto # => Pluto::ImageRGBA\n```\n\n**NOTE:** Currently Pluto and CrImage share the same bindings for `libturbojpeg`, `libspng`, and `libwebp`. If you\nuse Pluto, you _cannot_ use those formats from CrImage.\n\n\n```crystal\nrequire \"cr-image/stumpy\"\nstumpy_canvas # => StumpyCore::Canvas\nstumpy_canvas.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_stumpy # => StumpyCore::Canvas\n```\n\n**NOTE:** Stumpy uses `UInt16` for its underlying raw image storage per channel per pixel, while Pluto and\nCrImage uses `UInt8`. Converting from a Stumpy `Canvas` object to `RGBAImage` may lose quality if the original\nimage used 16 bit color channels (i.e. 16-bit PNG). Most image formats tend to use 8-bit color channels.\n\n## Development\n\nThis requires `libwebp`, `libspng`, and `libturbojpeg` to run. Then:\n\n```\n> make test\n```\n\nTo ensure all tests run and pass.\n\n## Contributing\n\n1. [Fork it](https://github.com/Vici37/cr-image/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Troy Sornson](https://github.com/Vici37) - creator and maintainer\n","program":{"html_id":"Crystal Image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"Crystal Image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"Crystal Image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image.cr#L21"},{"filename":"src/cr-image/edge_policy.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L1"},{"filename":"src/cr-image/map.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L1"},{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/region.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L1"},{"filename":"src/cr-image/window_view.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L1"},{"filename":"src/lib-formats/bindings/lib_jpeg_turbo.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_jpeg_turbo.cr#L1"},{"filename":"src/lib-formats/bindings/lib_spng.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_spng.cr#L1"},{"filename":"src/lib-formats/bindings/lib_webp.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_webp.cr#L1"},{"filename":"src/pluto.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L35"},{"filename":"src/stumpy.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This module by itself isn't very interesting. Try taking a look through the [tutorials](./Tutorial.html) for better examples.","summary":"

This module by itself isn't very interesting.

","types":[{"html_id":"Crystal Image/CrImage/BlackView","path":"CrImage/BlackView.html","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L76"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to zero (or black)","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to zero (or black)

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = BlackView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":77,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L77"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n return T.zero\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/channel_type.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Red","name":"Red","value":"0"},{"id":"Green","name":"Green","value":"1"},{"id":"Blue","name":"Blue","value":"2"},{"id":"Gray","name":"Gray","value":"3"},{"id":"Alpha","name":"Alpha","value":"4"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_color_channel` and `GrayscaleImage#each_color_channel`","summary":"

Enum representing different image channels supported by CrImage

","instance_methods":[{"html_id":"alpha?-instance-method","name":"alpha?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L9"},"def":{"name":"alpha?","visibility":"Public","body":"self == Alpha"}},{"html_id":"blue?-instance-method","name":"blue?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"html_id":"default:UInt8-instance-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L11"},"def":{"name":"default","return_type":"UInt8","visibility":"Public","body":"alpha? ? 255_u8 : 0_u8"}},{"html_id":"gray?-instance-method","name":"gray?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L8"},"def":{"name":"gray?","visibility":"Public","body":"self == Gray"}},{"html_id":"green?-instance-method","name":"green?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L6"},"def":{"name":"green?","visibility":"Public","body":"self == Green"}},{"html_id":"red?-instance-method","name":"red?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"Crystal Image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/color.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for parsing and representing colors that can be used for certain\nmethods in CrImage.\n\nSee `Operation::MaskApply#apply_color`, `Operation::Draw#draw_square`, or `Operation::Draw#draw_circle`","summary":"

Utility class for parsing and representing colors that can be used for certain methods in CrImage.

","constructors":[{"html_id":"default:Color-class-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L11"},"def":{"name":"default","return_type":"Color","visibility":"Public","body":"new(ChannelType::Red.default, ChannelType::Green.default, ChannelType::Blue.default, ChannelType::Alpha.default)"}},{"html_id":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=ChannelType::Alpha.default)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L8"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"of(color:String):Color-class-method","name":"of","doc":"Parse color from a hex string:\n\n```\nColor.of(\"#1\") # same as \"#11\" => Color.new(17, 17, 17, 255)\nColor.of(\"#01\") # => Color.new(1, 1, 1, 255)\nColor.of(\"#123\") # same as \"#112233\" => Color.new(17, 34, 51, 255)\nColor.of(\"#1234\") # same as \"#11223344\" => Color.new(34, 51, 68, 17)\nColor.of(\"#010203\") # => Color.new(1, 2, 3, 255)\nColor.of(\"#01020304\") # => Color.new(2, 3, 4, 1)\n```","summary":"

Parse color from a hex string:

","abstract":false,"args":[{"name":"color","external_name":"color","restriction":"String"}],"args_string":"(color : String) : Color","args_html":"(color : String) : Color","location":{"filename":"src/cr-image/color.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L49"},"def":{"name":"of","args":[{"name":"color","external_name":"color","restriction":"String"}],"return_type":"Color","visibility":"Public","body":"if ((!(color.starts_with?(\"#\"))) || (!({2, 3, 4, 5, 7, 9}.includes?(color.size)))) || (color.match(/^#[^0-9a-f]/i))\n raise(\"Invalid hex color '#{color}': must start with '#' followed by 1, 2, 3, 4, 6, or 9 alphanumeric characters (0-9 or a-f)\")\nend\ncase color.size\nwhen 2\n gray = (color[1].to_i(16)).to_u8\n gray = (gray << 4) + gray\n self.new(gray, gray, gray)\nwhen 3\n gray = (color[1, 2].to_i(16)).to_u8\n self.new(gray, gray, gray)\nwhen 4\n red = (color[1].to_i(16)).to_u8\n green = (color[2].to_i(16)).to_u8\n blue = (color[3].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue)\nwhen 5\n alpha = (color[1].to_i(16)).to_u8\n red = (color[2].to_i(16)).to_u8\n green = (color[3].to_i(16)).to_u8\n blue = (color[4].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue, (alpha << 4) + alpha)\nwhen 7\n red = (color[1, 2].to_i(16)).to_u8\n green = (color[3, 2].to_i(16)).to_u8\n blue = (color[5, 2].to_i(16)).to_u8\n self.new(red, green, blue)\nelse\n alpha = (color[1, 2].to_i(16)).to_u8\n red = (color[3, 2].to_i(16)).to_u8\n green = (color[5, 2].to_i(16)).to_u8\n blue = (color[7, 2].to_i(16)).to_u8\n self.new(red, green, blue, alpha)\nend\n"}},{"html_id":"random:Color-class-method","name":"random","doc":"Generate a random color with full (255) opacity","summary":"

Generate a random color with full (255) opacity

","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L16"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), ChannelType::Alpha.default)\n"}}],"instance_methods":[{"html_id":"==(other:Color):Bool-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"}],"args_string":"(other : Color) : Bool","args_html":"(other : Color) : Bool","location":{"filename":"src/cr-image/color.cr","line_number":93,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L93"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Color"}],"return_type":"Bool","visibility":"Public","body":"(((red == other.red) && (green == other.green)) && (blue == other.blue)) && (alpha == other.alpha)"}},{"html_id":"[](channel_type:ChannelType):UInt8-instance-method","name":"[]","doc":"Receive the UInt8 portion of this color corresponding to `channel_type`","summary":"

Receive the UInt8 portion of this color corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : UInt8","args_html":"(channel_type : ChannelType) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L29"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"UInt8","visibility":"Public","body":"case channel_type\nin ChannelType::Red\n red\nin ChannelType::Green\n green\nin ChannelType::Blue\n blue\nin ChannelType::Alpha\n alpha\nin ChannelType::Gray\n gray\nend"}},{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"alpha","visibility":"Public","body":"@alpha"}},{"html_id":"blue:UInt8-instance-method","name":"blue","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"html_id":"dist(other:Color,*,manhattan:Bool=false):Float64-instance-method","name":"dist","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"args_string":"(other : Color, *, manhattan : Bool = false) : Float64","args_html":"(other : Color, *, manhattan : Bool = false) : Float64","location":{"filename":"src/cr-image/color.cr","line_number":100,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L100"},"def":{"name":"dist","args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"splat_index":1,"return_type":"Float64","visibility":"Public","body":"if manhattan\n ((red.to_f - other.red).abs + (blue.to_i - other.blue).abs) + (green.to_i - other.green).abs\nelse\n Math.sqrt((((red.to_i - other.red) ** 2) + ((green.to_i - other.green) ** 2)) + ((blue.to_i - other.blue) ** 2))\nend"}},{"html_id":"gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):UInt8-instance-method","name":"gray","doc":"Convert this Color to a single UInt8 gray value","summary":"

Convert this Color to a single UInt8 gray value

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L22"},"def":{"name":"gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"UInt8","visibility":"Public","body":"Math.min(255_u8, (((red * red_multiplier) + (blue * blue_multiplier)) + (green * green_multiplier)).to_u8)"}},{"html_id":"green:UInt8-instance-method","name":"green","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"green","visibility":"Public","body":"@green"}},{"html_id":"red:UInt8-instance-method","name":"red","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"Crystal Image/CrImage/ComplexMap","path":"CrImage/ComplexMap.html","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":606,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L606"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"instance_methods":[{"html_id":"ifft:FloatMap-instance-method","name":"ifft","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":609,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L609"},"def":{"name":"ifft","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, (FftUtil.ifft2d(width, raw)).map(&.real))"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":613,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L613"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"self"}},{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":621,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L621"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to FloatMap\"))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":617,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L617"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to IntMap\"))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":607,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L607"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/EdgePolicy","path":"CrImage/EdgePolicy.html","kind":"enum","full_name":"CrImage::EdgePolicy","name":"EdgePolicy","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/edge_policy.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Black","name":"Black","value":"0"},{"id":"Repeat","name":"Repeat","value":"1"},{"id":"None","name":"None","value":"2"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A general enum for determining behavior around edges of `Image` or `Map`s. See also `Operator::Pad`","summary":"

A general enum for determining behavior around edges of Image or Maps.

","instance_methods":[{"html_id":"black?-instance-method","name":"black?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L4"},"def":{"name":"black?","visibility":"Public","body":"self == Black"}},{"html_id":"none?-instance-method","name":"none?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L6"},"def":{"name":"none?","visibility":"Public","body":"self == None"}},{"html_id":"repeat?-instance-method","name":"repeat?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L5"},"def":{"name":"repeat?","visibility":"Public","body":"self == Repeat"}}]},{"html_id":"Crystal Image/CrImage/ErrorView","path":"CrImage/ErrorView.html","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L61"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of teh underlying `Map` causes an error","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of teh underlying Map causes an error

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = ErrorView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":62,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L62"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n raise(Exception.new(\"Coordinates #{x}, #{y} correspond to #{adjusted_x}, #{adjusted_y} in sliding window sized #{width}x#{height} centered at #{@map_x}, #{@map_y}, which is outside\"))\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/exception.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Exception class for any errors thrown by CrImage","summary":"

Exception class for any errors thrown by CrImage

","constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/cr-image/exception.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L5"},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(error_code:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"args_string":"(error_code : Int32)","args_html":"(error_code : Int32)","location":{"filename":"src/cr-image/exception.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L9"},"def":{"name":"new","args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(error_code)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(handle:LibJPEGTurbo::Handle)-class-method","name":"new","abstract":false,"args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"args_string":"(handle : LibJPEGTurbo::Handle)","args_html":"(handle : LibJPEGTurbo::Handle)","location":{"filename":"src/cr-image/exception.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L13"},"def":{"name":"new","args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"visibility":"Public","body":"_ = allocate\n_.initialize(handle)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"error_code:Int32|Nil-instance-method","name":"error_code","abstract":false,"location":{"filename":"src/cr-image/exception.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"Crystal Image/CrImage/FftUtil","path":"CrImage/FftUtil.html","kind":"class","full_name":"CrImage::FftUtil","name":"FftUtil","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/fft_util.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for Fast Fourier Transforms\n\nAt some point in the future, this may be moved to its own shard.","summary":"

Utility class for Fast Fourier Transforms

","class_methods":[{"html_id":"fft1d(inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L59"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if buf = buffer\nelse\n buf = Array(Complex).new(inp.size) do\n Complex.zero\n end\nend\nFftUtil.fft1d(Array(Complex).new(inp.size) do |i|\n Complex.new(inp.unsafe_fetch(i))\nend, buf)\n"}},{"html_id":"fft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L68"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.fft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"fft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)|Slice(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"fft1d_unsafe","doc":"Calculates Fast Fourier Transform of `ret`. Uses and modifies `ret` in place.\n\nCan optionally pass in `buffer` which must be the same length as `inp`. This method makes no bound checks or error checks.","summary":"

Calculates Fast Fourier Transform of ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L76"},"def":{"name":"fft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = (-Math::PI.i) / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret\n"}},{"html_id":"fft2d(width:Int32,inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L10"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"FftUtil.fft2d(width, inp.map(&.to_c), buffer)"}},{"html_id":"fft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L15"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.fft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"fft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"fft2d_unsafe","doc":"Perform Fast Fourier Transform, using and rewriting `ret` for the output, as a 2 dimensional array with `width`. `buffer` must be an array\nof length at least the longer of `width` or `height` of the input array.","summary":"

Perform Fast Fourier Transform, using and rewriting ret for the output, as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L28"},"def":{"name":"fft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.fft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.fft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}},{"html_id":"ifft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"ifft1d","doc":"Perform Inverse Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`.","summary":"

Perform Inverse Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L165"},"def":{"name":"ifft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.ifft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"ifft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"ifft1d_unsafe","doc":"Perform Inverse Fast Fourier Transform on `ret`. Will use and overwrite the original values in `ret` to do so.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`. This method makes no bound checks or error checks.","summary":"

Perform Inverse Fast Fourier Transform on ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L173"},"def":{"name":"ifft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = Math::PI.i / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret.map!(&./(ret.size))\n"}},{"html_id":"ifft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"ifft2d","doc":"Perform Inverse Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Inverse Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":124,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L124"},"def":{"name":"ifft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.ifft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"ifft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"ifft2d_unsafe","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":135,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L135"},"def":{"name":"ifft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.ifft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.ifft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}}]},{"html_id":"Crystal Image/CrImage/FloatMap","path":"CrImage/FloatMap.html","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":508,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L508"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Float64` types.","summary":"

Implementation of MapImpl for Float64 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":519,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L519"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"self"}},{"html_id":"to_f64:self-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":511,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L511"},"def":{"name":"to_f64","return_type":"self","visibility":"Public","body":"self"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":515,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L515"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":509,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L509"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Format","path":"CrImage/Format.html","kind":"module","full_name":"CrImage::Format","name":"Format","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}, {extension: \".png\", method: \"png\"}, {extension: \".jpeg\", method: \"jpeg\"}, {extension: \".jpg\", method: \"jpeg\"}, {extension: \".png\", method: \"png\"}, {extension: \".webp\", method: \"webp\"}] of Nil"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Provides a convenience method for saving image files to the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage.save(\"image.jpg\")\n```\nSee `Open` for a convenience method to read images from the filesystem","summary":"

Provides a convenience method for saving image files to the filesystem.

","types":[{"html_id":"Crystal Image/CrImage/Format/JPEG","path":"CrImage/Format/JPEG.html","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG","abstract":false,"locations":[{"filename":"src/lib-formats/jpeg.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/jpeg.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to jpeg. Requires `libturbojpeg` to function.\n\n```\nimage = File.open(\"image.jpg\") { |file| CrImage::RGBAImage.from_jpeg(file) }\nFile.open(\"other_image.jpg\") { |file| image.to_jpeg(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\nimage.save(\"other_image.jpg\")\n```","summary":"

Provides methods to read from and write to jpeg.

","instance_methods":[{"html_id":"to_jpeg(io:IO,quality:Int32=100):Nil-instance-method","name":"to_jpeg","doc":"Output the image as JPEG to `io`","summary":"

Output the image as JPEG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, quality : Int32 = 100) : Nil","args_html":"(io : IO, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/jpeg.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/jpeg.cr#L74"},"def":{"name":"to_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"handle = LibJPEGTurbo.init_compress\nimage_data = IO::Memory.new(size * 3)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\nend\nbuffer = Pointer(UInt8).null\ncheck_jpeg(handle, LibJPEGTurbo.compress2(handle, image_data.buffer, @width, 0, @height, LibJPEGTurbo::PixelFormat::RGB, pointerof(buffer), out size, LibJPEGTurbo::Subsampling::S444, quality, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibJPEGTurbo.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Open","path":"CrImage/Format/Open.html","kind":"module","full_name":"CrImage::Format::Open","name":"Open","abstract":false,"locations":[{"filename":"src/cr-image/format/open.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/open.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides a convenience method for opening up image files from the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\n```\nSee `Save` for a convenience method to write to the filesystem.","summary":"

Provides a convenience method for opening up image files from the filesystem.

","instance_methods":[{"html_id":"open(filename:String):self-instance-method","name":"open","doc":"Reads this image from file using the provided filename.","summary":"

Reads this image from file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/open.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/open.cr#L14"},"def":{"name":"open","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"{% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then File.open(filename) { |file| self.from_{{ format[:method].id }}(file) }\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\nend.join(\", \")).id }}\"\n end\n {% end %}"}}]},{"html_id":"Crystal Image/CrImage/Format/PNG","path":"CrImage/Format/PNG.html","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG","abstract":false,"locations":[{"filename":"src/cr-image/format/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/png.cr#L15"},{"filename":"src/lib-formats/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/png.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PNG. Requires `libspng` to function.\n\n```\nimage = File.open(\"image.png\") { |file| CrImage::RGBAImage.from_png(file) }\nFile.open(\"other_image.png\") { |file| image.to_png(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.png\")\nimage.save(\"other_image.png\")\n```","summary":"

Provides methods to read from and write to PNG.

","instance_methods":[{"html_id":"to_png(io:IO):Nil-instance-method","name":"to_png","doc":"Output the image as PNG to `io`","summary":"

Output the image as PNG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/lib-formats/png.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/png.cr#L72"},"def":{"name":"to_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::Encoder)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_option(ctx, LibSPNG::Option::EncodeToBuffer, true)\nLibSPNG.set_png_buffer(ctx, image_data.buffer, image_data.size)\nihdr = LibSPNG::IHDR.new\nihdr.width = @width\nihdr.height = @height\nihdr.color_type = LibSPNG::ColorType::TrueColorAlpha\nihdr.bit_depth = 8\nLibSPNG.set_ihdr(ctx, pointerof(ihdr))\nerror = LibSPNG.encode_image(ctx, image_data.buffer, image_data.size, LibSPNG::Format::PNG, LibSPNG::EncodeFlags::Finalize)\ncheck_png(error)\nbuffer = LibSPNG.get_png_buffer(ctx, out size, pointerof(error))\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to get a buffer\"))\nend\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibC.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/PPM","path":"CrImage/Format/PPM.html","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM","abstract":false,"locations":[{"filename":"src/cr-image/format/ppm.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/ppm.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PPM.\n\n```\nimage = File.open(\"image.ppm\") { |file| CrImage::RGBAImage.from_ppm(file) }\nFile.open(\"other_image.ppm\") { |file| image.to_ppm(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.ppm\")\nimage.save(\"other_image.ppm\")\n```","summary":"

Provides methods to read from and write to PPM.

","instance_methods":[{"html_id":"to_ppm(io:IO):Nil-instance-method","name":"to_ppm","doc":"Output this image to `io` using PPM image encoding","summary":"

Output this image to io using PPM image encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/cr-image/format/ppm.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/ppm.cr#L56"},"def":{"name":"to_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"io << \"P6\\n\"\n(((io << @width) << \" \") << @height) << \"\\n\"\nio << \"255\\n\"\nsize.times do |index|\n io.write_byte(red.unsafe_fetch(index))\n io.write_byte(green.unsafe_fetch(index))\n io.write_byte(blue.unsafe_fetch(index))\nend\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Save","path":"CrImage/Format/Save.html","kind":"module","full_name":"CrImage::Format::Save","name":"Save","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"instance_methods":[{"html_id":"save(filename:String):self-instance-method","name":"save","doc":"Write this image to file using the provided filename.\n\nThis method _will not_ create intermediate directory paths. This method will throw an\nerror if they don't exist.","summary":"

Write this image to file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/save.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L20"},"def":{"name":"save","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"File.open(filename, \"w\") do |file|\n {% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then to_{{ format[:method].id }}(file)\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\n end.join(\", \")).id }}\"\n end\n {% end %}\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Format/WebP","path":"CrImage/Format/WebP.html","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP","abstract":false,"locations":[{"filename":"src/lib-formats/webp.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/webp.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to WebP. Requires `libwebp` to function.\n\n```\nimage = File.open(\"image.webp\") { |file| CrImage::RGBAImage.from_webp(file) }\nFile.open(\"other_image.webp\") { |file| image.to_webp(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.webp\")\nimage.save(\"other_image.webp\")\n```","summary":"

Provides methods to read from and write to WebP.

","instance_methods":[{"html_id":"to_webp(io:IO,*,lossy:Bool=false,quality:Int32=100):Nil-instance-method","name":"to_webp","doc":"Write image to `io` using WebP encoding","summary":"

Write image to io using WebP encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","args_html":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/webp.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/webp.cr#L59"},"def":{"name":"to_webp","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"splat_index":1,"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nsize, buffer = lossy ? lossy_encode(image_data, quality) : lossless_encode(image_data)\ncheck_webp(size)\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibWebP.free(buffer)\n"}}]}]},{"html_id":"Crystal Image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L13"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L42"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L38"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image in Grayscale. These image types are the easiest to perform feature and information extraction from, where\nthere is only one channel to examine, and so has methods for constructing `Mask`s from (see `#threshold` below).\n\nAn `RGBAImage` would become a `GrayscaleImage` this way:\n```\nimage.to_gray\n```\n\n\"Woman\n\"Woman","summary":"

An image in Grayscale.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage from a set of color channels (delegates to `RGBAImage#to_gray`)","summary":"

Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray)

","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L20"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"(RGBAImage.new(red, green, blue, alpha, width, height)).to_gray"}},{"html_id":"new(gray:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L24"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32)","args_html":"(gray : Array(UInt8), width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L38"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"<(*args,**options)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.<(*args, **options)"}},{"html_id":"<(*args,**options,&)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.<(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"<=(arg)-instance-method","name":"<=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! <= arg"}},{"html_id":"==(arg)-instance-method","name":"==","doc":"Returns `false` (other can only be a `Value` here).","summary":"

Returns false (other can only be a Value here).

","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"==","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! == arg"}},{"html_id":">(*args,**options)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.>(*args, **options)"}},{"html_id":">(*args,**options,&)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.>(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":">=(arg)-instance-method","name":">=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! >= arg"}},{"html_id":"[](x:Int32,y:Int32):Pixel-instance-method","name":"[]","doc":"Return a `Pixel` representing this cell in the image.","summary":"

Return a Pixel representing this cell in the image.

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Pixel","args_html":"(x : Int32, y : Int32) : Pixel","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Pixel","visibility":"Public","body":"index = (y * width) + x\nPixel.new(gray[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the `Array(UInt8)` corresponding to `channel_type`","summary":"

Return the Array(UInt8) corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L97"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"if channel_type == ChannelType::Alpha\n return @alpha\nend\n@gray\n"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the underlying `Array(UInt8)` of `channel_type` to the new `channel`.\n\nWarning: this method does not check the size of the incoming array, and if it's a different\nsize from what the current image represents, this could break it. We recommend against using\nthis method except for from other methods that will be updating the `width` and `height` immediately after.","summary":"

Set the underlying Array(UInt8) of channel_type to the new channel.

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L107"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Gray\n self.gray = channel\nwhen ChannelType::Alpha\n self.alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for GrayscaleImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return `alpha` channel","summary":"

Return #alpha channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":69,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L69"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L15"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the \"`blue`\" channel (returns `gray`)","summary":"

Return the "#blue" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L64"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"clone:GrayscaleImage-instance-method","name":"clone","doc":"Create a new GrayscaleImage as a copy of this one","summary":"

Create a new GrayscaleImage as a copy of this one

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L44"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone, @width, @height)"}},{"html_id":"cross_correlate(map:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":221,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L221"},"def":{"name":"cross_correlate","args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"to_imap.cross_correlate(map, edge_policy: edge_policy)"}},{"html_id":"cross_correlate(*args,**options)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options)"}},{"html_id":"cross_correlate(*args,**options,&)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"cross_correlate_fft(map:Map)-instance-method","name":"cross_correlate_fft","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"}],"args_string":"(map : Map)","args_html":"(map : Map)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":225,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L225"},"def":{"name":"cross_correlate_fft","args":[{"name":"map","external_name":"map","restriction":"Map"}],"visibility":"Public","body":"to_imap.cross_correlate_fft(map)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L80"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L74"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nnil\n"}},{"html_id":"gray:Array(UInt8)-instance-method","name":"gray","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"gray=(gray:Array(UInt8))-instance-method","name":"gray=","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"args_string":"(gray : Array(UInt8))","args_html":"(gray : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray=","args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@gray = gray"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the \"`green`\" channel (returns `gray`)","summary":"

Return the "#green" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L59"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"invert-instance-method","name":"invert","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`).\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":171,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L171"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`). Modifies self.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L182"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(*args,**options)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mask_from(*args, **options)"}},{"html_id":"mask_from(*args,**options,&)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mask_from(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"mean(*args,**options)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mean(*args, **options)"}},{"html_id":"mean(*args,**options,&)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mean(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the \"`red`\" channel (returns `gray`)","summary":"

Return the "#red" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L54"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels this image contains","summary":"

Return the number of pixels this image contains

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":160,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"threshold(threshold:Int):Mask-instance-method","name":"threshold","doc":"Construct a simple threshold `Mask` containing all pixels with a `UInt8` value greater than `threshold`\nGiven sample image:\n\n\"Woman\n\n```\nimage\n .to_gray # convert color image to grayscale one\n .threshold(128) # generate a mask using threshold operator\n .to_gray # convert mask to grayscale image\n .save(\"threshold_example.jpg\") # save mask as grayscale\n```\n\"Black","summary":"

Construct a simple threshold Mask containing all pixels with a UInt8 value greater than #threshold Given sample image:

","abstract":false,"args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"args_string":"(threshold : Int) : Mask","args_html":"(threshold : Int) : Mask","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":200,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L200"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"self >= threshold"}},{"html_id":"to_a:Array(UInt8)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `Array(UInt8)` corresponding to the `ChannelType::Gray` channel","summary":"

Receive a copy of the underlying Array(UInt8) corresponding to the ChannelType::Gray channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":217,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L217"},"def":{"name":"to_a","return_type":"Array(UInt8)","visibility":"Public","body":"gray.dup"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":155,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L155"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"html_id":"to_imap:IntMap-instance-method","name":"to_imap","doc":"Convert this image into a `IntMap`","summary":"

Convert this image into a IntMap

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":207,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L207"},"def":{"name":"to_imap","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, gray.map(&.to_i))"}},{"html_id":"to_map!:UInt8Map-instance-method","name":"to_map!","doc":"Convert this image into a `UInt8Map`. Does not clone underlying `gray` channel, both this image and map share the same data.","summary":"

Convert this image into a UInt8Map.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":212,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L212"},"def":{"name":"to_map!","return_type":"UInt8Map","visibility":"Public","body":"UInt8Map.new(width, @gray)"}},{"html_id":"to_pluto:Pluto::ImageGA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L43"},"def":{"name":"to_pluto","return_type":"Pluto::ImageGA","visibility":"Public","body":"Pluto::ImageGA.new(gray.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba(color_map:Hash(UInt8,Color),*,default:Color=Color.default):RGBAImage-instance-method","name":"to_rgba","doc":"Convert this grayscale image to an RGBA one using the provided color map.\n\nThe provided map should have a key for all 0-255 possible gray pixel values, otherwise the `default`\n`Color` will be used instead (default is black).\n\n```\ncolors = 256.times.to_a.map { |i| {i.to_u8, CrImage::Color.random} }.to_h\ngray_image.to_rgba(colors).save(\"to_rgba_color_map_sample.jpg\")\n```\n\n\"Woman\n\nBecomes\n\n\"Random","summary":"

Convert this grayscale image to an RGBA one using the provided color map.

","abstract":false,"args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"args_string":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","args_html":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L137"},"def":{"name":"to_rgba","args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"splat_index":1,"return_type":"RGBAImage","visibility":"Public","body":"red = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\ngray.each do |pixel|\n color = color_map[pixel]? || default\n red << color.red\n green << color.green\n blue << color.blue\n alpha << color.alpha\nend\nRGBAImage.new(red, green, blue, alpha, width, height)\n"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Convert this `GrayscaleImage` to an `RGBAImage`.\n\nNo color will be provided, all pixels will remain gray.","summary":"

Convert this GrayscaleImage to an RGBAImage.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":118,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L118"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L39"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}],"types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage/Pixel","path":"CrImage/GrayscaleImage/Pixel.html","kind":"struct","full_name":"CrImage::GrayscaleImage::Pixel","name":"Pixel","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},"constructors":[{"html_id":"new(gray:UInt8,alpha:UInt8)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"args_string":"(gray : UInt8, alpha : UInt8)","args_html":"(gray : UInt8, alpha : UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"def":{"name":"alpha","return_type":"UInt8","visibility":"Public","body":"@alpha"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone)"}},{"html_id":"copy_with(gray_gray=@gray,alpha_alpha=@alpha)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"args_string":"(gray _gray = @gray, alpha _alpha = @alpha)","args_html":"(gray _gray = @gray, alpha _alpha = @alpha)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"copy_with","args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"visibility":"Public","body":"self.class.new(_gray, _alpha)"}},{"html_id":"gray:UInt8-instance-method","name":"gray","abstract":false,"def":{"name":"gray","return_type":"UInt8","visibility":"Public","body":"@gray"}}]}]},{"html_id":"Crystal Image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Common base class for `GrayscaleImage` and `RGBAImage`. All `Image`s are readable and saveable\nto the filesystem or `IO` stream.","summary":"

Common base class for GrayscaleImage and RGBAImage.

","instance_methods":[{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Get the `Array(UInt8)` corresponding to `channel_type`)","summary":"

Get the Array(UInt8) corresponding to channel_type)

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":57,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L57"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the `Array(UInt8)` corresponding to `channel_type`) to `channel`","summary":"

Set the Array(UInt8) corresponding to channel_type) to channel

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L59"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L42"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":40,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L40"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L54"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":51,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L51"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L38"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L46"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L36"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size (total pixels) in image (`width` * `height`)","summary":"

Size (total pixels) in image (#width * #height)

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":48,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L48"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L44"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}],"macros":[{"html_id":"subsclasses_include(mod)-macro","name":"subsclasses_include","abstract":false,"args":[{"name":"mod","external_name":"mod","restriction":""}],"args_string":"(mod)","args_html":"(mod)","location":{"filename":"src/cr-image/image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L4"},"def":{"name":"subsclasses_include","args":[{"name":"mod","external_name":"mod","restriction":""}],"visibility":"Public","body":" \n{% for sub in @type.subclasses %}\n class ::{{ sub }}\n include {{ mod }}\n end\n {% end %}\n\n \n"}}]},{"html_id":"Crystal Image/CrImage/IntMap","path":"CrImage/IntMap.html","kind":"class","full_name":"CrImage::IntMap","name":"IntMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L478"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Int32` types.","summary":"

Implementation of MapImpl for Int32 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":485,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L485"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"to_f64"}},{"html_id":"to_f64:FloatMap-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":481,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L481"},"def":{"name":"to_f64","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f64))"}},{"html_id":"to_i:self-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":489,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L489"},"def":{"name":"to_i","return_type":"self","visibility":"Public","body":"self"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":479,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L479"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Map","path":"CrImage/Map.html","kind":"module","full_name":"CrImage::Map(T)","name":"Map","abstract":false,"locations":[{"filename":"src/cr-image/map.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/Mask","kind":"class","full_name":"CrImage::Mask","name":"Mask"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/OneMap","kind":"class","full_name":"CrImage::OneMap","name":"OneMap"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An interface for 2 dimensional data. Used for various masking and correlation methods.","summary":"

An interface for 2 dimensional data.

","instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L9"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L8"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L11"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L10"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L5"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L7"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L6"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L4"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/MapImpl","path":"CrImage/MapImpl.html","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L45"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"}],"including_types":[{"html_id":"Crystal Image/CrImage/ComplexMap","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap"},{"html_id":"Crystal Image/CrImage/FloatMap","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap"},{"html_id":"Crystal Image/CrImage/IntMap","kind":"class","full_name":"CrImage::IntMap","name":"IntMap"},{"html_id":"Crystal Image/CrImage/UInt8Map","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A collection of implementations of `NumericMap(T)`, intended to be included in base classes.\n\nSee `IntMap`, `FloatMap`, and `ComplexMap`.","summary":"

A collection of implementations of NumericMap(T), intended to be included in base classes.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:T)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"args_string":"(width : Int32, height : Int32, initial : T)","args_html":"(width : Int32, height : Int32, initial : T)","location":{"filename":"src/cr-image/map.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L82"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,raw:Array(T))-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"args_string":"(width : Int32, raw : Array(T))","args_html":"(width : Int32, raw : Array(T))","location":{"filename":"src/cr-image/map.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L63"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other:Array(Array(T)))-class-method","name":"new","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"args_string":"(other : Array(Array(T)))","args_html":"(other : Array(Array(T)))","location":{"filename":"src/cr-image/map.cr","line_number":67,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L67"},"def":{"name":"new","args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &)","args_html":"(width : Int32, height : Int32, &)","location":{"filename":"src/cr-image/map.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L76"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":1,"block_arity":1,"visibility":"Public","body":"_ = allocate\n_.initialize(width, height) do |_arg0|\n yield _arg0\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"*(num:Int|Float):self-instance-method","name":"*","doc":"Multiply each point in this `Map` by `num`","summary":"

Multiply each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":284,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L284"},"def":{"name":"*","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i * num\nend)"}},{"html_id":"+(num:Int|Float):self-instance-method","name":"+","doc":"Add each point in this `Map` by `num`","summary":"

Add each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":289,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L289"},"def":{"name":"+","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i + num\nend)"}},{"html_id":"+(other:self):self-instance-method","name":"+","doc":"Add each point of this `Map` with each point in `other`","summary":"

Add each point of this Map with each point in other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : self","args_html":"(other : self) : self","location":{"filename":"src/cr-image/map.cr","line_number":304,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L304"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Dimensions should match (caller: #{width}x#{height}, callee: #{other.width}x#{other.height})\"))\nend\nself.class.new(width, @raw.map_with_index do |val, i|\n val + other[i]\nend)\n"}},{"html_id":"-(other:NumericMap(T)):self-instance-method","name":"-","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : self","args_html":"(other : NumericMap(T)) : self","location":{"filename":"src/cr-image/map.cr","line_number":196,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L196"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Unable to subtract a map of different dimensions: #{width}x#{height} vs #{other.width}x#{other.height}\"))\nend\nself.class.new(width, raw.map_with_index do |v, i|\n v - other.raw[i]\nend)\n"}},{"html_id":"-(num:Int):self-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int"}],"args_string":"(num : Int) : self","args_html":"(num : Int) : self","location":{"filename":"src/cr-image/map.cr","line_number":294,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L294"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Int"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"-(num:Float):FloatMap-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Float"}],"args_string":"(num : Float) : FloatMap","args_html":"(num : Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":299,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L299"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"/(num:Int|Float):FloatMap-instance-method","name":"/","doc":"Divides each point in this `Map` by `num`\n\nTODO: ComplexMap shouldn't return a FloatMap","summary":"

Divides each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : FloatMap","args_html":"(num : Int | Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":279,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L279"},"def":{"name":"/","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i / num\nend)"}},{"html_id":"<(num:Int|Float):Mask-instance-method","name":"<","doc":"Construct a `Mask` identifying all pixels smaller than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray < 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels smaller than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":257,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L257"},"def":{"name":"<","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val < num\nend"}},{"html_id":"<=(num:Int|Float):Mask-instance-method","name":"<=","doc":"Construct a `Mask` identifying all pixels smaller than or equal to `num`. See `#<` for example.","summary":"

Construct a Mask identifying all pixels smaller than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":262,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L262"},"def":{"name":"<=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val <= num\nend"}},{"html_id":"==(num:Int|Float):Mask-instance-method","name":"==","doc":"Construct a `Mask` identifying all pixels equal to `num`","summary":"

Construct a Mask identifying all pixels equal to num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":267,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L267"},"def":{"name":"==","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val == num\nend"}},{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Check if this `Map` is equal to `other`","summary":"

Check if this Map is equal to other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/cr-image/map.cr","line_number":272,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L272"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"(other.width == width) && (@raw == other.raw)"}},{"html_id":">(num:Int|Float):Mask-instance-method","name":">","doc":"Construct a `Mask` identifying all pixels larger than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray > 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels larger than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":238,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L238"},"def":{"name":">","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val > num\nend"}},{"html_id":">=(num:Int|Float):Mask-instance-method","name":">=","doc":"Construct a `Mask` identify all pixels larger than or equal to `num`. See `#>` for near example.","summary":"

Construct a Mask identify all pixels larger than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":243,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L243"},"def":{"name":">=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val >= num\nend"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):self-instance-method","name":"[]","doc":"Crop the map to the values contained from `xstart` out by `xcount`, and `ystart` out by `ycount`","summary":"

Crop the map to the values contained from xstart out by xcount, and ystart out by ycount

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":152,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L152"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, xcount, ystart, ycount)"}},{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","doc":"Get element at coordinates `x` and `y`","summary":"

Get element at coordinates x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":106,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L106"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"if x >= width || x < 0\n raise(Exception.new(\"X coordinate #{x} is outside of Map width #{width}\"))\nend\nif y >= height || y < 0\n raise(Exception.new(\"Y coordinate #{y} is outside of Map height #{height}\"))\nend\nindex = (y * width) + x\nself[index]\n"}},{"html_id":"[](xrange:Range,ystart:Int32):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in row at `ystart`","summary":"

Crop the map, returning only the values in row at ystart

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : self","args_html":"(xrange : Range, ystart : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L137"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), ystart, 1)"}},{"html_id":"[](xstart:Int32,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in column at `xstart`","summary":"

Crop the map, returning only the values in column at xstart

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : self","args_html":"(xstart : Int32, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":142,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L142"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, 1, *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map to the values contained in `xrange` and `yrange`","summary":"

Crop the map to the values contained in xrange and yrange

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":147,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L147"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","doc":"Get element at `index` from underlying `raw` Array.","summary":"

Get element at index from underlying #raw Array.

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":101,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L101"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"@raw[index]"}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","doc":"Get lement at coordinates `x` and `y`, or `nil` if coordinates are out of bounds","summary":"

Get lement at coordinates x and y, or nil if coordinates are out of bounds

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":119,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L119"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"if x < 0 || x >= width\n return nil\nend\nif y < 0 || y >= height\n return nil\nend\nindex = (y * width) + x\n@raw[index]?\n"}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","doc":"Get element at `index`, or `nil` if out of bounds","summary":"

Get element at index, or nil if out of bounds

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":114,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L114"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"@raw[index]?"}},{"html_id":"column(x:Int32):self-instance-method","name":"column","doc":"Get a single dimensional `Map` representing teh column at `x`","summary":"

Get a single dimensional Map representing teh column at x

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"}],"args_string":"(x : Int32) : self","args_html":"(x : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":132,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L132"},"def":{"name":"column","args":[{"name":"x","external_name":"x","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(x, 1, 0, height)"}},{"html_id":"cross_correlate(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","doc":"Perform a brute force cross correlation calculation with provided `template`.","summary":"

Perform a brute force cross correlation calculation with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":393,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L393"},"def":{"name":"cross_correlate","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"half_width = template.width >> 1\nhalf_height = template.height >> 1\nstart_x, start_y = (edge_policy.none? ? {half_width, half_height} : {0, 0})\nend_x, end_y = (edge_policy.none? ? {(width - half_width) - 1, (height - half_height) - 1} : {width - 1, height - 1})\nret = Array(Float64).new((end_x - start_x) * (end_y - start_y))\n(start_y.upto(end_y)).each do |y|\n (start_x.upto(end_x)).each do |x|\n view = case edge_policy\n in EdgePolicy::Repeat\n RepeatView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::Black\n BlackView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::None\n ErrorView(T).new(template.width, template.height, self, x, y)\n end\n ret << view.sum do |pixel, vx, vy|\n template[vx, vy] * pixel\n end\n end\nend\nretf = FloatMap.new((end_x - start_x) + 1, ret)\nretf\n"}},{"html_id":"cross_correlate_fft(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Black):FloatMap-instance-method","name":"cross_correlate_fft","doc":"Perform a Fast Fourier Transform cross correlation (convolution?) with provided `template`. See `FftUtil`","summary":"

Perform a Fast Fourier Transform cross correlation (convolution?) with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":421,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L421"},"def":{"name":"cross_correlate_fft","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"max_width, max_height = Math.pw2ceil(width + template.width), Math.pw2ceil(height + template.height)\npad_type = edge_policy.none? ? EdgePolicy::Black : edge_policy\nwidth_range, height_range = case edge_policy\nin EdgePolicy::Black, EdgePolicy::Repeat\n {(template.width)...(width + template.width), (template.height)...(height + template.height)}\nin EdgePolicy::None\n {(template.width + (template.width // 2))..(((template.width + width) - template.width) + 1), (template.height + (template.height // 2))..(((template.height + height) - template.height) + 1)}\nend\norig_pad_fft = pad(top: (template.height // 2) + (template.height % 2), bottom: (max_height - height) - ((template.height // 2) + (template.height % 2)), right: (max_width - width) - ((template.width // 2) + (template.width % 2)), left: (template.width // 2) + (template.width % 2), pad_type: pad_type).to_c\nmap_pad_fft = template.pad(bottom: max_height - template.height, right: max_width - template.width).to_c\nbuffer = Array(Complex).new(Math.max(max_width, max_height)) do\n Complex.zero\nend\nFftUtil.fft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nFftUtil.fft2d_unsafe(max_width, map_pad_fft.raw, buffer)\norig_pad_fft.raw.map_with_index! do |o, i|\n o * map_pad_fft[i]\nend\nFftUtil.ifft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nret = (FloatMap.new(max_width, orig_pad_fft.raw.map(&.real)))[width_range, height_range]\nret\n"}},{"html_id":"fft:ComplexMap-instance-method","name":"fft","doc":"Performe a Fast Fourier Transform, padding out this `Map` so dimensions are a power of 2. See `FftUtil`","summary":"

Performe a Fast Fourier Transform, padding out this Map so dimensions are a power of 2.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":461,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L461"},"def":{"name":"fft","return_type":"ComplexMap","visibility":"Public","body":"map = pad(bottom: (Math.pw2ceil(height)) - height, right: (Math.pw2ceil(width)) - width).to_c\nbuffer = Array(Complex).new(Math.max(map.height, map.width)) do\n Complex.zero\nend\nComplexMap.new(map.width, FftUtil.fft2d_unsafe(map.width, map.raw, buffer))\n"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L86"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@raw.size // @width"}},{"html_id":"mask_from(&block:T,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","doc":"Construct a `Mask` from this `GrayscaleImage` using the passed in block to determine if a given pixel should be true or not\n\n```\n# Construct a mask identifying the bright pixels in the bottom left corner of image\nimage.to_gray.mask_from do |pixel, x, y|\n x < image.width // 2 && # left half of image\n y > (image.height // 2) && # bottom half of image\n pixel > 128 # only \"bright\" pixels\nend\n```\n\"Woman\n->\n\"Mask","summary":"

Construct a Mask from this GrayscaleImage using the passed in block to determine if a given pixel should be true or not

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":214,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L214"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(T, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(@raw[i], x, y)\nend)\n"}},{"html_id":"max:T-instance-method","name":"max","doc":"Return the maximum value in this `Map`","summary":"

Return the maximum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":187,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L187"},"def":{"name":"max","return_type":"T","visibility":"Public","body":"@raw.max"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Return the average of the elements in this `Map`","summary":"

Return the average of the elements in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":177,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L177"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@raw.sum / size"}},{"html_id":"min:T-instance-method","name":"min","doc":"Return the minimum value in this `Map`","summary":"

Return the minimum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L182"},"def":{"name":"min","return_type":"T","visibility":"Public","body":"@raw.min"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):self-instance-method","name":"pad","doc":"Pad the borders of this `Map` corresponding to `pad_type`.","summary":"

Pad the borders of this Map corresponding to pad_type.

","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","location":{"filename":"src/cr-image/map.cr","line_number":336,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L336"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"top = top > 0 ? top : all\nbottom = bottom > 0 ? bottom : all\nleft = left > 0 ? left : all\nright = right > 0 ? right : all\nnew_width = (left + width) + right\nnew_raw = initial_raw_pad(pad_type, new_width, top, bottom, left, right, pad_black_value)\nheight.times do |y|\n adjusted_y = y + top\n ((new_raw.to_unsafe + (adjusted_y * new_width)) + left).copy_from(raw.to_unsafe + (y * width), width)\nend\nif pad_type.repeat?\n if top > 0\n copy = new_raw[new_width * top, new_width]\n top.times do |i|\n new_raw[i * new_width, new_width] = copy\n end\n end\n if bottom > 0\n copy = new_raw[new_width * ((top + height) - 1), new_width]\n bottom.times do |i|\n new_raw[((i + top) + height) * new_width, new_width] = copy\n end\n end\nend\nself.class.new(new_width, new_raw)\n"}},{"html_id":"raw:Array(T)-instance-method","name":"raw","doc":"Return the raw array underlying the map","summary":"

Return the raw array underlying the map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L61"},"def":{"name":"raw","return_type":"Array(T)","visibility":"Public","body":"@raw"}},{"html_id":"row(y:Int32):self-instance-method","name":"row","doc":"Get a single dimensional `Map` representing the row at `y`","summary":"

Get a single dimensional Map representing the row at y

","abstract":false,"args":[{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(y : Int32) : self","args_html":"(y : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":127,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L127"},"def":{"name":"row","args":[{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(0, width, y, 1)"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Return the shape of the map - `{width, height}`","summary":"

Return the shape of the map - {width, height}

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L91"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size of the map - `width * height`","summary":"

Size of the map - width * height

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":96,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L96"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@raw.size"}},{"html_id":"sum:T-instance-method","name":"sum","doc":"Return the sum of all values in this `Map`","summary":"

Return the sum of all values in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":192,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L192"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":"@raw.sum"}},{"html_id":"to_a:Array(T)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `raw` array.","summary":"

Receive a copy of the underlying #raw array.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":326,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L326"},"def":{"name":"to_a","return_type":"Array(T)","visibility":"Public","body":"@raw.dup"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":331,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L331"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, raw.map(&.to_c))"}},{"html_id":"to_gray(*,scale:Bool=false):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Map` to a `GrayscaleImage`.\n\nSet `scale: true` so that all of the values will scale, such that `max` will become `255u8`, and `min` will become `0u8`. All other values will be\nlinearly scaled between those values.","summary":"

Convert this Map to a GrayscaleImage.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"args_string":"(*, scale : Bool = false) : GrayscaleImage","args_html":"(*, scale : Bool = false) : GrayscaleImage","location":{"filename":"src/cr-image/map.cr","line_number":313,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L313"},"def":{"name":"to_gray","args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"splat_index":0,"return_type":"GrayscaleImage","visibility":"Public","body":"if scale\n max_val = max\n min_val = min\n multiplier = 255 / (max_val - min_val)\n GrayscaleImage.new(@raw.map do |v|\n (((v - min_val) * multiplier).clamp(0, 255)).to_u8\n end, width)\nelse\n GrayscaleImage.new(@raw.map(&.to_u8), width)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L58"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/mask.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L39"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel\nfrom an image. This can include whether a particular pixel has a value within certain conditions, OR\nif that pixel should be zeroed out or not.\n\nSee `[]=` methods below for examples of how to manually construct masks.\n\n(x,y) - coordinates. Represent these positions in a Mask of size 10x10:\n\n```\n[\n (0,0), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7), (0,8), (0,9),\n (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9),\n (2,0), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,7), (2,8), (2,9),\n (3,0), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (3,7), (3,8), (3,9),\n (4,0), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (4,7), (4,8), (4,9),\n (5,0), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (5,7), (5,8), (5,9),\n (6,0), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6), (6,7), (6,8), (6,9),\n (7,0), (7,1), (7,2), (7,3), (7,4), (7,5), (7,6), (7,7), (7,8), (7,9),\n (8,0), (8,1), (8,2), (8,3), (8,4), (8,5), (8,6), (8,7), (8,8), (8,9),\n (9,0), (9,1), (9,2), (9,3), (9,4), (9,5), (9,6), (9,7), (9,8), (9,9),\n]\n```\n\nAnd every position is a Bool value.\n\nDifferent ways to refer to coordinates:\n```\nmask.at(0, 0) # => (0,0)\nmask[0, 0] # => (0,0), same as .at(0, 0)\nmask[0..1, 4] # => (4,0), (4,1)\nmask[3, 3..5] # => (3,3), (3,4), (3,5)\nmask[2..3, 4..5] # => (2,4), (2,5), (3,4), (3,5)\n```\n\nSee `Operation::Crop` and `Operation::MaskApply` for how this can be useful","summary":"

Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel from an image.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` of width x height, preset to `initial`","summary":"

Construct a new Mask of width x height, preset to initial

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(width : Int32, height : Int32, initial : Bool = true)","args_html":"(width : Int32, height : Int32, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L54"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,int:Int)-class-method","name":"new","doc":"Construct a new `Mask` from an integer (useful for testing or small mask construction)","summary":"

Construct a new Mask from an integer (useful for testing or small mask construction)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"args_string":"(width : Int32, height : Int32, int : Int)","args_html":"(width : Int32, height : Int32, int : Int)","location":{"filename":"src/cr-image/mask.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L66"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, int)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(image:Image,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` from the dimensions of passed in `image` with an initial bit","summary":"

Construct a new Mask from the dimensions of passed in image with an initial bit

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(image : Image, initial : Bool = true)","args_html":"(image : Image, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L72"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,bits:BitArray)-class-method","name":"new","doc":"Construct a new `Mask` with a set width and bits from `bits`","summary":"

Construct a new Mask with a set width and bits from #bits

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"args_string":"(width : Int32, bits : BitArray)","args_html":"(width : Int32, bits : BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L49"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&block:Int32,Int32->Bool)-class-method","name":"new","doc":"Construct a new `Mask` of width x height using `&block` to determine if a bit should be true or not (passed in `x` and `y` coordinates)","summary":"

Construct a new Mask of width x height using &block to determine if a bit should be true or not (passed in x and y coordinates)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","args_html":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","location":{"filename":"src/cr-image/mask.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L59"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":2,"block_arity":2,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32 -> Bool)"},"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, &block) do |_arg0, _arg1|\n yield _arg0, _arg1\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other_bits:Array(BitArray))-class-method","name":"new","doc":"Construct a new `Mask` from an array of `BitArray`. See `#[](xs : Range, ys : Range) : Array(BitArray)`\n\nThis assumes `other_bits[0]` corresponds to `x == 0` in the mask, and the corresponding\n`BitArray` represents all bits for that row. All `BitArray`s must be of the same size in\n`other_bits`.","summary":"

Construct a new Mask from an array of BitArray.

","abstract":false,"args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"args_string":"(other_bits : Array(BitArray))","args_html":"(other_bits : Array(BitArray))","location":{"filename":"src/cr-image/mask.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L82"},"def":{"name":"new","args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other_bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:Mask)-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask)","args_html":"(other : Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":188,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L188"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":180,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L180"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"Array(BitArray)","visibility":"Public","body":"ycount.times.to_a.map do |y|\n BitArray.new(xcount) do |x|\n self[x + xstart, y + ystart]\n end\nend"}},{"html_id":"[](x:Int32,y:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `x` and `y`","summary":"

Return the bit at x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool","args_html":"(x : Int32, y : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":153,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L153"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\n@bits[(y * width) + x]\n"}},{"html_id":"[](xs:Range,y:Int32):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial row specified","summary":"

Return a new BitArray corresponding to the partial row specified

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(xs : Range, y : Int32) : BitArray","args_html":"(xs : Range, y : Int32) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":159,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L159"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(xs, width)\nBitArray.new(count) do |x|\n self[x + start, y]\nend\n"}},{"html_id":"[](x:Int32,ys:Range):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial column specified","summary":"

Return a new BitArray corresponding to the partial column specified

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(x : Int32, ys : Range) : BitArray","args_html":"(x : Int32, ys : Range) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L165"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(ys, height)\nBitArray.new(count) do |y|\n self[x, y + start]\nend\n"}},{"html_id":"[](xs:Range,ys:Range):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(xs : Range, ys : Range) : Array(BitArray)","args_html":"(xs : Range, ys : Range) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L173"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xs, width)\nystart, ycount = resolve_to_start_and_count(ys, height)\nself[xstart, xcount, ystart, ycount]\n"}},{"html_id":"[](index:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":140,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L140"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"@bits[index]"}},{"html_id":"[]=(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bit for coordinate `x` and `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20, 20] = true\nmask.to_gray.save(\"mask_point.jpg\")\n```\n\"Black","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":208,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L208"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"self.set(x, y, value)"}},{"html_id":"[]=(xs:Range,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial row `xs` at column `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_row.jpg\")\n```\n\"Black","summary":"

Set the bits for partial row xs at column y

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, y : Int32, value : Bool) : Bool","args_html":"(xs : Range, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":220,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L220"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if y >= height\n raise(IndexError.new(\"Out of bounds: #{y} is beyond the bounds of this mask's height of #{height}\"))\nend\nstart_x, count_x = resolve_to_start_and_count(xs, width)\n@bits.fill(value, (y * width) + start_x, count_x)\nclear_caches\nvalue\n"}},{"html_id":"[]=(x:Int32,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for row `x` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for row x and partial columns ys

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, ys : Range, value : Bool) : Bool","args_html":"(x : Int32, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":236,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L236"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width\n raise(IndexError.new(\"Out of bounds: #{x} is beyond the bounds of this mask's width of #{width}\"))\nend\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n set(x, y + start_y, value)\nend\nvalue\n"}},{"html_id":"[]=(xs:Range,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial rows `xs` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20..40] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for partial rows xs and partial columns ys

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, ys : Range, value : Bool) : Bool","args_html":"(xs : Range, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":253,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L253"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"start_x, count_x = resolve_to_start_and_count(xs, width)\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n @bits.fill(value, ((y + start_y) * width) + start_x, count_x)\nend\nclear_caches\nvalue\n"}},{"html_id":"[]?(x:Int32,y:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool | Nil","args_html":"(x : Int32, y : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":148,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L148"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[(y * width) + x]?"}},{"html_id":"[]?(index:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool | Nil","args_html":"(index : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":144,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L144"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[index]?"}},{"html_id":"|(other:Mask):Mask-instance-method","name":"|","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask) : Mask","args_html":"(other : Mask) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":487,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L487"},"def":{"name":"|","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n bits[i] | other.bits[i]\nend)"}},{"html_id":"apply(image:Image):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":269,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L269"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.apply(self)"}},{"html_id":"apply(image:Image,&block:UInt8,ChannelType,Int32,Int32->UInt8):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","args_html":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":274,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L274"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8)"},"return_type":"Image","visibility":"Public","body":"image.apply(self, &block)"}},{"html_id":"at(index:Int32):Bool-instance-method","name":"at","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L134"},"def":{"name":"at","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if index >= size\n raise(\"Index #{index} exceeds mask size #{@bits.size}\")\nend\n@bits[index]\n"}},{"html_id":"bits:BitArray-instance-method","name":"bits","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L43"},"def":{"name":"bits","return_type":"BitArray","visibility":"Public","body":"@bits"}},{"html_id":"clone-instance-method","name":"clone","doc":"Create a new `Mask` from this one without modifying it","summary":"

Create a new Mask from this one without modifying it

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L107"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"closing(*,diagonal:Bool=true):Mask-instance-method","name":"closing","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L478"},"def":{"name":"closing","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.closing!(diagonal: diagonal)"}},{"html_id":"closing!(*,diagonal:Bool=true):Mask-instance-method","name":"closing!","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":483,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L483"},"def":{"name":"closing!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"dilate!(diagonal: diagonal).erode!(diagonal: diagonal)"}},{"html_id":"dilate(*,diagonal:Bool=true):Mask-instance-method","name":"dilate","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":419,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L419"},"def":{"name":"dilate","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.dilate!(diagonal: diagonal)"}},{"html_id":"dilate!(*,diagonal:Bool=true):self-instance-method","name":"dilate!","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : self","args_html":"(*, diagonal : Bool = true) : self","location":{"filename":"src/cr-image/mask.cr","line_number":424,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L424"},"def":{"name":"dilate!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"self","visibility":"Public","body":"clear_caches\nnew_bits = bits.dup\nx = -1\ny = 0\nbits.size.times do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n if bits[i]\n next\n end\n new_bits[i] = (((((x != 0) && bits[i - 1]) || ((x != (width - 1)) && bits[i + 1])) || ((y != 0) && bits[i - width])) || ((y != (height - 1)) && bits[i + width])) || (diagonal && ((((((x != 0) && (y != 0)) && bits[(i - width) - 1]) || (((x != (width - 1)) && (y != 0)) && bits[(i - width) + 1])) || (((x != 0) && (y != (height - 1))) && bits[(i + width) - 1])) || (((x != (width - 1)) && (y != (height - 1))) && bits[(i + width) + 1])))\nend\n@bits = new_bits\nself\n"}},{"html_id":"erode(*,diagonal:Bool=true):Mask-instance-method","name":"erode","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":458,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L458"},"def":{"name":"erode","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.erode!(diagonal: diagonal)"}},{"html_id":"erode!(*,diagonal:Bool=true):Mask-instance-method","name":"erode!","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":463,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L463"},"def":{"name":"erode!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"invert!.dilate!(diagonal: diagonal).invert!"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L111"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@bits.size // width"}},{"html_id":"invert-instance-method","name":"invert","doc":"Return a new `Mask` that's a copy of this one with all bits inverted.","summary":"

Return a new Mask that's a copy of this one with all bits inverted.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":129,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L129"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert all bits in this instance of `Mask`. Modifies self.\n\n\"Black\n\nBecomes\n\n\"White","summary":"

Invert all bits in this instance of Mask.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":122,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L122"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"html_id":"opening(*,diagonal:Bool=true):Mask-instance-method","name":"opening","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":468,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L468"},"def":{"name":"opening","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.opening!(diagonal: diagonal)"}},{"html_id":"opening!(*,diagonal:Bool=true):Mask-instance-method","name":"opening!","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":473,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L473"},"def":{"name":"opening!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"erode!(diagonal: diagonal).dilate!(diagonal: diagonal)"}},{"html_id":"region:Region-instance-method","name":"region","doc":"Returns the bounding box of the mask where all true bits are contained. Any pixels outside of the region are false\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask[20, 20..40] = true\nmask.region # => Region(x: 20, y: 20, width: 20, height: 20)\n```\n\n\"Black","summary":"

Returns the bounding box of the mask where all true bits are contained.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":296,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L296"},"def":{"name":"region","return_type":"Region","visibility":"Public","body":"@region || (@region = calculate_region)"}},{"html_id":"segments(*,diagonal:Bool=true):Array(Mask)-instance-method","name":"segments","doc":"Return an array of `Mask`s, each one corresponding to an area of contiguous true bits (identified from flood fills).\n\nMay specify `diagonal: false` for only 4-way (up, down, left, right) flood fill instead of default 8-way.\nStarting with sample mask:\n```\nmask = CrImage::Mask.new(50, 50, false)\n\nmask[5..45, 5..45] = true\nmask[15..35, 15..35] = false\nmask[21..25, 21..25] = true\nmask[26..30, 26..30] = true\n```\n\n\"Black\n\nIts segments look like:\n```\nmask.segments.each_with_index do |segment, i|\n segment.to_gray.save(\"mask_8-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\nUsing `diagonal: false` yields:\n```\nmask.segments(diagonal: false).each_with_index do |segment, i|\n segment.to_gray.save(\"mask_4-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\"Black","summary":"

Return an array of Masks, each one corresponding to an area of contiguous true bits (identified from flood fills).

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Array(Mask)","args_html":"(*, diagonal : Bool = true) : Array(Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":360,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L360"},"def":{"name":"segments","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Array(Mask)","visibility":"Public","body":"diagonal ? (@segments_8_way || (@segments_8_way = calculate_segments(diagonal))) : (@segments_4_way || (@segments_4_way = calculate_segments(diagonal)))"}},{"html_id":"set(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"set","doc":"Set the bit for coordinate `x` and `y`","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":194,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L194"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\nclear_caches\n@bits[(y * width) + x] = value\n"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Returns the dimension of this mask (width x height)","summary":"

Returns the dimension of this mask (width x height)

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":102,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L102"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L97"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"bits.size"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Mask` to a `GrayscaleImage`, with false bits becoming 0, and true bits becoming 255","summary":"

Convert this Mask to a GrayscaleImage, with false bits becoming 0, and true bits becoming 255

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":264,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L264"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(bits.map do |b|\n b ? 255_u8 : 0_u8\nend, width, height)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L42"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/NumericMap","path":"CrImage/NumericMap.html","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"including_types":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Additional methods for `Map` that assume `T` is a numeric type. See `MapImpl`","summary":"

Additional methods for Map that assume T is a numeric type.

","instance_methods":[{"html_id":"+(other:NumericMap(T)):NumericMap(T)-instance-method","name":"+","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L39"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"-(other:NumericMap(T)):NumericMap(T)-instance-method","name":"-","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L38"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"max:T-instance-method","name":"max","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L35"},"def":{"name":"max","return_type":"T","visibility":"Public","body":""}},{"html_id":"min:T-instance-method","name":"min","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L36"},"def":{"name":"min","return_type":"T","visibility":"Public","body":""}},{"html_id":"sum:T-instance-method","name":"sum","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":34,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L34"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":""}},{"html_id":"to_c:NumericMap(Complex)-instance-method","name":"to_c","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L31"},"def":{"name":"to_c","return_type":"NumericMap(Complex)","visibility":"Public","body":""}},{"html_id":"to_f:NumericMap(Float64)-instance-method","name":"to_f","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L32"},"def":{"name":"to_f","return_type":"NumericMap(Float64)","visibility":"Public","body":""}},{"html_id":"to_i:NumericMap(Int32)-instance-method","name":"to_i","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L30"},"def":{"name":"to_i","return_type":"NumericMap(Int32)","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/OneMap","path":"CrImage/OneMap.html","kind":"class","full_name":"CrImage::OneMap","name":"OneMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":525,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L525"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Memory efficient implementation of `MapImpl` when all values are equal to `1`","summary":"

Memory efficient implementation of MapImpl when all values are equal to 1

","constructors":[{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/map.cr","line_number":531,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L531"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":574,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L574"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"OneMap.new(xcount, ycount)"}},{"html_id":"[](x:Int32,y:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":550,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L550"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[](xstart:Int32,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : OneMap","args_html":"(xstart : Int32, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":558,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L558"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, ycount = range_to_index_and_count(yrange)\nOneMap.new(1, ycount)\n"}},{"html_id":"[](xrange:Range,ystart:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : OneMap","args_html":"(xrange : Range, ystart : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":563,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L563"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\nOneMap.new(xcount, 1)\n"}},{"html_id":"[](xrange:Range,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : OneMap","args_html":"(xrange : Range, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":568,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L568"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\n_, ycount = range_to_index_and_count(yrange)\nOneMap.new(xcount, ycount)\n"}},{"html_id":"[](index:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":542,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L542"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(x:Int32,y:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":554,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L554"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(index:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":546,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L546"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":529,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L529"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):OneMap|IntMap-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","location":{"filename":"src/cr-image/map.cr","line_number":582,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L582"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"OneMap | IntMap","visibility":"Public","body":"case pad_type\nin EdgePolicy::Black\n to_i.pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: pad_black_value)\nin EdgePolicy::Repeat\n top = top > 0 ? top : all\n bottom = bottom > 0 ? bottom : all\n left = left > 0 ? left : all\n right = right > 0 ? right : all\n @width = @width + (left + right)\n @height = @height + (top + bottom)\n self\nin EdgePolicy::None\n raise(Exception.new(\"Pad method doesn't support edge policy None\"))\nend"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":534,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L534"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":538,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L538"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"width * height"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":601,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L601"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, Array(Complex).new(size) do\n Complex.new(1)\nend)"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":597,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L597"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, Array(Int32).new(size) do\n 1\nend)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":528,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L528"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Operation","path":"CrImage/Operation.html","kind":"module","full_name":"CrImage::Operation","name":"Operation","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/operation/operation.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/operation.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Module for containing individual operations for `Image` classes.","summary":"

Module for containing individual operations for Image classes.

","types":[{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","path":"CrImage/Operation/BilinearResize.html","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Resize an image using a bilinear resizing algorithm.\n\nTaking sample `image`:\n\n\"Woman\n\n```\nputs image.width, image.height # => 159x199\nimage.bilinear_resize(40, 50).save(\"small_sample.jpg\")\nimage.bilinear_resize(200, 250).save(\"larger_sample.jpg\")\n```\n\"Sample\n\"Sample","summary":"

Resize an image using a bilinear resizing algorithm.

","instance_methods":[{"html_id":"bilinear_resize(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize","doc":"Resizes image to new dimensions","summary":"

Resizes image to new dimensions

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L16"},"def":{"name":"bilinear_resize","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.bilinear_resize!(width, height)"}},{"html_id":"bilinear_resize!(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize!","doc":"Resizes image to new dimensions. Modifies self.","summary":"

Resizes image to new dimensions.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L21"},"def":{"name":"bilinear_resize!","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"x_ratio = width > 1 ? (@width - 1) / (width - 1) : 0\ny_ratio = height > 1 ? (@height - 1) / (height - 1) : 0\neach_channel do |channel, channel_type|\n resized_channel = Array.new(width * height) do\n 0_u8\n end\n height.times do |h|\n width.times do |w|\n x = w * x_ratio\n y = h * y_ratio\n x_ceil = Math.min(@width - 1, x.ceil.to_i)\n x_floor = x.floor.to_i\n y_ceil = Math.min(@height - 1, y.ceil.to_i)\n y_floor = y.floor.to_i\n value = case\n when (x_ceil == x_floor) && (y_ceil == y_floor)\n x_index = x.to_i\n y_index = y.to_i\n channel.unsafe_fetch((@width * y_index) + x_index)\n when x_ceil == x_floor\n x_index = x.to_i\n q_1 = channel.unsafe_fetch((@width * y_ceil) + x_index)\n q_2 = channel.unsafe_fetch((@width * y_floor) + x_index)\n ((q_2 * (y_ceil - y)) + (q_1 * (y - y_floor))).to_u8\n when y_ceil == y_floor\n y_index = y.to_i\n q_1 = channel.unsafe_fetch((@width * y_index) + x_ceil)\n q_2 = channel.unsafe_fetch((@width * y_index) + x_floor)\n ((q_2 * (x_ceil - x)) + (q_1 * (x - x_floor))).to_u8\n else\n v_1 = channel.unsafe_fetch((@width * y_floor) + x_floor)\n v_2 = channel.unsafe_fetch((@width * y_floor) + x_ceil)\n v_3 = channel.unsafe_fetch((@width * y_ceil) + x_floor)\n v_4 = channel.unsafe_fetch((@width * y_ceil) + x_ceil)\n q_1 = (v_1 * (x_ceil - x)) + (v_2 * (x - x_floor))\n q_2 = (v_3 * (x_ceil - x)) + (v_4 * (x - x_floor))\n ((q_1 * (y_ceil - y)) + (q_2 * (y - y_floor))).to_u8\n end\n resized_channel.unsafe_put((width * h) + w, value)\n end\n end\n self[channel_type] = resized_channel\nend\n@width = width\n@height = height\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","path":"CrImage/Operation/BoxBlur.html","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/box_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blurs the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.box_blur(1).save(\"blurred_1_sample.jpg\")\nimage.box_blur(5).save(\"blurred_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blurs the image

","instance_methods":[{"html_id":"box_blur(value:Int32):self-instance-method","name":"box_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L14"},"def":{"name":"box_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.box_blur!(value)"}},{"html_id":"box_blur!(value:Int32):self-instance-method","name":"box_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L18"},"def":{"name":"box_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"horizontal_blur!(value)\nvertical_blur!(value)\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Brightness","path":"CrImage/Operation/Brightness.html","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness","abstract":false,"locations":[{"filename":"src/cr-image/operation/brightness.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Brightens an image (increases white value)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.brightness(2.0)\n```\n\"Brightened","summary":"

Brightens an image (increases white value)

","instance_methods":[{"html_id":"brightness(value:Float64):self-instance-method","name":"brightness","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L12"},"def":{"name":"brightness","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.brightness!(value)"}},{"html_id":"brightness!(value:Float64):self-instance-method","name":"brightness!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L16"},"def":{"name":"brightness!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"each_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, ( (channel.unsafe_fetch(index)) * value))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","path":"CrImage/Operation/ChannelSwap.html","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap","abstract":false,"locations":[{"filename":"src/cr-image/operation/channel_swap.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Swaps channels of `ChannelType` supported by an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.channel_swap(:green, :red) # Crystal autocasting of symbols to Pluto::ChannelType enum is magic\n```\n\"Channel","summary":"

Swaps channels of ChannelType supported by an image

","instance_methods":[{"html_id":"channel_swap(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L12"},"def":{"name":"channel_swap","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"clone.channel_swap!(a, b)"}},{"html_id":"channel_swap!(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap!","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L16"},"def":{"name":"channel_swap!","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"ch_a, ch_b = self[a], self[b]\nself[a] = ch_b\nself[b] = ch_a\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Contrast","path":"CrImage/Operation/Contrast.html","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast","abstract":false,"locations":[{"filename":"src/cr-image/operation/contrast.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Increases contrast of an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.contrast(20)\n```\n\"Contrasted","summary":"

Increases contrast of an image

","instance_methods":[{"html_id":"contrast(value:Float64):self-instance-method","name":"contrast","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L12"},"def":{"name":"contrast","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.contrast!(value)"}},{"html_id":"contrast!(value:Float64):self-instance-method","name":"contrast!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L16"},"def":{"name":"contrast!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"factor = (259 * (value + 255)) / (255 * (259 - value))\neach_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, Math.max(0, (factor * ((channel.unsafe_fetch(index)).to_i - 128)) + 128))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Crop","path":"CrImage/Operation/Crop.html","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop","abstract":false,"locations":[{"filename":"src/cr-image/operation/crop.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Crops an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\n# These calls are equivalent\nimage.crop(40, 30, 80, 80)\nimage[40...120, 30...110]\n```\n\"Cropped","summary":"

Crops an image

","instance_methods":[{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xrange, width)\nystart, ycount = resolve_to_start_and_count(yrange, height)\ncrop(xstart, ystart, xcount, ycount)\n"}},{"html_id":"crop(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L18"},"def":{"name":"crop","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.crop!(x, y, new_width, new_height)"}},{"html_id":"crop(region:Region):self-instance-method","name":"crop","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L14"},"def":{"name":"crop","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop(*region.to_tuple)"}},{"html_id":"crop!(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L32"},"def":{"name":"crop!","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"each_channel do |channel, channel_type|\n self[channel_type] = (UInt8Map.new(width, channel))[x, new_width, y, new_height].raw\nend\n@width = new_width\n@height = new_height\nself\n"}},{"html_id":"crop!(region:Region):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L28"},"def":{"name":"crop!","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop!(*region.to_tuple)"}}]},{"html_id":"Crystal Image/CrImage/Operation/Draw","path":"CrImage/Operation/Draw.html","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw","abstract":false,"locations":[{"filename":"src/cr-image/operation/draw.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L17"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Draws shapes in the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.draw_square(40, 30, 80, 80, CrImage::Color.of(\"#00f\"))\nimage.draw_circle(80, 70, 40, CrImage::Color.of(\"#00f\"))\nimage.draw_line(50, 50, 70, 90, CrImage::Color.of(\"#0f0\"))\n```\n\"Woman\n\"Woman\n\"Woman\n\nCan also use the `fill: true` parameter to fill in the drawn shapes","summary":"

Draws shapes in the image

","instance_methods":[{"html_id":"draw_circle(x:Int,y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle centered at x, y with radius","summary":"

Draw a circle centered at x, y with radius

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L59"},"def":{"name":"draw_circle","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(x, y, radius, color, fill: fill)"}},{"html_id":"draw_circle(region:Region,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L54"},"def":{"name":"draw_circle","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":3,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_circle!(center_x:Int,center_y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle!","abstract":false,"args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L68"},"def":{"name":"draw_circle!","args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"min_x = Math.max(0, center_x - radius)\nmax_x = Math.min(width - 1, center_x + radius)\nmax_y = Math.min(height - 1, center_y + radius)\neach_color_channel do |channel, channel_type|\n 0.upto(radius) do |y|\n theta_0 = Math.asin((Math.max(0, ( y - 1))) / radius.to_f)\n theta_1 = Math.asin(y / radius.to_f)\n x_0 = (radius * (Math.cos(theta_0))).round\n x_1 = (radius * (Math.cos(theta_1))).round\n lower_x_outer = (Math.max(min_x, center_x - x_0)).to_i\n lower_x_inner = (Math.max(min_x, center_x - x_1)).to_i\n upper_x_outer = (Math.min(max_x, center_x + x_0)).to_i\n upper_x_inner = (Math.min(max_x, center_x + x_1)).to_i\n lower_y = center_y - y\n upper_y = center_y + y\n lower_y_outside_of_image = (center_y - y) < 0 || (center_y - y) > max_y\n upper_y_outside_of_image = (center_y + y) < 0 || (center_y + y) > max_y\n left_outer_x_beyond_right_of_image = (center_x - x_0) > max_x\n right_outer_x_beyond_left_of_image = (center_x + x_0) < 0\n left_inner_x_beyond_left_of_image = (center_x - x_1) < 0\n right_inner_x_beyond_right_of_image = (center_x + x_1) > max_x\n if fill\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n else\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(upper_x_inner, lower_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(upper_x_inner, upper_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n end\n end\nend\nself\n"}},{"html_id":"draw_circle!(region:Region,color:Color,*,fill:Bool=false,radius:Int32|Nil=nil):self-instance-method","name":"draw_circle!","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L64"},"def":{"name":"draw_circle!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_line(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L134"},"def":{"name":"draw_line","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.draw_line!(x1, y1, x2, y2, color)"}},{"html_id":"draw_line!(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line!","doc":"Implementation of http://www.edepot.com/linec.html","summary":"

Implementation of http://www.edepot.com/linec.html

","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":139,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L139"},"def":{"name":"draw_line!","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"if (0 <= x1 && x1 < width) && (0 <= y1 && y1 < height)\nelse\n raise(Exception.new(\"First point (#{x1},#{y1}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nif (0 <= x2 && x2 < width) && (0 <= y2 && y2 < height)\nelse\n raise(Exception.new(\"Second point (#{x2},#{y2}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nrise_by_height = false\nshort = y2 - y1\nlong = x2 - x1\nif short.abs > long.abs\n short, long = long, short\n rise_by_height = true\nend\nend_val = long\ngradient = long == 0 ? short : short / long.abs.to_f\nif rise_by_height\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + jump.to_i, y1 + i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nelse\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + i, y1 + jump.to_i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nend\nself\n"}},{"html_id":"draw_square(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L22"},"def":{"name":"draw_square","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"clone.draw_square!(x, y, box_width, box_height, color, fill: fill)"}},{"html_id":"draw_square(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L18"},"def":{"name":"draw_square","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"clone.draw_square!(region, color, fill: fill)"}},{"html_id":"draw_square!(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L30"},"def":{"name":"draw_square!","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"if (x + box_width) > width\n raise(\"Box dimensions extend #{((x + box_width) - width) + 1} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{((y + box_height) - height) + 1} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_color_channel do |channel, channel_type|\n channel[( (y_i * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n channel[((y_i + box_height) * width) + x_i, box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n box_height.times do |i|\n if i == 0\n next\n end\n if fill\n channel[( ((y_i + i) * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n else\n channel.unsafe_put(((y_i + i) * width) + x_i, color[channel_type])\n channel.unsafe_put(((((y_i + i) * width) + x_i) + box_width) - 1, color[channel_type])\n end\n end\nend\nself\n"}},{"html_id":"draw_square!(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L26"},"def":{"name":"draw_square!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_square!(*region.to_tuple, color, fill: fill)"}}]},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","path":"CrImage/Operation/GaussianBlur.html","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Applies a 3x3 Gaussian blur. Implementation derived from [here](https://blog.ivank.net/fastest-gaussian-blur.html)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.gaussian_blur(1).save(\"gaussian_1_sample.jpg\")\nimage.gaussian_blur(5).save(\"gaussian_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Applies a 3x3 Gaussian blur.

","instance_methods":[{"html_id":"gaussian_blur(sigma:Int32):self-instance-method","name":"gaussian_blur","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L14"},"def":{"name":"gaussian_blur","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.gaussian_blur!(sigma)"}},{"html_id":"gaussian_blur!(sigma:Int32):self-instance-method","name":"gaussian_blur!","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L18"},"def":{"name":"gaussian_blur!","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"n = 3\nw_ideal = Math.sqrt((((12 * sigma) * sigma) / n) + 1)\nw_l = w_ideal.floor.to_i\nif (w_l % 2) == 0\n w_l = w_l - 1\nend\nm_ideal = (((((12 * sigma) * sigma) - ((n * w_l) * w_l)) - ((4 * n) * w_l)) - (3 * n)) / ((-4 * w_l) - 4)\nm = m_ideal.round\nsizes = [] of Int32\nn.times do |i|\n sizes << (if i < m\n w_l\n else\n w_l + 2\n end)\nend\nbox_blur!(((sizes.unsafe_fetch(0)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(1)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(2)) - 1) // 2)\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","path":"CrImage/Operation/HistogramEqualize.html","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize","abstract":false,"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":19,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Provides methods for histogram and histogram equalization. Follows method outlined [here](https://www.sci.utah.edu/~acoste/uou/Image/project1/Arthur_COSTE_Project_1_report.html)\n\nIf an image is particularly dark or particularly bright with low contrast, the `Operation::Contrast#contrast` method will only\nmake the image darker or lighter. For images like these, equalizing the image along its histogram will produce better results.\n\n\"A\n\n```\nimage.contrast(10).save(\"contrast.jpg\")\nimage.histogram_equalize.save(\"equalized.jpg\")\n```\n\"Darker\n\"A\n\nThis method does not work well when a given method has a bimodal distribution of color pixels. For example:\n\n\"Woman\n\"Highly","summary":"

Provides methods for histogram and histogram equalization.

","instance_methods":[{"html_id":"histogram(channel_type:ChannelType):Histogram-instance-method","name":"histogram","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Histogram","args_html":"(channel_type : ChannelType) : Histogram","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L107"},"def":{"name":"histogram","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Histogram","visibility":"Public","body":"Histogram.new(self, channel_type)"}},{"html_id":"histogram_equalize:self-instance-method","name":"histogram_equalize","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L111"},"def":{"name":"histogram_equalize","return_type":"self","visibility":"Public","body":"clone.histogram_equalize!"}},{"html_id":"histogram_equalize!:self-instance-method","name":"histogram_equalize!","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":115,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L115"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_color_channel do |channel, channel_type|\n if channel_type.alpha?\n next\n end\n remap = (histogram(channel_type)).equalize\n size.times do |i|\n channel.unsafe_put(i, remap[channel.unsafe_fetch(i)])\n end\nend\nself\n"}}],"types":[{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize/Histogram","path":"CrImage/Operation/HistogramEqualize/Histogram.html","kind":"class","full_name":"CrImage::Operation::HistogramEqualize::Histogram","name":"Histogram","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},"doc":"A histogram of an `Image` for a specific `ChannelType`","summary":"

A histogram of an Image for a specific ChannelType

","constructors":[{"html_id":"new(image:Image,channel_type:ChannelType)-class-method","name":"new","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(image : Image, channel_type : ChannelType)","args_html":"(image : Image, channel_type : ChannelType)","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L24"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, channel_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"cdf:Hash(UInt8,Float64)-instance-method","name":"cdf","doc":"Get the cumulative distribution for the image's histogram","summary":"

Get the cumulative distribution for the image's histogram

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L56"},"def":{"name":"cdf","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"total = 0_f64\n@cumulative_distribution_histogram || (@cumulative_distribution_histogram = normalize.map do |pixel, probability|\n original = total\n total = total + probability\n {pixel, original}\nend.to_h)\n"}},{"html_id":"channel_type:CrImage::ChannelType-instance-method","name":"channel_type","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"channel_type","visibility":"Public","body":"@channel_type"}},{"html_id":"counts:Hash(UInt8,Int32)-instance-method","name":"counts","doc":"Get the raw counts for a given pixel value (0-255) in the image","summary":"

Get the raw counts for a given pixel value (0-255) in the image

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L30"},"def":{"name":"counts","return_type":"Hash(UInt8, Int32)","visibility":"Public","body":"@internal_hist || (@internal_hist = calculate_counts)"}},{"html_id":"equalize:Hash(UInt8,UInt8)-instance-method","name":"equalize","doc":"Remap the cumalitive distribution of pixels to get a new, more spread out pixel value","summary":"

Remap the cumalitive distribution of pixels to get a new, more spread out pixel value

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L66"},"def":{"name":"equalize","return_type":"Hash(UInt8, UInt8)","visibility":"Public","body":"cdf.map do |pixel, cumalative|\n {pixel, ((cumalative * 255).clamp(0, 255)).to_u8}\nend.to_h"}},{"html_id":"image:CrImage::Image-instance-method","name":"image","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"image","visibility":"Public","body":"@image"}},{"html_id":"mean:Float64-instance-method","name":"mean","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L74"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@mean || (@mean = counts.sum do |pixel, count|\n pixel.to_i64 * count\nend.to_f64 / @image.size)"}},{"html_id":"normalize:Hash(UInt8,Float64)-instance-method","name":"normalize","doc":"Get pixel counts normalized - all values between 0.0 and 1.0","summary":"

Get pixel counts normalized - all values between 0.0 and 1.0

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L47"},"def":{"name":"normalize","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"counts.map do |pixel, count|\n {pixel, count.to_f / @image.size}\nend.to_h"}},{"html_id":"std_dev:Float64-instance-method","name":"std_dev","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L80"},"def":{"name":"std_dev","return_type":"Float64","visibility":"Public","body":"@std_dev || (@std_dev = Math.sqrt(counts.sum do |value, count|\n count * ((value.to_i64 - mean) ** 2)\nend.to_f64 / @image.size))"}}]}]},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","path":"CrImage/Operation/HorizontalBlur.html","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the horizontal axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.horizontal_blur(1).save(\"horizontal_1_sample.jpg\")\nimage.horizontal_blur(5).save(\"horizontal_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the horizontal axis

","instance_methods":[{"html_id":"horizontal_blur(k:Int32):self-instance-method","name":"horizontal_blur","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(k)"}},{"html_id":"horizontal_blur!(k:Int32):self-instance-method","name":"horizontal_blur!","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_blur!","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((k + k) + 1)\neach_color_channel do |channel|\n @height.times do |y|\n center_index : Int32 = y * @width\n left__bound : Int32 = center_index\n right_bound : Int32 = center_index + k\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last__value : Int32 = (channel.unsafe_fetch((center_index + @width) - 1)).to_i\n current_sum : Int32 = (k + 1) * first_value\n (0..(k - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + i))\n end\n (0..k).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n center_index = center_index + 1\n end\n ((k + 1)..((@width - k) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n ((@width - k)..(@width - 1)).each do\n current_sum = current_sum + (last__value - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","path":"CrImage/Operation/MaskApply.html","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply","abstract":false,"locations":[{"filename":"src/cr-image/operation/mask_apply.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Apply a mask to an image\n\nTaking sample `image`:\n\n\"Woman\n\nAnd mask\n\n\"Black\n\n```\nmask = CrImage::Mask.new(image, false)\nmask[50..90, 65..75] = true\nmask.to_gray.save(\"apply_mask_mask.jpg\")\n\nimage.apply(mask).save(\"apply_mask.jpg\")\n\nimage.apply_color(mask, CrImage::Color.of(\"#00f\")).save(\"apply_mask_color.jpg\")\n\nimage.apply(mask) do |pixel, channel_type, x, y|\n Math.min(255, pixel + 50).to_u8 if channel_type.blue?\nend.save(\"apply_mask_block.jpg\")\n```\n\"Image\n\"Thin\n\"Thin","summary":"

Apply a mask to an image

","instance_methods":[{"html_id":"apply(mask:Mask):self-instance-method","name":"apply","doc":"Black out all pixels but those found in the mask","summary":"

Black out all pixels but those found in the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L29"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"clone.apply!(mask)"}},{"html_id":"apply(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply","doc":"Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.\n\nDoes not change values not matched by the mask","summary":"

Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L36"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"clone.apply!(mask, &block)"}},{"html_id":"apply!(mask:Mask):self-instance-method","name":"apply!","doc":"TODO: add apply version that accepts 1+ ChannelType that the mask should apply to (i.e. make a background completely transparent, not just transparent black)","summary":"

TODO add apply version that accepts 1+ ChannelType that the mask should apply to (i.e.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L46"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? pixel : 0_u8\n end\nend\nself\n"}},{"html_id":"apply!(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L55"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel, channel_type|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? (block.call(pixel, channel_type, i % width, i // width)) || pixel : pixel\n end\nend\nself\n"}},{"html_id":"apply_color(mask:Mask,color:Color):self-instance-method","name":"apply_color","doc":"Change the color of all pixels that match the mask","summary":"

Change the color of all pixels that match the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L41"},"def":{"name":"apply_color","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.apply_color!(mask, color)"}},{"html_id":"apply_color!(mask:Mask,color:Color):self-instance-method","name":"apply_color!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L66"},"def":{"name":"apply_color!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"apply!(mask) do |_, channel_type|\n color[channel_type]\nend"}}]},{"html_id":"Crystal Image/CrImage/Operation/Pad","path":"CrImage/Operation/Pad.html","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad","abstract":false,"locations":[{"filename":"src/cr-image/operation/pad.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Pads an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.pad(left: 50, right: 50)\nimage.pad(left: 50, right: 50, pad_type: CrImage::EdgePolicy::Repeat)\n```\n\"Picture\n\"Picture","summary":"

Pads an image

","instance_methods":[{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L14"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.pad!(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type)"}},{"html_id":"pad!(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad!","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L18"},"def":{"name":"pad!","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"orig_width = width\neach_channel do |channel, channel_type|\n padded = (UInt8Map.new(orig_width, channel)).pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: channel_type.default)\n self[channel_type] = padded.raw\n @width = padded.width\n @height = padded.height\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Rotate","path":"CrImage/Operation/Rotate.html","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate","abstract":false,"locations":[{"filename":"src/cr-image/operation/rotate.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Rotates an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.rotate(45)\nimage.rotate(45, pad: true)\n```\n\"Rotated\n\"Rotated","summary":"

Rotates an image

","instance_methods":[{"html_id":"rotate(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate","doc":"Rotates an image by `degrees`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L20"},"def":{"name":"rotate","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.rotate!(degrees, center_x: center_x, center_y: center_y, radius: radius, pad: pad, pad_type: pad_type)"}},{"html_id":"rotate!(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate!","doc":"Rotates an image by `degrees`. Modifies `self`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees.

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L38"},"def":{"name":"rotate!","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"if pad_type.none?\n raise(Exception.new(\"Edge policy None doesn't apply to rotation\"))\nend\nif pad && radius >= 0\n raise(Exception.new(\"Can't pad image and limit rotation by radius\"))\nend\nradians = ((-Math::PI) * degrees) / 180\nsin = Math.sin(radians)\ncos = Math.cos(radians)\nradius_sq = radius * radius\nnew_width, new_size, out_center_x, out_center_y = output_dimensions(pad, degrees, center_x, center_y)\neach_channel do |channel, channel_type|\n new_x = -1\n new_y = 0\n self[channel_type] = Array.new(new_size) do |i|\n new_x = new_x + 1\n if new_x == new_width\n new_x = 0\n new_y = new_y + 1\n end\n if radius >= 0 && (((new_x - center_x) ** 2) + ((new_y - center_y) ** 2)) > radius_sq\n next channel.unsafe_fetch(i)\n end\n orig_x = (((cos * (new_x - out_center_x)) - (sin * (new_y - out_center_y))) + center_x).round.to_i\n orig_y = (((sin * (new_x - out_center_x)) + (cos * (new_y - out_center_y))) + center_y).round.to_i\n if pad_type.black?\n if ((orig_x < 0 || orig_x >= width) || orig_y < 0) || orig_y >= height\n next channel_type.default\n end\n else\n orig_x = orig_x.clamp(0, width - 1)\n orig_y = orig_y.clamp(0, height - 1)\n end\n channel.unsafe_fetch((orig_y * width) + orig_x)\n end\nend\n@width = new_width\n@height = new_size // new_width\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","path":"CrImage/Operation/VerticalBlur.html","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the vertical axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.vertical_blur(1).save(\"vertical_1_sample.jpg\")\nimage.vertical_blur(5).save(\"vertical_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the vertical axis

","instance_methods":[{"html_id":"vertical_blur(value:Int32):self-instance-method","name":"vertical_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L14"},"def":{"name":"vertical_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.vertical_blur!(value)"}},{"html_id":"vertical_blur!(value:Int32):self-instance-method","name":"vertical_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L18"},"def":{"name":"vertical_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((value + value) + 1)\neach_color_channel do |channel|\n @width.times do |x|\n center_index : Int32 = x\n left_bound : Int32 = center_index\n right_bound : Int32 = center_index + (value * @width)\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last_value : Int32 = (channel.unsafe_fetch(center_index + (@width * (@height - 1)))).to_i\n current_sum : Int32 = (value + 1) * first_value\n (0..(value - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + (i * @width)))\n end\n (0..value).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n current_sum = current_sum + (last_value - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n center_index = center_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"Crystal Image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a rectangular area on an `Image` from its upper left corner `x` and `y` coordinates, and a `width` and `height`.\n\nSee `Operation::Crop#crop` and `Operation::Draw#draw_square` for examples using it.","summary":"

Represents a rectangular area on an Image from its upper left corner #x and #y coordinates, and a #width and #height.

","constructors":[{"html_id":"center(x:UInt16,y:UInt16,width:UInt16,height:UInt16):Region-class-method","name":"center","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","location":{"filename":"src/cr-image/region.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L11"},"def":{"name":"center","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"return_type":"Region","visibility":"Public","body":"new(x - (width // 2), y - (height // 2), width, height)"}},{"html_id":"new(x:UInt16,y:UInt16,width:UInt16,height:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"new","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(x, y, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"center:Tuple(Int32,Int32)-instance-method","name":"center","doc":"Return the `{x, y}` tuple of the center coordinates of this `Region`","summary":"

Return the {x, y} tuple of the center coordinates of this Region

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L21"},"def":{"name":"center","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{(width.to_i // 2) + x.to_i, (height.to_i // 2) + y.to_i}"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@x.clone, @y.clone, @width.clone, @height.clone)"}},{"html_id":"copy_with(x_x=@x,y_y=@y,width_width=@width,height_height=@height)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"args_string":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","args_html":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"copy_with","args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"visibility":"Public","body":"self.class.new(_x, _y, _width, _height)"}},{"html_id":"crop(image:Image):Image-instance-method","name":"crop","doc":"Crop a provided `Image` with this region, using `Operation::Crop#crop`","summary":"

Crop a provided Image with this region, using Operation::Crop#crop

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/region.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L16"},"def":{"name":"crop","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.crop(self)"}},{"html_id":"height:UInt16-instance-method","name":"height","abstract":false,"def":{"name":"height","return_type":"UInt16","visibility":"Public","body":"@height"}},{"html_id":"to_tuple:Tuple(Int32,Int32,Int32,Int32)-instance-method","name":"to_tuple","doc":"Return this `Region` as a `x`, `y`, `width`, and `height` tuple","summary":"

Return this Region as a #x, #y, #width, and #height tuple

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L26"},"def":{"name":"to_tuple","return_type":"Tuple(Int32, Int32, Int32, Int32)","visibility":"Public","body":"{x.to_i, y.to_i, width.to_i, height.to_i}"}},{"html_id":"width:UInt16-instance-method","name":"width","abstract":false,"def":{"name":"width","return_type":"UInt16","visibility":"Public","body":"@width"}},{"html_id":"x:UInt16-instance-method","name":"x","abstract":false,"def":{"name":"x","return_type":"UInt16","visibility":"Public","body":"@x"}},{"html_id":"y:UInt16-instance-method","name":"y","abstract":false,"def":{"name":"y","return_type":"UInt16","visibility":"Public","body":"@y"}}]},{"html_id":"Crystal Image/CrImage/RepeatView","path":"CrImage/RepeatView.html","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":52,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L52"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to the nearest edge of that `Map`","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to the nearest edge of that Map

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = RepeatView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L53"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = ((x - @half_width) + @map_x).clamp(0, @map.width - 1)\nadjusted_y = ((y - @half_height) + @map_y).clamp(0, @map.height - 1)\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/rgba_image.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L2"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L36"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L29"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image with red, green, blue, and alpha color channels (i.e. a color image). This image type is likely the one read from and written to file (or `IO`).","summary":"

An image with red, green, blue, and alpha color channels (i.e.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L10"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L13"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):Color-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Color","args_html":"(x : Int32, y : Int32) : Color","location":{"filename":"src/cr-image/rgba_image.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L49"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Color","visibility":"Public","body":"index = (y * width) + x\nColor.new(red[index], green[index], blue[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the channel corresponding to `channel_type`","summary":"

Return the channel corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L55"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red\nwhen ChannelType::Green\n @green\nwhen ChannelType::Blue\n @blue\nwhen ChannelType::Alpha\n @alpha\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the corresponding `channel_type` with `channel`","summary":"

Set the corresponding channel_type with channel

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L66"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red = channel\nwhen ChannelType::Green\n @green = channel\nwhen ChannelType::Blue\n @blue = channel\nwhen ChannelType::Alpha\n @alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@blue"}},{"html_id":"blue=(blue:Array(UInt8))-instance-method","name":"blue=","abstract":false,"args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"args_string":"(blue : Array(UInt8))","args_html":"(blue : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue=","args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@blue = blue"}},{"html_id":"clone:RGBAImage-instance-method","name":"clone","doc":"Create a copy of this image","summary":"

Create a copy of this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L21"},"def":{"name":"clone","return_type":"RGBAImage","visibility":"Public","body":"self.class.new(@red.clone, @green.clone, @blue.clone, @alpha.clone, @width, @height)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L41"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L33"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nnil\n"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@green"}},{"html_id":"green=(green:Array(UInt8))-instance-method","name":"green=","abstract":false,"args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"args_string":"(green : Array(UInt8))","args_html":"(green : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green=","args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@green = green"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"mask_from(&block:Color,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":103,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L103"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Color, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(Color.new(red.unsafe_fetch(i), green.unsafe_fetch(i), blue.unsafe_fetch(i), alpha.unsafe_fetch(i)), x, y)\nend)\n"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@red"}},{"html_id":"red=(red:Array(UInt8))-instance-method","name":"red=","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"args_string":"(red : Array(UInt8))","args_html":"(red : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red=","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@red = red"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels in this image","summary":"

Return the number of pixels in this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L99"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"to_gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert color image to `GrayscaleImage`, using the NTSC formula as default values.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Convert color image to GrayscaleImage, using the NTSC formula as default values.

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","location":{"filename":"src/cr-image/rgba_image.cr","line_number":83,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L83"},"def":{"name":"to_gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(red.map_with_index do |red_pix, i|\n (Math.min(255, ((red_pix * red_multiplier) + (@green[i] * green_multiplier)) + (@blue[i] * blue_multiplier))).to_u8\nend, width, height)"}},{"html_id":"to_pluto:Pluto::ImageRGBA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L37"},"def":{"name":"to_pluto","return_type":"Pluto::ImageRGBA","visibility":"Public","body":"Pluto::ImageRGBA.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":94,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L94"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"self"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L30"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.red.to_u16 << 8, color.green.to_u16 << 8, color.blue.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"Crystal Image/CrImage/UInt8Map","path":"CrImage/UInt8Map.html","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":495,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L495"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `UInt8` types. This type is useful for `MapImpl` operations around channels.","summary":"

Implementation of MapImpl for UInt8 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":502,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L502"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":498,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L498"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":496,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L496"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Window","path":"CrImage/Window.html","kind":"class","full_name":"CrImage::Window(T)","name":"Window","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L8"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/BlackView","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView"},{"html_id":"Crystal Image/CrImage/ErrorView","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView"},{"html_id":"Crystal Image/CrImage/RepeatView","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a read-only view on top of a `Map`.\n\nConstructing one of these over a larger `Map` allows for a re-indexed view within that map. If needing to sum all values\nwithin a certain area, a `Window` can be constructed around that area and then summed from that.\n\nSee `RepeatView`, `ErrorView`, and `BlackView` for specific edge handling cases.","summary":"

Represents a read-only view on top of a Map.

","constructors":[{"html_id":"new(width:Int32,height:Int32,map:CrImage::Map(T),map_x:Int32,map_y:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","args_html":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"visibility":"Public","body":"_ = Window(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L22"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"half_height:Int32-instance-method","name":"half_height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L10"},"def":{"name":"half_height","return_type":"Int32","visibility":"Public","body":"@half_height"}},{"html_id":"half_width:Int32-instance-method","name":"half_width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L9"},"def":{"name":"half_width","return_type":"Int32","visibility":"Public","body":"@half_width"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L12"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"map:Map(T)-instance-method","name":"map","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L13"},"def":{"name":"map","return_type":"Map(T)","visibility":"Public","body":"@map"}},{"html_id":"map_x:Int32-instance-method","name":"map_x","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L14"},"def":{"name":"map_x","return_type":"Int32","visibility":"Public","body":"@map_x"}},{"html_id":"map_y:Int32-instance-method","name":"map_y","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L15"},"def":{"name":"map_y","return_type":"Int32","visibility":"Public","body":"@map_y"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Calculate the mean for all values in the window","summary":"

Calculate the mean for all values in the window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L41"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"sum / size"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the size of this window","summary":"

Return the size of this window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L46"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"sum:Float64-instance-method","name":"sum","doc":"Sum all values in the window together","summary":"

Sum all values in the window together

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":25,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L25"},"def":{"name":"sum","return_type":"Float64","visibility":"Public","body":"sum(&.itself)"}},{"html_id":"sum(&:T,Int32,Int32,self->T):Float64-instance-method","name":"sum","doc":"Iterate over all values within the window and sum the result of the passed in block","summary":"

Iterate over all values within the window and sum the result of the passed in block

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L30"},"def":{"name":"sum","yields":4,"block_arity":4,"block_arg":{"name":"","external_name":"","restriction":"(T, Int32, Int32, self -> T)"},"return_type":"Float64","visibility":"Public","body":"ret = 0_f64\nheight.times do |y|\n width.times do |x|\n ret = ret + (yield self[x, y], x, y, self).to_f64\n end\nend\nret\n"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L11"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]}]},{"html_id":"Crystal Image/Pluto","path":"Pluto.html","kind":"module","full_name":"Pluto","name":"Pluto","abstract":false,"locations":[{"filename":"lib/pluto/src/pluto.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto.cr#L3"},{"filename":"lib/pluto/src/pluto/channel_type.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/channel_type.cr#L1"},{"filename":"src/pluto.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L20"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This project was initially a fork of [Pluto](https://github.com/phenopolis/pluto/), and so can very easily convert\nbetween the underlying format used by `CrImage` and `Pluto`. To easily convert a `Pluto` image to `CrImage`, simply:\n\n```\nrequire \"cr-image/pluto\"\n\nimage # => Pluto::ImageRGBA\nimage.to_crimage # => CrImage::RGBAImage\nimage.to_crimage.to_pluto # => Pluto::ImageRGBA\n```\nThis also works with `Pluto::ImageGA` and `CrImage::GrayscaleImage`, respectively.\n\n> Why are `ImageRGBA` and `RGBAImage` names mirrored?\n\nThe current `CrImage` names are a carry over from when originally forked from `Pluto`. However, after `Pluto` renamed `RGBAImage` to `ImageRGBA`, I noticed it became\nmore difficult to visually distinguish between `ImageRGBA` and `ImageGA`, as opposed to `RGBAImage` and `GrayscaleImage`, so I kept the older names.","summary":"

This project was initially a fork of Pluto, and so can very easily convert between the underlying format used by CrImage and Pluto.

","types":[{"html_id":"Crystal Image/Pluto/ImageGA","path":"Pluto/ImageGA.html","kind":"class","full_name":"Pluto::ImageGA","name":"ImageGA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_ga.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/image_ga.cr#L3"},{"filename":"src/pluto.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::GrayscaleImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/pluto.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L29"},"def":{"name":"to_crimage","return_type":"CrImage::GrayscaleImage","visibility":"Public","body":"new(gray.clone, alpha.clone, width, height)"}}]},{"html_id":"Crystal Image/Pluto/ImageRGBA","path":"Pluto/ImageRGBA.html","kind":"class","full_name":"Pluto::ImageRGBA","name":"ImageRGBA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_rgba.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/image_rgba.cr#L3"},{"filename":"src/pluto.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","doc":"Con","summary":"

Con

","abstract":false,"location":{"filename":"src/pluto.cr","line_number":23,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L23"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"CrImage::RGBAImage.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}}]}]},{"html_id":"Crystal Image/StumpyCore","path":"StumpyCore.html","kind":"module","full_name":"StumpyCore","name":"StumpyCore","abstract":false,"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/canvas.cr#L3"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba.cr#L4"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/mixing.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/mixing.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/utils.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/utils.cr#L1"},{"filename":"src/stumpy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"A module owned by [StumpyCr](https://github.com/stumpycr/stumpy_core)","summary":"

A module owned by StumpyCr

","types":[{"html_id":"Crystal Image/StumpyCore/Canvas","path":"StumpyCore/Canvas.html","kind":"class","full_name":"StumpyCore::Canvas","name":"Canvas","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/canvas.cr#L31"},{"filename":"src/stumpy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L6"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/StumpyCore","kind":"module","full_name":"StumpyCore","name":"StumpyCore"},"doc":"A canvas is 2D array of `RGBA` pixels\n\nTo create a canvas of size `400` x `200`\n\n```\ncanvas = StumpyCore::Canvas.new(400, 200)\n```\n\nThe default background color is transparent,\nbut it can be passed in as a parameter or as a block\nthat returns the color value for each `{x, y}` pair.\n\n```\ncanvas2 = StumpyCore::Canvas.new(400, 200, RGBA::WHITE)\n```\n\n```\ncanvas3 = StumpyCore::Canvas.new(256, 256) do |x, y|\n RGBA.from_rgb_n(x, y, 255, 8)\nend\n```\n![image](https://github.com/stumpycr/stumpy_core/blob/feature/images/rainbow.png?raw=true)\n\nBecause of the way pixels are stored in a `Slice`,\n`Canvas`es are limited to `Int32::MAX = 2147483647` pixels in total,\ne.g. a maximal size of 46340x46340 for a square image.","summary":"

A canvas is 2D array of RGBA pixels

","instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L7"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"size = width * height\nred = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\neach_row do |row|\n row.each do |rgba|\n red << (rgba.r >> 8).to_u8\n green << (rgba.g >> 8).to_u8\n blue << (rgba.b >> 8).to_u8\n alpha << (rgba.a >> 8).to_u8\n end\nend\nCrImage::RGBAImage.new(red, green, blue, alpha, width, height)\n"}}]}]},{"html_id":"Crystal Image/Tutorial","path":"Tutorial.html","kind":"module","full_name":"Tutorial","name":"Tutorial","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/chromakey_tutorial.cr#L35"},{"filename":"src/tutorials/tutorial.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/tutorial.cr#L7"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This fictional module exists to provide tutorials for using CrImage in the documentation\n\nSee:\n* `EdgeDetection`\n* `ChromaKey`\n* `FindDifferences`","summary":"

This fictional module exists to provide tutorials for using CrImage in the documentation

","types":[{"html_id":"Crystal Image/Tutorial/ChromaKey","path":"Tutorial/ChromaKey.html","kind":"module","full_name":"Tutorial::ChromaKey","name":"ChromaKey","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/chromakey_tutorial.cr#L35"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can swap out the background by creating a mask representing the pixels that are close in color, and replacing them using an `MaskApply#apply_color` method.\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"sample.jpg\")\n\n# Grab a color from the background, for comparison\nbackground = image[10, 10]\n\n# Construct a mask of all pixels within a color distance of our background\nbackground_mask = image.mask_from do |color|\n # 25 chosen through trial-and-error\n color.dist(background) < 25\nend\n .closing! # Remove small `true` regions\n .opening! # Remove small `false` regions\n\n# Now make the background blue\nimage\n .apply_color(background_mask, CrImage::Color.of(\"#0000cc\"))\n .save(\"chromakey.jpg\")\n```\n\nResults in image:\n\n\"Background\n\nThis script ran on my machine in `4ms` in `--release` mode.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/EdgeDetection","path":"Tutorial/EdgeDetection.html","kind":"module","full_name":"Tutorial::EdgeDetection","name":"EdgeDetection","abstract":false,"locations":[{"filename":"src/tutorials/edge_detection_tutorial.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/edge_detection_tutorial.cr#L38"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can run the [Sobel Operator](https://en.wikipedia.org/wiki/Sobel_operator) to detect edges in it:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nvertical_sobel = CrImage::IntMap.new([\n [-1, -2, -1],\n [0, 0, 0],\n [1, 2, 1],\n])\n\nhorizontal_sobel = CrImage::IntMap.new([\n [-1, 0, 1],\n [-2, 0, 2],\n [-1, 0, 1],\n])\n\nimage = CrImage::GrayscaleImage.open(\"sample.jpg\")\n\ndx = image.cross_correlate(horizontal_sobel)\ndy = image.cross_correlate(vertical_sobel)\n\n(dx ** 2 + dy ** 2).to_gray(scale: true).save(\"edge_detection.jpg\")\n```\n\nResults in image:\n\n\"Black\n\nThis script ran on my machine in `11ms` in `--release` mode.\n\n**Note**: This tutorial is using `cross_correlate`. For large images (or medium-to-large operators), the `cross_correlate_fft` may perform better.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/FindDifferences","path":"Tutorial/FindDifferences.html","kind":"module","full_name":"Tutorial::FindDifferences","name":"FindDifferences","abstract":false,"locations":[{"filename":"src/tutorials/find_differences.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/find_differences.cr#L55"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `differences.jpg` image:\n\n\"Two\n\nWe can programatically detect _most_ of the differences between these two images:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"differences.jpg\")\nret = image.clone\n\n# Perform a blur to remove random noise\nimg1 = image.gaussian_blur(1)[2...340, ..]\nimg2 = image.gaussian_blur(1)[361...699, ..]\n\n# Convert each color channel into a IntMap\nred_img1 = CrImage::UInt8Map.new(img1.width, img1.red).to_i\ngre_img1 = CrImage::UInt8Map.new(img1.width, img1.green).to_i\nblu_img1 = CrImage::UInt8Map.new(img1.width, img1.blue).to_i\nred_img2 = CrImage::UInt8Map.new(img2.width, img2.red).to_i\ngre_img2 = CrImage::UInt8Map.new(img2.width, img2.green).to_i\nblu_img2 = CrImage::UInt8Map.new(img2.width, img2.blue).to_i\n\n# Calculate a pixel by pixel difference calculation, convert it to a `Mask`\nred_mask = (red_img1 - red_img2).abs.>(50)\ngre_mask = (gre_img1 - gre_img2).abs.>(50)\nblu_mask = (blu_img1 - blu_img2).abs.>(50)\n\n# Combine the different color channel masks\ncombo_mask = (red_mask | blu_mask | gre_mask).dilate!\n\n# Expensive way to make a thick box.\n3.times do\n combo_mask.dilate!.segments.each do |v|\n # Draw a box in the first image\n ret.draw_square!(v.region.x + 2, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n # ... and the second image\n ret.draw_square!(v.region.x + 361, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n end\nend\n\nret.save(\"differences_end.jpg\")\n```\n\nResults in image:\n\n\"Two\n\nThis script ran on my machine in `66ms` in `--release` mode.\n\n**NOTE**: There's a difference in the seeds on one of the watermelons that don't survive the blurring process, and so aren't picked\nup by the differences algorithm above.","summary":"

Given differences.jpg image:

"}]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index ac1bf20..270ad35 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"Crystal Image","body":"

Crystal Image (Processing)

\n\nThis shard aims to provide feature rich image processing abilities, both for the purpose of\nimage manipulation as well as feature / information extraction from those images.\n\nThe code here originated as a fork from [Pluto](https://github.com/phenopolis/pluto) and further takes inspiration from [Stumpy](https://github.com/stumpycr/stumpy_core),\nand support converting to and from both of those libraries.\n\nAll sample images used are from [Unsplash](https://unsplash.com/).\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cr-image:\n github: vici37/cr-image\n ```\n\n2. Run `shards install`\n\n## Usage\n\nCrImage supports the formats:\n* PPM\n* JPEG (requires `libturbojpeg`)\n* PNG (requirens `libspng`)\n* WebP (requires `libwebp`)\n\nFor the formats that require a linked library, they must be `require`d explicitly:\n\n```crystal\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\nrequire \"cr-image/png\"\nrequire \"cr-image/webp\"\n\n# Or, alternatively\nrequire \"cr-image/all_formats\"\n```\n\n### Example\n\nAssuming an image `moon.jpg` already exists\n\n\"Picture\n\n```crystal\nrequire \"cr-image\"\n\nimage = CrImage::RGBAImage.open(\"moon.jpg\")\n\n# create a mask identifying all pixels with light (i.e. the moon)\nmoon_mask = image\n .to_gray\n .threshold(8) # pixels are UInt8, with 0 as black and 255 as white\n\n# Crop out the moon from the image, and save it to a new file\nimage.crop(\n moon_mask.region # smallest area that encompasses all true bits in mask\n).save(\"moon_cropped.jpg\")\n\n```\n\nYields this image:\n\n\"Cropped\n\n[See the tutorials](http://troy.sornson.io/cr-image/Tutorial.html) for more examples.\n\n### [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core) Conversion\n\nIf your library or application already uses Pluto or Stumpy and you want to use\nsome of the functionality of this library, CrImage also provides some optional\nconversion methods:\n\n```crystal\nrequire \"cr-image/pluto\"\npluto_image # => Pluto::ImageRGBA\npluto_image.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_pluto # => Pluto::ImageRGBA\n```\n\n**NOTE:** Currently Pluto and CrImage share the same bindings for `libturbojpeg`, `libspng`, and `libwebp`. If you\nuse Pluto, you _cannot_ use those formats from CrImage.\n\n\n```crystal\nrequire \"cr-image/stumpy\"\nstumpy_canvas # => StumpyCore::Canvas\nstumpy_canvas.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_stumpy # => StumpyCore::Canvas\n```\n\n**NOTE:** Stumpy uses `UInt16` for its underlying raw image storage per channel per pixel, while Pluto and\nCrImage uses `UInt8`. Converting from a Stumpy `Canvas` object to `RGBAImage` may lose quality if the original\nimage used 16 bit color channels (i.e. 16-bit PNG). Most image formats tend to use 8-bit color channels.\n\n## Development\n\nThis requires `libwebp`, `libspng`, and `libturbojpeg` to run. Then:\n\n```\n> make test\n```\n\nTo ensure all tests run and pass.\n\n## Contributing\n\n1. [Fork it](https://github.com/Vici37/cr-image/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Troy Sornson](https://github.com/Vici37) - creator and maintainer\n","program":{"html_id":"Crystal Image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"Crystal Image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"Crystal Image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image.cr#L20"},{"filename":"src/cr-image/edge_policy.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L1"},{"filename":"src/cr-image/map.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L1"},{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/region.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L1"},{"filename":"src/cr-image/window_view.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L1"},{"filename":"src/lib-formats/bindings/lib_jpeg_turbo.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_jpeg_turbo.cr#L1"},{"filename":"src/lib-formats/bindings/lib_spng.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_spng.cr#L1"},{"filename":"src/lib-formats/bindings/lib_webp.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/bindings/lib_webp.cr#L1"},{"filename":"src/pluto.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L35"},{"filename":"src/stumpy.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This module by itself isn't very interesting. Try taking a look through the [tutorials](./Tutorial.html) for better examples.","summary":"

This module by itself isn't very interesting.

","types":[{"html_id":"Crystal Image/CrImage/BlackView","path":"CrImage/BlackView.html","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L76"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to zero (or black)","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to zero (or black)

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = BlackView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":77,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L77"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n return T.zero\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/channel_type.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Red","name":"Red","value":"0"},{"id":"Green","name":"Green","value":"1"},{"id":"Blue","name":"Blue","value":"2"},{"id":"Gray","name":"Gray","value":"3"},{"id":"Alpha","name":"Alpha","value":"4"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_color_channel` and `GrayscaleImage#each_color_channel`","summary":"

Enum representing different image channels supported by CrImage

","instance_methods":[{"html_id":"alpha?-instance-method","name":"alpha?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L9"},"def":{"name":"alpha?","visibility":"Public","body":"self == Alpha"}},{"html_id":"blue?-instance-method","name":"blue?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"html_id":"default:UInt8-instance-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L11"},"def":{"name":"default","return_type":"UInt8","visibility":"Public","body":"alpha? ? 255_u8 : 0_u8"}},{"html_id":"gray?-instance-method","name":"gray?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L8"},"def":{"name":"gray?","visibility":"Public","body":"self == Gray"}},{"html_id":"green?-instance-method","name":"green?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L6"},"def":{"name":"green?","visibility":"Public","body":"self == Green"}},{"html_id":"red?-instance-method","name":"red?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"Crystal Image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/color.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for parsing and representing colors that can be used for certain\nmethods in CrImage.\n\nSee `Operation::MaskApply#apply_color`, `Operation::Draw#draw_square`, or `Operation::Draw#draw_circle`","summary":"

Utility class for parsing and representing colors that can be used for certain methods in CrImage.

","constructors":[{"html_id":"default:Color-class-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L11"},"def":{"name":"default","return_type":"Color","visibility":"Public","body":"new(ChannelType::Red.default, ChannelType::Green.default, ChannelType::Blue.default, ChannelType::Alpha.default)"}},{"html_id":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=ChannelType::Alpha.default)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L8"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"of(color:String):Color-class-method","name":"of","doc":"Parse color from a hex string:\n\n```\nColor.of(\"#1\") # same as \"#11\" => Color.new(17, 17, 17, 255)\nColor.of(\"#01\") # => Color.new(1, 1, 1, 255)\nColor.of(\"#123\") # same as \"#112233\" => Color.new(17, 34, 51, 255)\nColor.of(\"#1234\") # same as \"#11223344\" => Color.new(34, 51, 68, 17)\nColor.of(\"#010203\") # => Color.new(1, 2, 3, 255)\nColor.of(\"#01020304\") # => Color.new(2, 3, 4, 1)\n```","summary":"

Parse color from a hex string:

","abstract":false,"args":[{"name":"color","external_name":"color","restriction":"String"}],"args_string":"(color : String) : Color","args_html":"(color : String) : Color","location":{"filename":"src/cr-image/color.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L49"},"def":{"name":"of","args":[{"name":"color","external_name":"color","restriction":"String"}],"return_type":"Color","visibility":"Public","body":"if ((!(color.starts_with?(\"#\"))) || (!({2, 3, 4, 5, 7, 9}.includes?(color.size)))) || (color.match(/^#[^0-9a-f]/i))\n raise(\"Invalid hex color '#{color}': must start with '#' followed by 1, 2, 3, 4, 6, or 9 alphanumeric characters (0-9 or a-f)\")\nend\ncase color.size\nwhen 2\n gray = (color[1].to_i(16)).to_u8\n gray = (gray << 4) + gray\n self.new(gray, gray, gray)\nwhen 3\n gray = (color[1, 2].to_i(16)).to_u8\n self.new(gray, gray, gray)\nwhen 4\n red = (color[1].to_i(16)).to_u8\n green = (color[2].to_i(16)).to_u8\n blue = (color[3].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue)\nwhen 5\n alpha = (color[1].to_i(16)).to_u8\n red = (color[2].to_i(16)).to_u8\n green = (color[3].to_i(16)).to_u8\n blue = (color[4].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue, (alpha << 4) + alpha)\nwhen 7\n red = (color[1, 2].to_i(16)).to_u8\n green = (color[3, 2].to_i(16)).to_u8\n blue = (color[5, 2].to_i(16)).to_u8\n self.new(red, green, blue)\nelse\n alpha = (color[1, 2].to_i(16)).to_u8\n red = (color[3, 2].to_i(16)).to_u8\n green = (color[5, 2].to_i(16)).to_u8\n blue = (color[7, 2].to_i(16)).to_u8\n self.new(red, green, blue, alpha)\nend\n"}},{"html_id":"random:Color-class-method","name":"random","doc":"Generate a random color with full (255) opacity","summary":"

Generate a random color with full (255) opacity

","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L16"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), ChannelType::Alpha.default)\n"}}],"instance_methods":[{"html_id":"==(other:Color):Bool-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"}],"args_string":"(other : Color) : Bool","args_html":"(other : Color) : Bool","location":{"filename":"src/cr-image/color.cr","line_number":93,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L93"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Color"}],"return_type":"Bool","visibility":"Public","body":"(((red == other.red) && (green == other.green)) && (blue == other.blue)) && (alpha == other.alpha)"}},{"html_id":"[](channel_type:ChannelType):UInt8-instance-method","name":"[]","doc":"Receive the UInt8 portion of this color corresponding to `channel_type`","summary":"

Receive the UInt8 portion of this color corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : UInt8","args_html":"(channel_type : ChannelType) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L29"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"UInt8","visibility":"Public","body":"case channel_type\nin ChannelType::Red\n red\nin ChannelType::Green\n green\nin ChannelType::Blue\n blue\nin ChannelType::Alpha\n alpha\nin ChannelType::Gray\n gray\nend"}},{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"alpha","visibility":"Public","body":"@alpha"}},{"html_id":"blue:UInt8-instance-method","name":"blue","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"html_id":"dist(other:Color,*,manhattan:Bool=false):Float64-instance-method","name":"dist","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"args_string":"(other : Color, *, manhattan : Bool = false) : Float64","args_html":"(other : Color, *, manhattan : Bool = false) : Float64","location":{"filename":"src/cr-image/color.cr","line_number":100,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L100"},"def":{"name":"dist","args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"splat_index":1,"return_type":"Float64","visibility":"Public","body":"if manhattan\n ((red.to_f - other.red).abs + (blue.to_i - other.blue).abs) + (green.to_i - other.green).abs\nelse\n Math.sqrt((((red.to_i - other.red) ** 2) + ((green.to_i - other.green) ** 2)) + ((blue.to_i - other.blue) ** 2))\nend"}},{"html_id":"gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):UInt8-instance-method","name":"gray","doc":"Convert this Color to a single UInt8 gray value","summary":"

Convert this Color to a single UInt8 gray value

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L22"},"def":{"name":"gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"UInt8","visibility":"Public","body":"Math.min(255_u8, (((red * red_multiplier) + (blue * blue_multiplier)) + (green * green_multiplier)).to_u8)"}},{"html_id":"green:UInt8-instance-method","name":"green","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"green","visibility":"Public","body":"@green"}},{"html_id":"red:UInt8-instance-method","name":"red","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"Crystal Image/CrImage/ComplexMap","path":"CrImage/ComplexMap.html","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":606,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L606"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"instance_methods":[{"html_id":"ifft:FloatMap-instance-method","name":"ifft","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":609,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L609"},"def":{"name":"ifft","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, (FftUtil.ifft2d(width, raw)).map(&.real))"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":613,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L613"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"self"}},{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":621,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L621"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to FloatMap\"))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":617,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L617"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to IntMap\"))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":607,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L607"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/EdgePolicy","path":"CrImage/EdgePolicy.html","kind":"enum","full_name":"CrImage::EdgePolicy","name":"EdgePolicy","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/edge_policy.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Black","name":"Black","value":"0"},{"id":"Repeat","name":"Repeat","value":"1"},{"id":"None","name":"None","value":"2"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A general enum for determining behavior around edges of `Image` or `Map`s. See also `Operator::Pad`","summary":"

A general enum for determining behavior around edges of Image or Maps.

","instance_methods":[{"html_id":"black?-instance-method","name":"black?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L4"},"def":{"name":"black?","visibility":"Public","body":"self == Black"}},{"html_id":"none?-instance-method","name":"none?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L6"},"def":{"name":"none?","visibility":"Public","body":"self == None"}},{"html_id":"repeat?-instance-method","name":"repeat?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/edge_policy.cr#L5"},"def":{"name":"repeat?","visibility":"Public","body":"self == Repeat"}}]},{"html_id":"Crystal Image/CrImage/ErrorView","path":"CrImage/ErrorView.html","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L61"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of teh underlying `Map` causes an error","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of teh underlying Map causes an error

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = ErrorView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":62,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L62"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n raise(Exception.new(\"Coordinates #{x}, #{y} correspond to #{adjusted_x}, #{adjusted_y} in sliding window sized #{width}x#{height} centered at #{@map_x}, #{@map_y}, which is outside\"))\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/exception.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Exception class for any errors thrown by CrImage","summary":"

Exception class for any errors thrown by CrImage

","constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/cr-image/exception.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L5"},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(error_code:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"args_string":"(error_code : Int32)","args_html":"(error_code : Int32)","location":{"filename":"src/cr-image/exception.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L9"},"def":{"name":"new","args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(error_code)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(handle:LibJPEGTurbo::Handle)-class-method","name":"new","abstract":false,"args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"args_string":"(handle : LibJPEGTurbo::Handle)","args_html":"(handle : LibJPEGTurbo::Handle)","location":{"filename":"src/cr-image/exception.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L13"},"def":{"name":"new","args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"visibility":"Public","body":"_ = allocate\n_.initialize(handle)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"error_code:Int32|Nil-instance-method","name":"error_code","abstract":false,"location":{"filename":"src/cr-image/exception.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"Crystal Image/CrImage/FftUtil","path":"CrImage/FftUtil.html","kind":"class","full_name":"CrImage::FftUtil","name":"FftUtil","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/fft_util.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for Fast Fourier Transforms\n\nAt some point in the future, this may be moved to its own shard.","summary":"

Utility class for Fast Fourier Transforms

","class_methods":[{"html_id":"fft1d(inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L59"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if buf = buffer\nelse\n buf = Array(Complex).new(inp.size) do\n Complex.zero\n end\nend\nFftUtil.fft1d(Array(Complex).new(inp.size) do |i|\n Complex.new(inp.unsafe_fetch(i))\nend, buf)\n"}},{"html_id":"fft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L68"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.fft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"fft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)|Slice(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"fft1d_unsafe","doc":"Calculates Fast Fourier Transform of `ret`. Uses and modifies `ret` in place.\n\nCan optionally pass in `buffer` which must be the same length as `inp`. This method makes no bound checks or error checks.","summary":"

Calculates Fast Fourier Transform of ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L76"},"def":{"name":"fft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = (-Math::PI.i) / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret\n"}},{"html_id":"fft2d(width:Int32,inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L10"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"FftUtil.fft2d(width, inp.map(&.to_c), buffer)"}},{"html_id":"fft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L15"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.fft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"fft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"fft2d_unsafe","doc":"Perform Fast Fourier Transform, using and rewriting `ret` for the output, as a 2 dimensional array with `width`. `buffer` must be an array\nof length at least the longer of `width` or `height` of the input array.","summary":"

Perform Fast Fourier Transform, using and rewriting ret for the output, as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L28"},"def":{"name":"fft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.fft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.fft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}},{"html_id":"ifft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"ifft1d","doc":"Perform Inverse Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`.","summary":"

Perform Inverse Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L165"},"def":{"name":"ifft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.ifft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"ifft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"ifft1d_unsafe","doc":"Perform Inverse Fast Fourier Transform on `ret`. Will use and overwrite the original values in `ret` to do so.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`. This method makes no bound checks or error checks.","summary":"

Perform Inverse Fast Fourier Transform on ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L173"},"def":{"name":"ifft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = Math::PI.i / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret.map!(&./(ret.size))\n"}},{"html_id":"ifft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"ifft2d","doc":"Perform Inverse Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Inverse Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":124,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L124"},"def":{"name":"ifft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.ifft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"ifft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"ifft2d_unsafe","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":135,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/fft_util.cr#L135"},"def":{"name":"ifft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.ifft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.ifft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}}]},{"html_id":"Crystal Image/CrImage/FloatMap","path":"CrImage/FloatMap.html","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":508,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L508"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Float64` types.","summary":"

Implementation of MapImpl for Float64 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":519,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L519"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"self"}},{"html_id":"to_f64:self-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":511,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L511"},"def":{"name":"to_f64","return_type":"self","visibility":"Public","body":"self"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":515,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L515"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":509,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L509"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Format","path":"CrImage/Format.html","kind":"module","full_name":"CrImage::Format","name":"Format","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}, {extension: \".jpeg\", method: \"jpeg\"}, {extension: \".jpg\", method: \"jpeg\"}, {extension: \".png\", method: \"png\"}, {extension: \".webp\", method: \"webp\"}] of Nil"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Provides a convenience method for saving image files to the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage.save(\"image.jpg\")\n```\nSee `Open` for a convenience method to read images from the filesystem","summary":"

Provides a convenience method for saving image files to the filesystem.

","types":[{"html_id":"Crystal Image/CrImage/Format/JPEG","path":"CrImage/Format/JPEG.html","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG","abstract":false,"locations":[{"filename":"src/lib-formats/jpeg.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/jpeg.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to jpeg. Requires `libturbojpeg` to function.\n\n```\nimage = File.open(\"image.jpg\") { |file| CrImage::RGBAImage.from_jpeg(file) }\nFile.open(\"other_image.jpg\") { |file| image.to_jpeg(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\nimage.save(\"other_image.jpg\")\n```","summary":"

Provides methods to read from and write to jpeg.

","instance_methods":[{"html_id":"to_jpeg(io:IO,quality:Int32=100):Nil-instance-method","name":"to_jpeg","doc":"Output the image as JPEG to `io`","summary":"

Output the image as JPEG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, quality : Int32 = 100) : Nil","args_html":"(io : IO, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/jpeg.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/jpeg.cr#L74"},"def":{"name":"to_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"handle = LibJPEGTurbo.init_compress\nimage_data = IO::Memory.new(size * 3)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\nend\nbuffer = Pointer(UInt8).null\ncheck_jpeg(handle, LibJPEGTurbo.compress2(handle, image_data.buffer, @width, 0, @height, LibJPEGTurbo::PixelFormat::RGB, pointerof(buffer), out size, LibJPEGTurbo::Subsampling::S444, quality, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibJPEGTurbo.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Open","path":"CrImage/Format/Open.html","kind":"module","full_name":"CrImage::Format::Open","name":"Open","abstract":false,"locations":[{"filename":"src/cr-image/format/open.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/open.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides a convenience method for opening up image files from the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\n```\nSee `Save` for a convenience method to write to the filesystem.","summary":"

Provides a convenience method for opening up image files from the filesystem.

","instance_methods":[{"html_id":"open(filename:String):self-instance-method","name":"open","doc":"Reads this image from file using the provided filename.","summary":"

Reads this image from file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/open.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/open.cr#L14"},"def":{"name":"open","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"{% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then File.open(filename) { |file| self.from_{{ format[:method].id }}(file) }\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\nend.join(\", \")).id }}\"\n end\n {% end %}"}}]},{"html_id":"Crystal Image/CrImage/Format/PNG","path":"CrImage/Format/PNG.html","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG","abstract":false,"locations":[{"filename":"src/lib-formats/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/png.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PNG. Requires `libspng` to function.\n\n```\nimage = File.open(\"image.png\") { |file| CrImage::RGBAImage.from_png(file) }\nFile.open(\"other_image.png\") { |file| image.to_png(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.png\")\nimage.save(\"other_image.png\")\n```","summary":"

Provides methods to read from and write to PNG.

","instance_methods":[{"html_id":"to_png(io:IO):Nil-instance-method","name":"to_png","doc":"Output the image as PNG to `io`","summary":"

Output the image as PNG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/lib-formats/png.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/png.cr#L72"},"def":{"name":"to_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::Encoder)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_option(ctx, LibSPNG::Option::EncodeToBuffer, true)\nLibSPNG.set_png_buffer(ctx, image_data.buffer, image_data.size)\nihdr = LibSPNG::IHDR.new\nihdr.width = @width\nihdr.height = @height\nihdr.color_type = LibSPNG::ColorType::TrueColorAlpha\nihdr.bit_depth = 8\nLibSPNG.set_ihdr(ctx, pointerof(ihdr))\nerror = LibSPNG.encode_image(ctx, image_data.buffer, image_data.size, LibSPNG::Format::PNG, LibSPNG::EncodeFlags::Finalize)\ncheck_png(error)\nbuffer = LibSPNG.get_png_buffer(ctx, out size, pointerof(error))\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to get a buffer\"))\nend\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibC.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/PPM","path":"CrImage/Format/PPM.html","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM","abstract":false,"locations":[{"filename":"src/cr-image/format/ppm.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/ppm.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PPM.\n\n```\nimage = File.open(\"image.ppm\") { |file| CrImage::RGBAImage.from_ppm(file) }\nFile.open(\"other_image.ppm\") { |file| image.to_ppm(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.ppm\")\nimage.save(\"other_image.ppm\")\n```","summary":"

Provides methods to read from and write to PPM.

","instance_methods":[{"html_id":"to_ppm(io:IO):Nil-instance-method","name":"to_ppm","doc":"Output this image to `io` using PPM image encoding","summary":"

Output this image to io using PPM image encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/cr-image/format/ppm.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/ppm.cr#L56"},"def":{"name":"to_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"io << \"P6\\n\"\n(((io << @width) << \" \") << @height) << \"\\n\"\nio << \"255\\n\"\nsize.times do |index|\n io.write_byte(red.unsafe_fetch(index))\n io.write_byte(green.unsafe_fetch(index))\n io.write_byte(blue.unsafe_fetch(index))\nend\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Save","path":"CrImage/Format/Save.html","kind":"module","full_name":"CrImage::Format::Save","name":"Save","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"instance_methods":[{"html_id":"save(filename:String):self-instance-method","name":"save","doc":"Write this image to file using the provided filename.\n\nThis method _will not_ create intermediate directory paths. This method will throw an\nerror if they don't exist.","summary":"

Write this image to file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/save.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/format/save.cr#L20"},"def":{"name":"save","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"File.open(filename, \"w\") do |file|\n {% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then to_{{ format[:method].id }}(file)\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\n end.join(\", \")).id }}\"\n end\n {% end %}\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Format/WebP","path":"CrImage/Format/WebP.html","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP","abstract":false,"locations":[{"filename":"src/lib-formats/webp.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/webp.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to WebP. Requires `libwebp` to function.\n\n```\nimage = File.open(\"image.webp\") { |file| CrImage::RGBAImage.from_webp(file) }\nFile.open(\"other_image.webp\") { |file| image.to_webp(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.webp\")\nimage.save(\"other_image.webp\")\n```","summary":"

Provides methods to read from and write to WebP.

","instance_methods":[{"html_id":"to_webp(io:IO,*,lossy:Bool=false,quality:Int32=100):Nil-instance-method","name":"to_webp","doc":"Write image to `io` using WebP encoding","summary":"

Write image to io using WebP encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","args_html":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/webp.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/lib-formats/webp.cr#L59"},"def":{"name":"to_webp","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"splat_index":1,"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nsize, buffer = lossy ? lossy_encode(image_data, quality) : lossless_encode(image_data)\ncheck_webp(size)\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibWebP.free(buffer)\n"}}]}]},{"html_id":"Crystal Image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L13"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L42"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L38"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image in Grayscale. These image types are the easiest to perform feature and information extraction from, where\nthere is only one channel to examine, and so has methods for constructing `Mask`s from (see `#threshold` below).\n\nAn `RGBAImage` would become a `GrayscaleImage` this way:\n```\nimage.to_gray\n```\n\n\"Woman\n\"Woman","summary":"

An image in Grayscale.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage from a set of color channels (delegates to `RGBAImage#to_gray`)","summary":"

Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray)

","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L20"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"(RGBAImage.new(red, green, blue, alpha, width, height)).to_gray"}},{"html_id":"new(gray:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L24"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32)","args_html":"(gray : Array(UInt8), width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L38"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"<(*args,**options)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.<(*args, **options)"}},{"html_id":"<(*args,**options,&)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.<(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"<=(arg)-instance-method","name":"<=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! <= arg"}},{"html_id":"==(arg)-instance-method","name":"==","doc":"Returns `false` (other can only be a `Value` here).","summary":"

Returns false (other can only be a Value here).

","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"==","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! == arg"}},{"html_id":">(*args,**options)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.>(*args, **options)"}},{"html_id":">(*args,**options,&)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.>(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":">=(arg)-instance-method","name":">=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! >= arg"}},{"html_id":"[](x:Int32,y:Int32):Pixel-instance-method","name":"[]","doc":"Return a `Pixel` representing this cell in the image.","summary":"

Return a Pixel representing this cell in the image.

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Pixel","args_html":"(x : Int32, y : Int32) : Pixel","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Pixel","visibility":"Public","body":"index = (y * width) + x\nPixel.new(gray[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the `Array(UInt8)` corresponding to `channel_type`","summary":"

Return the Array(UInt8) corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L97"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"if channel_type == ChannelType::Alpha\n return @alpha\nend\n@gray\n"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the underlying `Array(UInt8)` of `channel_type` to the new `channel`.\n\nWarning: this method does not check the size of the incoming array, and if it's a different\nsize from what the current image represents, this could break it. We recommend against using\nthis method except for from other methods that will be updating the `width` and `height` immediately after.","summary":"

Set the underlying Array(UInt8) of channel_type to the new channel.

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L107"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Gray\n self.gray = channel\nwhen ChannelType::Alpha\n self.alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for GrayscaleImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return `alpha` channel","summary":"

Return #alpha channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":69,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L69"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L15"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the \"`blue`\" channel (returns `gray`)","summary":"

Return the "#blue" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L64"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"clone:GrayscaleImage-instance-method","name":"clone","doc":"Create a new GrayscaleImage as a copy of this one","summary":"

Create a new GrayscaleImage as a copy of this one

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L44"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone, @width, @height)"}},{"html_id":"cross_correlate(map:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":221,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L221"},"def":{"name":"cross_correlate","args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"to_imap.cross_correlate(map, edge_policy: edge_policy)"}},{"html_id":"cross_correlate(*args,**options)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options)"}},{"html_id":"cross_correlate(*args,**options,&)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"cross_correlate_fft(map:Map)-instance-method","name":"cross_correlate_fft","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"}],"args_string":"(map : Map)","args_html":"(map : Map)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":225,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L225"},"def":{"name":"cross_correlate_fft","args":[{"name":"map","external_name":"map","restriction":"Map"}],"visibility":"Public","body":"to_imap.cross_correlate_fft(map)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L80"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L74"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nnil\n"}},{"html_id":"gray:Array(UInt8)-instance-method","name":"gray","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"gray=(gray:Array(UInt8))-instance-method","name":"gray=","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"args_string":"(gray : Array(UInt8))","args_html":"(gray : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray=","args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@gray = gray"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the \"`green`\" channel (returns `gray`)","summary":"

Return the "#green" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L59"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"invert-instance-method","name":"invert","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`).\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":171,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L171"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`). Modifies self.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L182"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(*args,**options)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mask_from(*args, **options)"}},{"html_id":"mask_from(*args,**options,&)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mask_from(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"mean(*args,**options)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mean(*args, **options)"}},{"html_id":"mean(*args,**options,&)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mean(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the \"`red`\" channel (returns `gray`)","summary":"

Return the "#red" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L54"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels this image contains","summary":"

Return the number of pixels this image contains

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":160,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"threshold(threshold:Int):Mask-instance-method","name":"threshold","doc":"Construct a simple threshold `Mask` containing all pixels with a `UInt8` value greater than `threshold`\nGiven sample image:\n\n\"Woman\n\n```\nimage\n .to_gray # convert color image to grayscale one\n .threshold(128) # generate a mask using threshold operator\n .to_gray # convert mask to grayscale image\n .save(\"threshold_example.jpg\") # save mask as grayscale\n```\n\"Black","summary":"

Construct a simple threshold Mask containing all pixels with a UInt8 value greater than #threshold Given sample image:

","abstract":false,"args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"args_string":"(threshold : Int) : Mask","args_html":"(threshold : Int) : Mask","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":200,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L200"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"self >= threshold"}},{"html_id":"to_a:Array(UInt8)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `Array(UInt8)` corresponding to the `ChannelType::Gray` channel","summary":"

Receive a copy of the underlying Array(UInt8) corresponding to the ChannelType::Gray channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":217,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L217"},"def":{"name":"to_a","return_type":"Array(UInt8)","visibility":"Public","body":"gray.dup"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":155,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L155"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"html_id":"to_imap:IntMap-instance-method","name":"to_imap","doc":"Convert this image into a `IntMap`","summary":"

Convert this image into a IntMap

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":207,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L207"},"def":{"name":"to_imap","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, gray.map(&.to_i))"}},{"html_id":"to_map!:UInt8Map-instance-method","name":"to_map!","doc":"Convert this image into a `UInt8Map`. Does not clone underlying `gray` channel, both this image and map share the same data.","summary":"

Convert this image into a UInt8Map.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":212,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L212"},"def":{"name":"to_map!","return_type":"UInt8Map","visibility":"Public","body":"UInt8Map.new(width, @gray)"}},{"html_id":"to_pluto:Pluto::ImageGA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L43"},"def":{"name":"to_pluto","return_type":"Pluto::ImageGA","visibility":"Public","body":"Pluto::ImageGA.new(gray.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba(color_map:Hash(UInt8,Color),*,default:Color=Color.default):RGBAImage-instance-method","name":"to_rgba","doc":"Convert this grayscale image to an RGBA one using the provided color map.\n\nThe provided map should have a key for all 0-255 possible gray pixel values, otherwise the `default`\n`Color` will be used instead (default is black).\n\n```\ncolors = 256.times.to_a.map { |i| {i.to_u8, CrImage::Color.random} }.to_h\ngray_image.to_rgba(colors).save(\"to_rgba_color_map_sample.jpg\")\n```\n\n\"Woman\n\nBecomes\n\n\"Random","summary":"

Convert this grayscale image to an RGBA one using the provided color map.

","abstract":false,"args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"args_string":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","args_html":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L137"},"def":{"name":"to_rgba","args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"splat_index":1,"return_type":"RGBAImage","visibility":"Public","body":"red = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\ngray.each do |pixel|\n color = color_map[pixel]? || default\n red << color.red\n green << color.green\n blue << color.blue\n alpha << color.alpha\nend\nRGBAImage.new(red, green, blue, alpha, width, height)\n"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Convert this `GrayscaleImage` to an `RGBAImage`.\n\nNo color will be provided, all pixels will remain gray.","summary":"

Convert this GrayscaleImage to an RGBAImage.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":118,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L118"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L39"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}],"types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage/Pixel","path":"CrImage/GrayscaleImage/Pixel.html","kind":"struct","full_name":"CrImage::GrayscaleImage::Pixel","name":"Pixel","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},"constructors":[{"html_id":"new(gray:UInt8,alpha:UInt8)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"args_string":"(gray : UInt8, alpha : UInt8)","args_html":"(gray : UInt8, alpha : UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"def":{"name":"alpha","return_type":"UInt8","visibility":"Public","body":"@alpha"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone)"}},{"html_id":"copy_with(gray_gray=@gray,alpha_alpha=@alpha)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"args_string":"(gray _gray = @gray, alpha _alpha = @alpha)","args_html":"(gray _gray = @gray, alpha _alpha = @alpha)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"copy_with","args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"visibility":"Public","body":"self.class.new(_gray, _alpha)"}},{"html_id":"gray:UInt8-instance-method","name":"gray","abstract":false,"def":{"name":"gray","return_type":"UInt8","visibility":"Public","body":"@gray"}}]}]},{"html_id":"Crystal Image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Common base class for `GrayscaleImage` and `RGBAImage`. All `Image`s are readable and saveable\nto the filesystem or `IO` stream.","summary":"

Common base class for GrayscaleImage and RGBAImage.

","instance_methods":[{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Get the `Array(UInt8)` corresponding to `channel_type`)","summary":"

Get the Array(UInt8) corresponding to channel_type)

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L56"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the `Array(UInt8)` corresponding to `channel_type`) to `channel`","summary":"

Set the Array(UInt8) corresponding to channel_type) to channel

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L58"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L41"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L39"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L53"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":50,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L50"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L37"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L45"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L35"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size (total pixels) in image (`width` * `height`)","summary":"

Size (total pixels) in image (#width * #height)

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L47"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L43"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}],"macros":[{"html_id":"subsclasses_include(mod)-macro","name":"subsclasses_include","abstract":false,"args":[{"name":"mod","external_name":"mod","restriction":""}],"args_string":"(mod)","args_html":"(mod)","location":{"filename":"src/cr-image/image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/image.cr#L4"},"def":{"name":"subsclasses_include","args":[{"name":"mod","external_name":"mod","restriction":""}],"visibility":"Public","body":" \n{% for sub in @type.subclasses %}\n class ::{{ sub }}\n include {{ mod }}\n end\n {% end %}\n\n \n"}}]},{"html_id":"Crystal Image/CrImage/IntMap","path":"CrImage/IntMap.html","kind":"class","full_name":"CrImage::IntMap","name":"IntMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L478"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Int32` types.","summary":"

Implementation of MapImpl for Int32 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":485,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L485"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"to_f64"}},{"html_id":"to_f64:FloatMap-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":481,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L481"},"def":{"name":"to_f64","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f64))"}},{"html_id":"to_i:self-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":489,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L489"},"def":{"name":"to_i","return_type":"self","visibility":"Public","body":"self"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":479,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L479"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Map","path":"CrImage/Map.html","kind":"module","full_name":"CrImage::Map(T)","name":"Map","abstract":false,"locations":[{"filename":"src/cr-image/map.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/Mask","kind":"class","full_name":"CrImage::Mask","name":"Mask"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/OneMap","kind":"class","full_name":"CrImage::OneMap","name":"OneMap"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An interface for 2 dimensional data. Used for various masking and correlation methods.","summary":"

An interface for 2 dimensional data.

","instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L9"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L8"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L11"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L10"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L5"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L7"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L6"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L4"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/MapImpl","path":"CrImage/MapImpl.html","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L45"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"}],"including_types":[{"html_id":"Crystal Image/CrImage/ComplexMap","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap"},{"html_id":"Crystal Image/CrImage/FloatMap","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap"},{"html_id":"Crystal Image/CrImage/IntMap","kind":"class","full_name":"CrImage::IntMap","name":"IntMap"},{"html_id":"Crystal Image/CrImage/UInt8Map","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A collection of implementations of `NumericMap(T)`, intended to be included in base classes.\n\nSee `IntMap`, `FloatMap`, and `ComplexMap`.","summary":"

A collection of implementations of NumericMap(T), intended to be included in base classes.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:T)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"args_string":"(width : Int32, height : Int32, initial : T)","args_html":"(width : Int32, height : Int32, initial : T)","location":{"filename":"src/cr-image/map.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L82"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,raw:Array(T))-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"args_string":"(width : Int32, raw : Array(T))","args_html":"(width : Int32, raw : Array(T))","location":{"filename":"src/cr-image/map.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L63"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other:Array(Array(T)))-class-method","name":"new","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"args_string":"(other : Array(Array(T)))","args_html":"(other : Array(Array(T)))","location":{"filename":"src/cr-image/map.cr","line_number":67,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L67"},"def":{"name":"new","args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &)","args_html":"(width : Int32, height : Int32, &)","location":{"filename":"src/cr-image/map.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L76"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":1,"block_arity":1,"visibility":"Public","body":"_ = allocate\n_.initialize(width, height) do |_arg0|\n yield _arg0\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"*(num:Int|Float):self-instance-method","name":"*","doc":"Multiply each point in this `Map` by `num`","summary":"

Multiply each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":284,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L284"},"def":{"name":"*","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i * num\nend)"}},{"html_id":"+(num:Int|Float):self-instance-method","name":"+","doc":"Add each point in this `Map` by `num`","summary":"

Add each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":289,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L289"},"def":{"name":"+","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i + num\nend)"}},{"html_id":"+(other:self):self-instance-method","name":"+","doc":"Add each point of this `Map` with each point in `other`","summary":"

Add each point of this Map with each point in other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : self","args_html":"(other : self) : self","location":{"filename":"src/cr-image/map.cr","line_number":304,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L304"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Dimensions should match (caller: #{width}x#{height}, callee: #{other.width}x#{other.height})\"))\nend\nself.class.new(width, @raw.map_with_index do |val, i|\n val + other[i]\nend)\n"}},{"html_id":"-(other:NumericMap(T)):self-instance-method","name":"-","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : self","args_html":"(other : NumericMap(T)) : self","location":{"filename":"src/cr-image/map.cr","line_number":196,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L196"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Unable to subtract a map of different dimensions: #{width}x#{height} vs #{other.width}x#{other.height}\"))\nend\nself.class.new(width, raw.map_with_index do |v, i|\n v - other.raw[i]\nend)\n"}},{"html_id":"-(num:Int):self-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int"}],"args_string":"(num : Int) : self","args_html":"(num : Int) : self","location":{"filename":"src/cr-image/map.cr","line_number":294,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L294"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Int"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"-(num:Float):FloatMap-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Float"}],"args_string":"(num : Float) : FloatMap","args_html":"(num : Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":299,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L299"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"/(num:Int|Float):FloatMap-instance-method","name":"/","doc":"Divides each point in this `Map` by `num`\n\nTODO: ComplexMap shouldn't return a FloatMap","summary":"

Divides each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : FloatMap","args_html":"(num : Int | Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":279,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L279"},"def":{"name":"/","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i / num\nend)"}},{"html_id":"<(num:Int|Float):Mask-instance-method","name":"<","doc":"Construct a `Mask` identifying all pixels smaller than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray < 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels smaller than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":257,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L257"},"def":{"name":"<","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val < num\nend"}},{"html_id":"<=(num:Int|Float):Mask-instance-method","name":"<=","doc":"Construct a `Mask` identifying all pixels smaller than or equal to `num`. See `#<` for example.","summary":"

Construct a Mask identifying all pixels smaller than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":262,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L262"},"def":{"name":"<=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val <= num\nend"}},{"html_id":"==(num:Int|Float):Mask-instance-method","name":"==","doc":"Construct a `Mask` identifying all pixels equal to `num`","summary":"

Construct a Mask identifying all pixels equal to num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":267,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L267"},"def":{"name":"==","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val == num\nend"}},{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Check if this `Map` is equal to `other`","summary":"

Check if this Map is equal to other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/cr-image/map.cr","line_number":272,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L272"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"(other.width == width) && (@raw == other.raw)"}},{"html_id":">(num:Int|Float):Mask-instance-method","name":">","doc":"Construct a `Mask` identifying all pixels larger than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray > 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels larger than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":238,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L238"},"def":{"name":">","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val > num\nend"}},{"html_id":">=(num:Int|Float):Mask-instance-method","name":">=","doc":"Construct a `Mask` identify all pixels larger than or equal to `num`. See `#>` for near example.","summary":"

Construct a Mask identify all pixels larger than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":243,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L243"},"def":{"name":">=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val >= num\nend"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):self-instance-method","name":"[]","doc":"Crop the map to the values contained from `xstart` out by `xcount`, and `ystart` out by `ycount`","summary":"

Crop the map to the values contained from xstart out by xcount, and ystart out by ycount

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":152,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L152"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, xcount, ystart, ycount)"}},{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","doc":"Get element at coordinates `x` and `y`","summary":"

Get element at coordinates x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":106,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L106"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"if x >= width || x < 0\n raise(Exception.new(\"X coordinate #{x} is outside of Map width #{width}\"))\nend\nif y >= height || y < 0\n raise(Exception.new(\"Y coordinate #{y} is outside of Map height #{height}\"))\nend\nindex = (y * width) + x\nself[index]\n"}},{"html_id":"[](xrange:Range,ystart:Int32):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in row at `ystart`","summary":"

Crop the map, returning only the values in row at ystart

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : self","args_html":"(xrange : Range, ystart : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L137"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), ystart, 1)"}},{"html_id":"[](xstart:Int32,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in column at `xstart`","summary":"

Crop the map, returning only the values in column at xstart

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : self","args_html":"(xstart : Int32, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":142,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L142"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, 1, *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map to the values contained in `xrange` and `yrange`","summary":"

Crop the map to the values contained in xrange and yrange

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":147,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L147"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","doc":"Get element at `index` from underlying `raw` Array.","summary":"

Get element at index from underlying #raw Array.

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":101,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L101"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"@raw[index]"}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","doc":"Get lement at coordinates `x` and `y`, or `nil` if coordinates are out of bounds","summary":"

Get lement at coordinates x and y, or nil if coordinates are out of bounds

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":119,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L119"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"if x < 0 || x >= width\n return nil\nend\nif y < 0 || y >= height\n return nil\nend\nindex = (y * width) + x\n@raw[index]?\n"}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","doc":"Get element at `index`, or `nil` if out of bounds","summary":"

Get element at index, or nil if out of bounds

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":114,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L114"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"@raw[index]?"}},{"html_id":"column(x:Int32):self-instance-method","name":"column","doc":"Get a single dimensional `Map` representing teh column at `x`","summary":"

Get a single dimensional Map representing teh column at x

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"}],"args_string":"(x : Int32) : self","args_html":"(x : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":132,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L132"},"def":{"name":"column","args":[{"name":"x","external_name":"x","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(x, 1, 0, height)"}},{"html_id":"cross_correlate(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","doc":"Perform a brute force cross correlation calculation with provided `template`.","summary":"

Perform a brute force cross correlation calculation with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":393,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L393"},"def":{"name":"cross_correlate","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"half_width = template.width >> 1\nhalf_height = template.height >> 1\nstart_x, start_y = (edge_policy.none? ? {half_width, half_height} : {0, 0})\nend_x, end_y = (edge_policy.none? ? {(width - half_width) - 1, (height - half_height) - 1} : {width - 1, height - 1})\nret = Array(Float64).new((end_x - start_x) * (end_y - start_y))\n(start_y.upto(end_y)).each do |y|\n (start_x.upto(end_x)).each do |x|\n view = case edge_policy\n in EdgePolicy::Repeat\n RepeatView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::Black\n BlackView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::None\n ErrorView(T).new(template.width, template.height, self, x, y)\n end\n ret << view.sum do |pixel, vx, vy|\n template[vx, vy] * pixel\n end\n end\nend\nretf = FloatMap.new((end_x - start_x) + 1, ret)\nretf\n"}},{"html_id":"cross_correlate_fft(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Black):FloatMap-instance-method","name":"cross_correlate_fft","doc":"Perform a Fast Fourier Transform cross correlation (convolution?) with provided `template`. See `FftUtil`","summary":"

Perform a Fast Fourier Transform cross correlation (convolution?) with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":421,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L421"},"def":{"name":"cross_correlate_fft","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"max_width, max_height = Math.pw2ceil(width + template.width), Math.pw2ceil(height + template.height)\npad_type = edge_policy.none? ? EdgePolicy::Black : edge_policy\nwidth_range, height_range = case edge_policy\nin EdgePolicy::Black, EdgePolicy::Repeat\n {(template.width)...(width + template.width), (template.height)...(height + template.height)}\nin EdgePolicy::None\n {(template.width + (template.width // 2))..(((template.width + width) - template.width) + 1), (template.height + (template.height // 2))..(((template.height + height) - template.height) + 1)}\nend\norig_pad_fft = pad(top: (template.height // 2) + (template.height % 2), bottom: (max_height - height) - ((template.height // 2) + (template.height % 2)), right: (max_width - width) - ((template.width // 2) + (template.width % 2)), left: (template.width // 2) + (template.width % 2), pad_type: pad_type).to_c\nmap_pad_fft = template.pad(bottom: max_height - template.height, right: max_width - template.width).to_c\nbuffer = Array(Complex).new(Math.max(max_width, max_height)) do\n Complex.zero\nend\nFftUtil.fft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nFftUtil.fft2d_unsafe(max_width, map_pad_fft.raw, buffer)\norig_pad_fft.raw.map_with_index! do |o, i|\n o * map_pad_fft[i]\nend\nFftUtil.ifft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nret = (FloatMap.new(max_width, orig_pad_fft.raw.map(&.real)))[width_range, height_range]\nret\n"}},{"html_id":"fft:ComplexMap-instance-method","name":"fft","doc":"Performe a Fast Fourier Transform, padding out this `Map` so dimensions are a power of 2. See `FftUtil`","summary":"

Performe a Fast Fourier Transform, padding out this Map so dimensions are a power of 2.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":461,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L461"},"def":{"name":"fft","return_type":"ComplexMap","visibility":"Public","body":"map = pad(bottom: (Math.pw2ceil(height)) - height, right: (Math.pw2ceil(width)) - width).to_c\nbuffer = Array(Complex).new(Math.max(map.height, map.width)) do\n Complex.zero\nend\nComplexMap.new(map.width, FftUtil.fft2d_unsafe(map.width, map.raw, buffer))\n"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L86"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@raw.size // @width"}},{"html_id":"mask_from(&block:T,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","doc":"Construct a `Mask` from this `GrayscaleImage` using the passed in block to determine if a given pixel should be true or not\n\n```\n# Construct a mask identifying the bright pixels in the bottom left corner of image\nimage.to_gray.mask_from do |pixel, x, y|\n x < image.width // 2 && # left half of image\n y > (image.height // 2) && # bottom half of image\n pixel > 128 # only \"bright\" pixels\nend\n```\n\"Woman\n->\n\"Mask","summary":"

Construct a Mask from this GrayscaleImage using the passed in block to determine if a given pixel should be true or not

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":214,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L214"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(T, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(@raw[i], x, y)\nend)\n"}},{"html_id":"max:T-instance-method","name":"max","doc":"Return the maximum value in this `Map`","summary":"

Return the maximum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":187,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L187"},"def":{"name":"max","return_type":"T","visibility":"Public","body":"@raw.max"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Return the average of the elements in this `Map`","summary":"

Return the average of the elements in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":177,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L177"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@raw.sum / size"}},{"html_id":"min:T-instance-method","name":"min","doc":"Return the minimum value in this `Map`","summary":"

Return the minimum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L182"},"def":{"name":"min","return_type":"T","visibility":"Public","body":"@raw.min"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):self-instance-method","name":"pad","doc":"Pad the borders of this `Map` corresponding to `pad_type`.","summary":"

Pad the borders of this Map corresponding to pad_type.

","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","location":{"filename":"src/cr-image/map.cr","line_number":336,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L336"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"top = top > 0 ? top : all\nbottom = bottom > 0 ? bottom : all\nleft = left > 0 ? left : all\nright = right > 0 ? right : all\nnew_width = (left + width) + right\nnew_raw = initial_raw_pad(pad_type, new_width, top, bottom, left, right, pad_black_value)\nheight.times do |y|\n adjusted_y = y + top\n ((new_raw.to_unsafe + (adjusted_y * new_width)) + left).copy_from(raw.to_unsafe + (y * width), width)\nend\nif pad_type.repeat?\n if top > 0\n copy = new_raw[new_width * top, new_width]\n top.times do |i|\n new_raw[i * new_width, new_width] = copy\n end\n end\n if bottom > 0\n copy = new_raw[new_width * ((top + height) - 1), new_width]\n bottom.times do |i|\n new_raw[((i + top) + height) * new_width, new_width] = copy\n end\n end\nend\nself.class.new(new_width, new_raw)\n"}},{"html_id":"raw:Array(T)-instance-method","name":"raw","doc":"Return the raw array underlying the map","summary":"

Return the raw array underlying the map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L61"},"def":{"name":"raw","return_type":"Array(T)","visibility":"Public","body":"@raw"}},{"html_id":"row(y:Int32):self-instance-method","name":"row","doc":"Get a single dimensional `Map` representing the row at `y`","summary":"

Get a single dimensional Map representing the row at y

","abstract":false,"args":[{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(y : Int32) : self","args_html":"(y : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":127,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L127"},"def":{"name":"row","args":[{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(0, width, y, 1)"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Return the shape of the map - `{width, height}`","summary":"

Return the shape of the map - {width, height}

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L91"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size of the map - `width * height`","summary":"

Size of the map - width * height

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":96,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L96"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@raw.size"}},{"html_id":"sum:T-instance-method","name":"sum","doc":"Return the sum of all values in this `Map`","summary":"

Return the sum of all values in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":192,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L192"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":"@raw.sum"}},{"html_id":"to_a:Array(T)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `raw` array.","summary":"

Receive a copy of the underlying #raw array.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":326,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L326"},"def":{"name":"to_a","return_type":"Array(T)","visibility":"Public","body":"@raw.dup"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":331,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L331"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, raw.map(&.to_c))"}},{"html_id":"to_gray(*,scale:Bool=false):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Map` to a `GrayscaleImage`.\n\nSet `scale: true` so that all of the values will scale, such that `max` will become `255u8`, and `min` will become `0u8`. All other values will be\nlinearly scaled between those values.","summary":"

Convert this Map to a GrayscaleImage.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"args_string":"(*, scale : Bool = false) : GrayscaleImage","args_html":"(*, scale : Bool = false) : GrayscaleImage","location":{"filename":"src/cr-image/map.cr","line_number":313,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L313"},"def":{"name":"to_gray","args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"splat_index":0,"return_type":"GrayscaleImage","visibility":"Public","body":"if scale\n max_val = max\n min_val = min\n multiplier = 255 / (max_val - min_val)\n GrayscaleImage.new(@raw.map do |v|\n (((v - min_val) * multiplier).clamp(0, 255)).to_u8\n end, width)\nelse\n GrayscaleImage.new(@raw.map(&.to_u8), width)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L58"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/mask.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L39"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel\nfrom an image. This can include whether a particular pixel has a value within certain conditions, OR\nif that pixel should be zeroed out or not.\n\nSee `[]=` methods below for examples of how to manually construct masks.\n\n(x,y) - coordinates. Represent these positions in a Mask of size 10x10:\n\n```\n[\n (0,0), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7), (0,8), (0,9),\n (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9),\n (2,0), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,7), (2,8), (2,9),\n (3,0), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (3,7), (3,8), (3,9),\n (4,0), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (4,7), (4,8), (4,9),\n (5,0), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (5,7), (5,8), (5,9),\n (6,0), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6), (6,7), (6,8), (6,9),\n (7,0), (7,1), (7,2), (7,3), (7,4), (7,5), (7,6), (7,7), (7,8), (7,9),\n (8,0), (8,1), (8,2), (8,3), (8,4), (8,5), (8,6), (8,7), (8,8), (8,9),\n (9,0), (9,1), (9,2), (9,3), (9,4), (9,5), (9,6), (9,7), (9,8), (9,9),\n]\n```\n\nAnd every position is a Bool value.\n\nDifferent ways to refer to coordinates:\n```\nmask.at(0, 0) # => (0,0)\nmask[0, 0] # => (0,0), same as .at(0, 0)\nmask[0..1, 4] # => (4,0), (4,1)\nmask[3, 3..5] # => (3,3), (3,4), (3,5)\nmask[2..3, 4..5] # => (2,4), (2,5), (3,4), (3,5)\n```\n\nSee `Operation::Crop` and `Operation::MaskApply` for how this can be useful","summary":"

Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel from an image.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` of width x height, preset to `initial`","summary":"

Construct a new Mask of width x height, preset to initial

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(width : Int32, height : Int32, initial : Bool = true)","args_html":"(width : Int32, height : Int32, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L54"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,int:Int)-class-method","name":"new","doc":"Construct a new `Mask` from an integer (useful for testing or small mask construction)","summary":"

Construct a new Mask from an integer (useful for testing or small mask construction)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"args_string":"(width : Int32, height : Int32, int : Int)","args_html":"(width : Int32, height : Int32, int : Int)","location":{"filename":"src/cr-image/mask.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L66"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, int)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(image:Image,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` from the dimensions of passed in `image` with an initial bit","summary":"

Construct a new Mask from the dimensions of passed in image with an initial bit

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(image : Image, initial : Bool = true)","args_html":"(image : Image, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L72"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,bits:BitArray)-class-method","name":"new","doc":"Construct a new `Mask` with a set width and bits from `bits`","summary":"

Construct a new Mask with a set width and bits from #bits

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"args_string":"(width : Int32, bits : BitArray)","args_html":"(width : Int32, bits : BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L49"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&block:Int32,Int32->Bool)-class-method","name":"new","doc":"Construct a new `Mask` of width x height using `&block` to determine if a bit should be true or not (passed in `x` and `y` coordinates)","summary":"

Construct a new Mask of width x height using &block to determine if a bit should be true or not (passed in x and y coordinates)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","args_html":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","location":{"filename":"src/cr-image/mask.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L59"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":2,"block_arity":2,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32 -> Bool)"},"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, &block) do |_arg0, _arg1|\n yield _arg0, _arg1\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other_bits:Array(BitArray))-class-method","name":"new","doc":"Construct a new `Mask` from an array of `BitArray`. See `#[](xs : Range, ys : Range) : Array(BitArray)`\n\nThis assumes `other_bits[0]` corresponds to `x == 0` in the mask, and the corresponding\n`BitArray` represents all bits for that row. All `BitArray`s must be of the same size in\n`other_bits`.","summary":"

Construct a new Mask from an array of BitArray.

","abstract":false,"args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"args_string":"(other_bits : Array(BitArray))","args_html":"(other_bits : Array(BitArray))","location":{"filename":"src/cr-image/mask.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L82"},"def":{"name":"new","args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other_bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:Mask)-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask)","args_html":"(other : Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":188,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L188"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":180,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L180"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"Array(BitArray)","visibility":"Public","body":"ycount.times.to_a.map do |y|\n BitArray.new(xcount) do |x|\n self[x + xstart, y + ystart]\n end\nend"}},{"html_id":"[](x:Int32,y:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `x` and `y`","summary":"

Return the bit at x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool","args_html":"(x : Int32, y : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":153,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L153"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\n@bits[(y * width) + x]\n"}},{"html_id":"[](xs:Range,y:Int32):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial row specified","summary":"

Return a new BitArray corresponding to the partial row specified

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(xs : Range, y : Int32) : BitArray","args_html":"(xs : Range, y : Int32) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":159,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L159"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(xs, width)\nBitArray.new(count) do |x|\n self[x + start, y]\nend\n"}},{"html_id":"[](x:Int32,ys:Range):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial column specified","summary":"

Return a new BitArray corresponding to the partial column specified

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(x : Int32, ys : Range) : BitArray","args_html":"(x : Int32, ys : Range) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L165"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(ys, height)\nBitArray.new(count) do |y|\n self[x, y + start]\nend\n"}},{"html_id":"[](xs:Range,ys:Range):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(xs : Range, ys : Range) : Array(BitArray)","args_html":"(xs : Range, ys : Range) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L173"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xs, width)\nystart, ycount = resolve_to_start_and_count(ys, height)\nself[xstart, xcount, ystart, ycount]\n"}},{"html_id":"[](index:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":140,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L140"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"@bits[index]"}},{"html_id":"[]=(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bit for coordinate `x` and `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20, 20] = true\nmask.to_gray.save(\"mask_point.jpg\")\n```\n\"Black","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":208,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L208"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"self.set(x, y, value)"}},{"html_id":"[]=(xs:Range,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial row `xs` at column `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_row.jpg\")\n```\n\"Black","summary":"

Set the bits for partial row xs at column y

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, y : Int32, value : Bool) : Bool","args_html":"(xs : Range, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":220,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L220"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if y >= height\n raise(IndexError.new(\"Out of bounds: #{y} is beyond the bounds of this mask's height of #{height}\"))\nend\nstart_x, count_x = resolve_to_start_and_count(xs, width)\n@bits.fill(value, (y * width) + start_x, count_x)\nclear_caches\nvalue\n"}},{"html_id":"[]=(x:Int32,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for row `x` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for row x and partial columns ys

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, ys : Range, value : Bool) : Bool","args_html":"(x : Int32, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":236,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L236"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width\n raise(IndexError.new(\"Out of bounds: #{x} is beyond the bounds of this mask's width of #{width}\"))\nend\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n set(x, y + start_y, value)\nend\nvalue\n"}},{"html_id":"[]=(xs:Range,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial rows `xs` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20..40] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for partial rows xs and partial columns ys

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, ys : Range, value : Bool) : Bool","args_html":"(xs : Range, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":253,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L253"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"start_x, count_x = resolve_to_start_and_count(xs, width)\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n @bits.fill(value, ((y + start_y) * width) + start_x, count_x)\nend\nclear_caches\nvalue\n"}},{"html_id":"[]?(x:Int32,y:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool | Nil","args_html":"(x : Int32, y : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":148,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L148"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[(y * width) + x]?"}},{"html_id":"[]?(index:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool | Nil","args_html":"(index : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":144,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L144"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[index]?"}},{"html_id":"|(other:Mask):Mask-instance-method","name":"|","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask) : Mask","args_html":"(other : Mask) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":487,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L487"},"def":{"name":"|","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n bits[i] | other.bits[i]\nend)"}},{"html_id":"apply(image:Image):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":269,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L269"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.apply(self)"}},{"html_id":"apply(image:Image,&block:UInt8,ChannelType,Int32,Int32->UInt8):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","args_html":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":274,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L274"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8)"},"return_type":"Image","visibility":"Public","body":"image.apply(self, &block)"}},{"html_id":"at(index:Int32):Bool-instance-method","name":"at","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L134"},"def":{"name":"at","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if index >= size\n raise(\"Index #{index} exceeds mask size #{@bits.size}\")\nend\n@bits[index]\n"}},{"html_id":"bits:BitArray-instance-method","name":"bits","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L43"},"def":{"name":"bits","return_type":"BitArray","visibility":"Public","body":"@bits"}},{"html_id":"clone-instance-method","name":"clone","doc":"Create a new `Mask` from this one without modifying it","summary":"

Create a new Mask from this one without modifying it

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L107"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"closing(*,diagonal:Bool=true):Mask-instance-method","name":"closing","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L478"},"def":{"name":"closing","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.closing!(diagonal: diagonal)"}},{"html_id":"closing!(*,diagonal:Bool=true):Mask-instance-method","name":"closing!","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":483,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L483"},"def":{"name":"closing!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"dilate!(diagonal: diagonal).erode!(diagonal: diagonal)"}},{"html_id":"dilate(*,diagonal:Bool=true):Mask-instance-method","name":"dilate","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":419,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L419"},"def":{"name":"dilate","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.dilate!(diagonal: diagonal)"}},{"html_id":"dilate!(*,diagonal:Bool=true):self-instance-method","name":"dilate!","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : self","args_html":"(*, diagonal : Bool = true) : self","location":{"filename":"src/cr-image/mask.cr","line_number":424,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L424"},"def":{"name":"dilate!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"self","visibility":"Public","body":"clear_caches\nnew_bits = bits.dup\nx = -1\ny = 0\nbits.size.times do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n if bits[i]\n next\n end\n new_bits[i] = (((((x != 0) && bits[i - 1]) || ((x != (width - 1)) && bits[i + 1])) || ((y != 0) && bits[i - width])) || ((y != (height - 1)) && bits[i + width])) || (diagonal && ((((((x != 0) && (y != 0)) && bits[(i - width) - 1]) || (((x != (width - 1)) && (y != 0)) && bits[(i - width) + 1])) || (((x != 0) && (y != (height - 1))) && bits[(i + width) - 1])) || (((x != (width - 1)) && (y != (height - 1))) && bits[(i + width) + 1])))\nend\n@bits = new_bits\nself\n"}},{"html_id":"erode(*,diagonal:Bool=true):Mask-instance-method","name":"erode","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":458,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L458"},"def":{"name":"erode","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.erode!(diagonal: diagonal)"}},{"html_id":"erode!(*,diagonal:Bool=true):Mask-instance-method","name":"erode!","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":463,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L463"},"def":{"name":"erode!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"invert!.dilate!(diagonal: diagonal).invert!"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L111"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@bits.size // width"}},{"html_id":"invert-instance-method","name":"invert","doc":"Return a new `Mask` that's a copy of this one with all bits inverted.","summary":"

Return a new Mask that's a copy of this one with all bits inverted.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":129,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L129"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert all bits in this instance of `Mask`. Modifies self.\n\n\"Black\n\nBecomes\n\n\"White","summary":"

Invert all bits in this instance of Mask.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":122,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L122"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"html_id":"opening(*,diagonal:Bool=true):Mask-instance-method","name":"opening","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":468,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L468"},"def":{"name":"opening","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.opening!(diagonal: diagonal)"}},{"html_id":"opening!(*,diagonal:Bool=true):Mask-instance-method","name":"opening!","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":473,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L473"},"def":{"name":"opening!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"erode!(diagonal: diagonal).dilate!(diagonal: diagonal)"}},{"html_id":"region:Region-instance-method","name":"region","doc":"Returns the bounding box of the mask where all true bits are contained. Any pixels outside of the region are false\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask[20, 20..40] = true\nmask.region # => Region(x: 20, y: 20, width: 20, height: 20)\n```\n\n\"Black","summary":"

Returns the bounding box of the mask where all true bits are contained.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":296,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L296"},"def":{"name":"region","return_type":"Region","visibility":"Public","body":"@region || (@region = calculate_region)"}},{"html_id":"segments(*,diagonal:Bool=true):Array(Mask)-instance-method","name":"segments","doc":"Return an array of `Mask`s, each one corresponding to an area of contiguous true bits (identified from flood fills).\n\nMay specify `diagonal: false` for only 4-way (up, down, left, right) flood fill instead of default 8-way.\nStarting with sample mask:\n```\nmask = CrImage::Mask.new(50, 50, false)\n\nmask[5..45, 5..45] = true\nmask[15..35, 15..35] = false\nmask[21..25, 21..25] = true\nmask[26..30, 26..30] = true\n```\n\n\"Black\n\nIts segments look like:\n```\nmask.segments.each_with_index do |segment, i|\n segment.to_gray.save(\"mask_8-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\nUsing `diagonal: false` yields:\n```\nmask.segments(diagonal: false).each_with_index do |segment, i|\n segment.to_gray.save(\"mask_4-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\"Black","summary":"

Return an array of Masks, each one corresponding to an area of contiguous true bits (identified from flood fills).

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Array(Mask)","args_html":"(*, diagonal : Bool = true) : Array(Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":360,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L360"},"def":{"name":"segments","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Array(Mask)","visibility":"Public","body":"diagonal ? (@segments_8_way || (@segments_8_way = calculate_segments(diagonal))) : (@segments_4_way || (@segments_4_way = calculate_segments(diagonal)))"}},{"html_id":"set(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"set","doc":"Set the bit for coordinate `x` and `y`","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":194,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L194"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\nclear_caches\n@bits[(y * width) + x] = value\n"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Returns the dimension of this mask (width x height)","summary":"

Returns the dimension of this mask (width x height)

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":102,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L102"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L97"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"bits.size"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Mask` to a `GrayscaleImage`, with false bits becoming 0, and true bits becoming 255","summary":"

Convert this Mask to a GrayscaleImage, with false bits becoming 0, and true bits becoming 255

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":264,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L264"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(bits.map do |b|\n b ? 255_u8 : 0_u8\nend, width, height)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/mask.cr#L42"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/NumericMap","path":"CrImage/NumericMap.html","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"including_types":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Additional methods for `Map` that assume `T` is a numeric type. See `MapImpl`","summary":"

Additional methods for Map that assume T is a numeric type.

","instance_methods":[{"html_id":"+(other:NumericMap(T)):NumericMap(T)-instance-method","name":"+","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L39"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"-(other:NumericMap(T)):NumericMap(T)-instance-method","name":"-","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L38"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"max:T-instance-method","name":"max","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L35"},"def":{"name":"max","return_type":"T","visibility":"Public","body":""}},{"html_id":"min:T-instance-method","name":"min","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L36"},"def":{"name":"min","return_type":"T","visibility":"Public","body":""}},{"html_id":"sum:T-instance-method","name":"sum","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":34,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L34"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":""}},{"html_id":"to_c:NumericMap(Complex)-instance-method","name":"to_c","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L31"},"def":{"name":"to_c","return_type":"NumericMap(Complex)","visibility":"Public","body":""}},{"html_id":"to_f:NumericMap(Float64)-instance-method","name":"to_f","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L32"},"def":{"name":"to_f","return_type":"NumericMap(Float64)","visibility":"Public","body":""}},{"html_id":"to_i:NumericMap(Int32)-instance-method","name":"to_i","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L30"},"def":{"name":"to_i","return_type":"NumericMap(Int32)","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/OneMap","path":"CrImage/OneMap.html","kind":"class","full_name":"CrImage::OneMap","name":"OneMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":525,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L525"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Memory efficient implementation of `MapImpl` when all values are equal to `1`","summary":"

Memory efficient implementation of MapImpl when all values are equal to 1

","constructors":[{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/map.cr","line_number":531,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L531"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":574,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L574"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"OneMap.new(xcount, ycount)"}},{"html_id":"[](x:Int32,y:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":550,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L550"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[](xstart:Int32,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : OneMap","args_html":"(xstart : Int32, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":558,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L558"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, ycount = range_to_index_and_count(yrange)\nOneMap.new(1, ycount)\n"}},{"html_id":"[](xrange:Range,ystart:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : OneMap","args_html":"(xrange : Range, ystart : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":563,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L563"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\nOneMap.new(xcount, 1)\n"}},{"html_id":"[](xrange:Range,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : OneMap","args_html":"(xrange : Range, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":568,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L568"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\n_, ycount = range_to_index_and_count(yrange)\nOneMap.new(xcount, ycount)\n"}},{"html_id":"[](index:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":542,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L542"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(x:Int32,y:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":554,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L554"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(index:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":546,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L546"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":529,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L529"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):OneMap|IntMap-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","location":{"filename":"src/cr-image/map.cr","line_number":582,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L582"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"OneMap | IntMap","visibility":"Public","body":"case pad_type\nin EdgePolicy::Black\n to_i.pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: pad_black_value)\nin EdgePolicy::Repeat\n top = top > 0 ? top : all\n bottom = bottom > 0 ? bottom : all\n left = left > 0 ? left : all\n right = right > 0 ? right : all\n @width = @width + (left + right)\n @height = @height + (top + bottom)\n self\nin EdgePolicy::None\n raise(Exception.new(\"Pad method doesn't support edge policy None\"))\nend"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":534,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L534"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":538,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L538"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"width * height"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":601,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L601"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, Array(Complex).new(size) do\n Complex.new(1)\nend)"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":597,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L597"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, Array(Int32).new(size) do\n 1\nend)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":528,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L528"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Operation","path":"CrImage/Operation.html","kind":"module","full_name":"CrImage::Operation","name":"Operation","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/operation/operation.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/operation.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Module for containing individual operations for `Image` classes.","summary":"

Module for containing individual operations for Image classes.

","types":[{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","path":"CrImage/Operation/BilinearResize.html","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Resize an image using a bilinear resizing algorithm.\n\nTaking sample `image`:\n\n\"Woman\n\n```\nputs image.width, image.height # => 159x199\nimage.bilinear_resize(40, 50).save(\"small_sample.jpg\")\nimage.bilinear_resize(200, 250).save(\"larger_sample.jpg\")\n```\n\"Sample\n\"Sample","summary":"

Resize an image using a bilinear resizing algorithm.

","instance_methods":[{"html_id":"bilinear_resize(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize","doc":"Resizes image to new dimensions","summary":"

Resizes image to new dimensions

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L16"},"def":{"name":"bilinear_resize","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.bilinear_resize!(width, height)"}},{"html_id":"bilinear_resize!(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize!","doc":"Resizes image to new dimensions. Modifies self.","summary":"

Resizes image to new dimensions.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/bilinear_resize.cr#L21"},"def":{"name":"bilinear_resize!","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"x_ratio = width > 1 ? (@width - 1) / (width - 1) : 0\ny_ratio = height > 1 ? (@height - 1) / (height - 1) : 0\neach_channel do |channel, channel_type|\n resized_channel = Array.new(width * height) do\n 0_u8\n end\n height.times do |h|\n width.times do |w|\n x = w * x_ratio\n y = h * y_ratio\n x_ceil = Math.min(@width - 1, x.ceil.to_i)\n x_floor = x.floor.to_i\n y_ceil = Math.min(@height - 1, y.ceil.to_i)\n y_floor = y.floor.to_i\n value = case\n when (x_ceil == x_floor) && (y_ceil == y_floor)\n x_index = x.to_i\n y_index = y.to_i\n channel.unsafe_fetch((@width * y_index) + x_index)\n when x_ceil == x_floor\n x_index = x.to_i\n q_1 = channel.unsafe_fetch((@width * y_ceil) + x_index)\n q_2 = channel.unsafe_fetch((@width * y_floor) + x_index)\n ((q_2 * (y_ceil - y)) + (q_1 * (y - y_floor))).to_u8\n when y_ceil == y_floor\n y_index = y.to_i\n q_1 = channel.unsafe_fetch((@width * y_index) + x_ceil)\n q_2 = channel.unsafe_fetch((@width * y_index) + x_floor)\n ((q_2 * (x_ceil - x)) + (q_1 * (x - x_floor))).to_u8\n else\n v_1 = channel.unsafe_fetch((@width * y_floor) + x_floor)\n v_2 = channel.unsafe_fetch((@width * y_floor) + x_ceil)\n v_3 = channel.unsafe_fetch((@width * y_ceil) + x_floor)\n v_4 = channel.unsafe_fetch((@width * y_ceil) + x_ceil)\n q_1 = (v_1 * (x_ceil - x)) + (v_2 * (x - x_floor))\n q_2 = (v_3 * (x_ceil - x)) + (v_4 * (x - x_floor))\n ((q_1 * (y_ceil - y)) + (q_2 * (y - y_floor))).to_u8\n end\n resized_channel.unsafe_put((width * h) + w, value)\n end\n end\n self[channel_type] = resized_channel\nend\n@width = width\n@height = height\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","path":"CrImage/Operation/BoxBlur.html","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/box_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blurs the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.box_blur(1).save(\"blurred_1_sample.jpg\")\nimage.box_blur(5).save(\"blurred_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blurs the image

","instance_methods":[{"html_id":"box_blur(value:Int32):self-instance-method","name":"box_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L14"},"def":{"name":"box_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.box_blur!(value)"}},{"html_id":"box_blur!(value:Int32):self-instance-method","name":"box_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/box_blur.cr#L18"},"def":{"name":"box_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"horizontal_blur!(value)\nvertical_blur!(value)\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Brightness","path":"CrImage/Operation/Brightness.html","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness","abstract":false,"locations":[{"filename":"src/cr-image/operation/brightness.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Brightens an image (increases white value)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.brightness(2.0)\n```\n\"Brightened","summary":"

Brightens an image (increases white value)

","instance_methods":[{"html_id":"brightness(value:Float64):self-instance-method","name":"brightness","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L12"},"def":{"name":"brightness","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.brightness!(value)"}},{"html_id":"brightness!(value:Float64):self-instance-method","name":"brightness!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/brightness.cr#L16"},"def":{"name":"brightness!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"each_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, ( (channel.unsafe_fetch(index)) * value))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","path":"CrImage/Operation/ChannelSwap.html","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap","abstract":false,"locations":[{"filename":"src/cr-image/operation/channel_swap.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Swaps channels of `ChannelType` supported by an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.channel_swap(:green, :red) # Crystal autocasting of symbols to Pluto::ChannelType enum is magic\n```\n\"Channel","summary":"

Swaps channels of ChannelType supported by an image

","instance_methods":[{"html_id":"channel_swap(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L12"},"def":{"name":"channel_swap","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"clone.channel_swap!(a, b)"}},{"html_id":"channel_swap!(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap!","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/channel_swap.cr#L16"},"def":{"name":"channel_swap!","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"ch_a, ch_b = self[a], self[b]\nself[a] = ch_b\nself[b] = ch_a\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Contrast","path":"CrImage/Operation/Contrast.html","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast","abstract":false,"locations":[{"filename":"src/cr-image/operation/contrast.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Increases contrast of an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.contrast(20)\n```\n\"Contrasted","summary":"

Increases contrast of an image

","instance_methods":[{"html_id":"contrast(value:Float64):self-instance-method","name":"contrast","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L12"},"def":{"name":"contrast","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.contrast!(value)"}},{"html_id":"contrast!(value:Float64):self-instance-method","name":"contrast!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/contrast.cr#L16"},"def":{"name":"contrast!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"factor = (259 * (value + 255)) / (255 * (259 - value))\neach_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, Math.max(0, (factor * ((channel.unsafe_fetch(index)).to_i - 128)) + 128))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Crop","path":"CrImage/Operation/Crop.html","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop","abstract":false,"locations":[{"filename":"src/cr-image/operation/crop.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Crops an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\n# These calls are equivalent\nimage.crop(40, 30, 80, 80)\nimage[40...120, 30...110]\n```\n\"Cropped","summary":"

Crops an image

","instance_methods":[{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xrange, width)\nystart, ycount = resolve_to_start_and_count(yrange, height)\ncrop(xstart, ystart, xcount, ycount)\n"}},{"html_id":"crop(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L18"},"def":{"name":"crop","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.crop!(x, y, new_width, new_height)"}},{"html_id":"crop(region:Region):self-instance-method","name":"crop","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L14"},"def":{"name":"crop","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop(*region.to_tuple)"}},{"html_id":"crop!(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L32"},"def":{"name":"crop!","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"each_channel do |channel, channel_type|\n self[channel_type] = (UInt8Map.new(width, channel))[x, new_width, y, new_height].raw\nend\n@width = new_width\n@height = new_height\nself\n"}},{"html_id":"crop!(region:Region):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/crop.cr#L28"},"def":{"name":"crop!","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop!(*region.to_tuple)"}}]},{"html_id":"Crystal Image/CrImage/Operation/Draw","path":"CrImage/Operation/Draw.html","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw","abstract":false,"locations":[{"filename":"src/cr-image/operation/draw.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L17"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Draws shapes in the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.draw_square(40, 30, 80, 80, CrImage::Color.of(\"#00f\"))\nimage.draw_circle(80, 70, 40, CrImage::Color.of(\"#00f\"))\nimage.draw_line(50, 50, 70, 90, CrImage::Color.of(\"#0f0\"))\n```\n\"Woman\n\"Woman\n\"Woman\n\nCan also use the `fill: true` parameter to fill in the drawn shapes","summary":"

Draws shapes in the image

","instance_methods":[{"html_id":"draw_circle(x:Int,y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle centered at x, y with radius","summary":"

Draw a circle centered at x, y with radius

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L59"},"def":{"name":"draw_circle","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(x, y, radius, color, fill: fill)"}},{"html_id":"draw_circle(region:Region,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L54"},"def":{"name":"draw_circle","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":3,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_circle!(center_x:Int,center_y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle!","abstract":false,"args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L68"},"def":{"name":"draw_circle!","args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"min_x = Math.max(0, center_x - radius)\nmax_x = Math.min(width - 1, center_x + radius)\nmax_y = Math.min(height - 1, center_y + radius)\neach_color_channel do |channel, channel_type|\n 0.upto(radius) do |y|\n theta_0 = Math.asin((Math.max(0, ( y - 1))) / radius.to_f)\n theta_1 = Math.asin(y / radius.to_f)\n x_0 = (radius * (Math.cos(theta_0))).round\n x_1 = (radius * (Math.cos(theta_1))).round\n lower_x_outer = (Math.max(min_x, center_x - x_0)).to_i\n lower_x_inner = (Math.max(min_x, center_x - x_1)).to_i\n upper_x_outer = (Math.min(max_x, center_x + x_0)).to_i\n upper_x_inner = (Math.min(max_x, center_x + x_1)).to_i\n lower_y = center_y - y\n upper_y = center_y + y\n lower_y_outside_of_image = (center_y - y) < 0 || (center_y - y) > max_y\n upper_y_outside_of_image = (center_y + y) < 0 || (center_y + y) > max_y\n left_outer_x_beyond_right_of_image = (center_x - x_0) > max_x\n right_outer_x_beyond_left_of_image = (center_x + x_0) < 0\n left_inner_x_beyond_left_of_image = (center_x - x_1) < 0\n right_inner_x_beyond_right_of_image = (center_x + x_1) > max_x\n if fill\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n else\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(upper_x_inner, lower_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(upper_x_inner, upper_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n end\n end\nend\nself\n"}},{"html_id":"draw_circle!(region:Region,color:Color,*,fill:Bool=false,radius:Int32|Nil=nil):self-instance-method","name":"draw_circle!","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L64"},"def":{"name":"draw_circle!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_line(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L134"},"def":{"name":"draw_line","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.draw_line!(x1, y1, x2, y2, color)"}},{"html_id":"draw_line!(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line!","doc":"Implementation of http://www.edepot.com/linec.html","summary":"

Implementation of http://www.edepot.com/linec.html

","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":139,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L139"},"def":{"name":"draw_line!","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"if (0 <= x1 && x1 < width) && (0 <= y1 && y1 < height)\nelse\n raise(Exception.new(\"First point (#{x1},#{y1}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nif (0 <= x2 && x2 < width) && (0 <= y2 && y2 < height)\nelse\n raise(Exception.new(\"Second point (#{x2},#{y2}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nrise_by_height = false\nshort = y2 - y1\nlong = x2 - x1\nif short.abs > long.abs\n short, long = long, short\n rise_by_height = true\nend\nend_val = long\ngradient = long == 0 ? short : short / long.abs.to_f\nif rise_by_height\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + jump.to_i, y1 + i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nelse\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + i, y1 + jump.to_i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nend\nself\n"}},{"html_id":"draw_square(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L22"},"def":{"name":"draw_square","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"clone.draw_square!(x, y, box_width, box_height, color, fill: fill)"}},{"html_id":"draw_square(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L18"},"def":{"name":"draw_square","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"clone.draw_square!(region, color, fill: fill)"}},{"html_id":"draw_square!(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L30"},"def":{"name":"draw_square!","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"if (x + box_width) > width\n raise(\"Box dimensions extend #{((x + box_width) - width) + 1} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{((y + box_height) - height) + 1} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_color_channel do |channel, channel_type|\n channel[( (y_i * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n channel[((y_i + box_height) * width) + x_i, box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n box_height.times do |i|\n if i == 0\n next\n end\n if fill\n channel[( ((y_i + i) * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n else\n channel.unsafe_put(((y_i + i) * width) + x_i, color[channel_type])\n channel.unsafe_put(((((y_i + i) * width) + x_i) + box_width) - 1, color[channel_type])\n end\n end\nend\nself\n"}},{"html_id":"draw_square!(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/draw.cr#L26"},"def":{"name":"draw_square!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_square!(*region.to_tuple, color, fill: fill)"}}]},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","path":"CrImage/Operation/GaussianBlur.html","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Applies a 3x3 Gaussian blur. Implementation derived from [here](https://blog.ivank.net/fastest-gaussian-blur.html)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.gaussian_blur(1).save(\"gaussian_1_sample.jpg\")\nimage.gaussian_blur(5).save(\"gaussian_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Applies a 3x3 Gaussian blur.

","instance_methods":[{"html_id":"gaussian_blur(sigma:Int32):self-instance-method","name":"gaussian_blur","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L14"},"def":{"name":"gaussian_blur","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.gaussian_blur!(sigma)"}},{"html_id":"gaussian_blur!(sigma:Int32):self-instance-method","name":"gaussian_blur!","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/gaussian_blur.cr#L18"},"def":{"name":"gaussian_blur!","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"n = 3\nw_ideal = Math.sqrt((((12 * sigma) * sigma) / n) + 1)\nw_l = w_ideal.floor.to_i\nif (w_l % 2) == 0\n w_l = w_l - 1\nend\nm_ideal = (((((12 * sigma) * sigma) - ((n * w_l) * w_l)) - ((4 * n) * w_l)) - (3 * n)) / ((-4 * w_l) - 4)\nm = m_ideal.round\nsizes = [] of Int32\nn.times do |i|\n sizes << (if i < m\n w_l\n else\n w_l + 2\n end)\nend\nbox_blur!(((sizes.unsafe_fetch(0)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(1)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(2)) - 1) // 2)\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","path":"CrImage/Operation/HistogramEqualize.html","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize","abstract":false,"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":19,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Provides methods for histogram and histogram equalization. Follows method outlined [here](https://www.sci.utah.edu/~acoste/uou/Image/project1/Arthur_COSTE_Project_1_report.html)\n\nIf an image is particularly dark or particularly bright with low contrast, the `Operation::Contrast#contrast` method will only\nmake the image darker or lighter. For images like these, equalizing the image along its histogram will produce better results.\n\n\"A\n\n```\nimage.contrast(10).save(\"contrast.jpg\")\nimage.histogram_equalize.save(\"equalized.jpg\")\n```\n\"Darker\n\"A\n\nThis method does not work well when a given method has a bimodal distribution of color pixels. For example:\n\n\"Woman\n\"Highly","summary":"

Provides methods for histogram and histogram equalization.

","instance_methods":[{"html_id":"histogram(channel_type:ChannelType):Histogram-instance-method","name":"histogram","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Histogram","args_html":"(channel_type : ChannelType) : Histogram","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L107"},"def":{"name":"histogram","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Histogram","visibility":"Public","body":"Histogram.new(self, channel_type)"}},{"html_id":"histogram_equalize:self-instance-method","name":"histogram_equalize","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L111"},"def":{"name":"histogram_equalize","return_type":"self","visibility":"Public","body":"clone.histogram_equalize!"}},{"html_id":"histogram_equalize!:self-instance-method","name":"histogram_equalize!","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":115,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L115"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_color_channel do |channel, channel_type|\n if channel_type.alpha?\n next\n end\n remap = (histogram(channel_type)).equalize\n size.times do |i|\n channel.unsafe_put(i, remap[channel.unsafe_fetch(i)])\n end\nend\nself\n"}}],"types":[{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize/Histogram","path":"CrImage/Operation/HistogramEqualize/Histogram.html","kind":"class","full_name":"CrImage::Operation::HistogramEqualize::Histogram","name":"Histogram","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},"doc":"A histogram of an `Image` for a specific `ChannelType`","summary":"

A histogram of an Image for a specific ChannelType

","constructors":[{"html_id":"new(image:Image,channel_type:ChannelType)-class-method","name":"new","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(image : Image, channel_type : ChannelType)","args_html":"(image : Image, channel_type : ChannelType)","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L24"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, channel_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"cdf:Hash(UInt8,Float64)-instance-method","name":"cdf","doc":"Get the cumulative distribution for the image's histogram","summary":"

Get the cumulative distribution for the image's histogram

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L56"},"def":{"name":"cdf","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"total = 0_f64\n@cumulative_distribution_histogram || (@cumulative_distribution_histogram = normalize.map do |pixel, probability|\n original = total\n total = total + probability\n {pixel, original}\nend.to_h)\n"}},{"html_id":"channel_type:CrImage::ChannelType-instance-method","name":"channel_type","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"channel_type","visibility":"Public","body":"@channel_type"}},{"html_id":"counts:Hash(UInt8,Int32)-instance-method","name":"counts","doc":"Get the raw counts for a given pixel value (0-255) in the image","summary":"

Get the raw counts for a given pixel value (0-255) in the image

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L30"},"def":{"name":"counts","return_type":"Hash(UInt8, Int32)","visibility":"Public","body":"@internal_hist || (@internal_hist = calculate_counts)"}},{"html_id":"equalize:Hash(UInt8,UInt8)-instance-method","name":"equalize","doc":"Remap the cumalitive distribution of pixels to get a new, more spread out pixel value","summary":"

Remap the cumalitive distribution of pixels to get a new, more spread out pixel value

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L66"},"def":{"name":"equalize","return_type":"Hash(UInt8, UInt8)","visibility":"Public","body":"cdf.map do |pixel, cumalative|\n {pixel, ((cumalative * 255).clamp(0, 255)).to_u8}\nend.to_h"}},{"html_id":"image:CrImage::Image-instance-method","name":"image","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"image","visibility":"Public","body":"@image"}},{"html_id":"mean:Float64-instance-method","name":"mean","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L74"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@mean || (@mean = counts.sum do |pixel, count|\n pixel.to_i64 * count\nend.to_f64 / @image.size)"}},{"html_id":"normalize:Hash(UInt8,Float64)-instance-method","name":"normalize","doc":"Get pixel counts normalized - all values between 0.0 and 1.0","summary":"

Get pixel counts normalized - all values between 0.0 and 1.0

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L47"},"def":{"name":"normalize","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"counts.map do |pixel, count|\n {pixel, count.to_f / @image.size}\nend.to_h"}},{"html_id":"std_dev:Float64-instance-method","name":"std_dev","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/histogram.cr#L80"},"def":{"name":"std_dev","return_type":"Float64","visibility":"Public","body":"@std_dev || (@std_dev = Math.sqrt(counts.sum do |value, count|\n count * ((value.to_i64 - mean) ** 2)\nend.to_f64 / @image.size))"}}]}]},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","path":"CrImage/Operation/HorizontalBlur.html","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the horizontal axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.horizontal_blur(1).save(\"horizontal_1_sample.jpg\")\nimage.horizontal_blur(5).save(\"horizontal_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the horizontal axis

","instance_methods":[{"html_id":"horizontal_blur(k:Int32):self-instance-method","name":"horizontal_blur","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(k)"}},{"html_id":"horizontal_blur!(k:Int32):self-instance-method","name":"horizontal_blur!","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_blur!","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((k + k) + 1)\neach_color_channel do |channel|\n @height.times do |y|\n center_index : Int32 = y * @width\n left__bound : Int32 = center_index\n right_bound : Int32 = center_index + k\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last__value : Int32 = (channel.unsafe_fetch((center_index + @width) - 1)).to_i\n current_sum : Int32 = (k + 1) * first_value\n (0..(k - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + i))\n end\n (0..k).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n center_index = center_index + 1\n end\n ((k + 1)..((@width - k) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n ((@width - k)..(@width - 1)).each do\n current_sum = current_sum + (last__value - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","path":"CrImage/Operation/MaskApply.html","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply","abstract":false,"locations":[{"filename":"src/cr-image/operation/mask_apply.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Apply a mask to an image\n\nTaking sample `image`:\n\n\"Woman\n\nAnd mask\n\n\"Black\n\n```\nmask = CrImage::Mask.new(image, false)\nmask[50..90, 65..75] = true\nmask.to_gray.save(\"apply_mask_mask.jpg\")\n\nimage.apply(mask).save(\"apply_mask.jpg\")\n\nimage.apply_color(mask, CrImage::Color.of(\"#00f\")).save(\"apply_mask_color.jpg\")\n\nimage.apply(mask) do |pixel, channel_type, x, y|\n Math.min(255, pixel + 50).to_u8 if channel_type.blue?\nend.save(\"apply_mask_block.jpg\")\n```\n\"Image\n\"Thin\n\"Thin","summary":"

Apply a mask to an image

","instance_methods":[{"html_id":"apply(mask:Mask):self-instance-method","name":"apply","doc":"Black out all pixels but those found in the mask","summary":"

Black out all pixels but those found in the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L29"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"clone.apply!(mask)"}},{"html_id":"apply(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply","doc":"Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.\n\nDoes not change values not matched by the mask","summary":"

Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L36"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"clone.apply!(mask, &block)"}},{"html_id":"apply!(mask:Mask):self-instance-method","name":"apply!","doc":"TODO: add apply version that accepts 1+ ChannelType that the mask should apply to (i.e. make a background completely transparent, not just transparent black)","summary":"

TODO add apply version that accepts 1+ ChannelType that the mask should apply to (i.e.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L46"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? pixel : 0_u8\n end\nend\nself\n"}},{"html_id":"apply!(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L55"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel, channel_type|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? (block.call(pixel, channel_type, i % width, i // width)) || pixel : pixel\n end\nend\nself\n"}},{"html_id":"apply_color(mask:Mask,color:Color):self-instance-method","name":"apply_color","doc":"Change the color of all pixels that match the mask","summary":"

Change the color of all pixels that match the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L41"},"def":{"name":"apply_color","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.apply_color!(mask, color)"}},{"html_id":"apply_color!(mask:Mask,color:Color):self-instance-method","name":"apply_color!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/mask_apply.cr#L66"},"def":{"name":"apply_color!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"apply!(mask) do |_, channel_type|\n color[channel_type]\nend"}}]},{"html_id":"Crystal Image/CrImage/Operation/Pad","path":"CrImage/Operation/Pad.html","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad","abstract":false,"locations":[{"filename":"src/cr-image/operation/pad.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Pads an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.pad(left: 50, right: 50)\nimage.pad(left: 50, right: 50, pad_type: CrImage::EdgePolicy::Repeat)\n```\n\"Picture\n\"Picture","summary":"

Pads an image

","instance_methods":[{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L14"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.pad!(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type)"}},{"html_id":"pad!(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad!","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/pad.cr#L18"},"def":{"name":"pad!","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"orig_width = width\neach_channel do |channel, channel_type|\n padded = (UInt8Map.new(orig_width, channel)).pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: channel_type.default)\n self[channel_type] = padded.raw\n @width = padded.width\n @height = padded.height\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Rotate","path":"CrImage/Operation/Rotate.html","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate","abstract":false,"locations":[{"filename":"src/cr-image/operation/rotate.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Rotates an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.rotate(45)\nimage.rotate(45, pad: true)\n```\n\"Rotated\n\"Rotated","summary":"

Rotates an image

","instance_methods":[{"html_id":"rotate(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate","doc":"Rotates an image by `degrees`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L20"},"def":{"name":"rotate","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.rotate!(degrees, center_x: center_x, center_y: center_y, radius: radius, pad: pad, pad_type: pad_type)"}},{"html_id":"rotate!(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate!","doc":"Rotates an image by `degrees`. Modifies `self`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees.

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/rotate.cr#L38"},"def":{"name":"rotate!","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"if pad_type.none?\n raise(Exception.new(\"Edge policy None doesn't apply to rotation\"))\nend\nif pad && radius >= 0\n raise(Exception.new(\"Can't pad image and limit rotation by radius\"))\nend\nradians = ((-Math::PI) * degrees) / 180\nsin = Math.sin(radians)\ncos = Math.cos(radians)\nradius_sq = radius * radius\nnew_width, new_size, out_center_x, out_center_y = output_dimensions(pad, degrees, center_x, center_y)\neach_channel do |channel, channel_type|\n new_x = -1\n new_y = 0\n self[channel_type] = Array.new(new_size) do |i|\n new_x = new_x + 1\n if new_x == new_width\n new_x = 0\n new_y = new_y + 1\n end\n if radius >= 0 && (((new_x - center_x) ** 2) + ((new_y - center_y) ** 2)) > radius_sq\n next channel.unsafe_fetch(i)\n end\n orig_x = (((cos * (new_x - out_center_x)) - (sin * (new_y - out_center_y))) + center_x).round.to_i\n orig_y = (((sin * (new_x - out_center_x)) + (cos * (new_y - out_center_y))) + center_y).round.to_i\n if pad_type.black?\n if ((orig_x < 0 || orig_x >= width) || orig_y < 0) || orig_y >= height\n next channel_type.default\n end\n else\n orig_x = orig_x.clamp(0, width - 1)\n orig_y = orig_y.clamp(0, height - 1)\n end\n channel.unsafe_fetch((orig_y * width) + orig_x)\n end\nend\n@width = new_width\n@height = new_size // new_width\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","path":"CrImage/Operation/VerticalBlur.html","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the vertical axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.vertical_blur(1).save(\"vertical_1_sample.jpg\")\nimage.vertical_blur(5).save(\"vertical_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the vertical axis

","instance_methods":[{"html_id":"vertical_blur(value:Int32):self-instance-method","name":"vertical_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L14"},"def":{"name":"vertical_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.vertical_blur!(value)"}},{"html_id":"vertical_blur!(value:Int32):self-instance-method","name":"vertical_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/operation/vertical_blur.cr#L18"},"def":{"name":"vertical_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((value + value) + 1)\neach_color_channel do |channel|\n @width.times do |x|\n center_index : Int32 = x\n left_bound : Int32 = center_index\n right_bound : Int32 = center_index + (value * @width)\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last_value : Int32 = (channel.unsafe_fetch(center_index + (@width * (@height - 1)))).to_i\n current_sum : Int32 = (value + 1) * first_value\n (0..(value - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + (i * @width)))\n end\n (0..value).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n current_sum = current_sum + (last_value - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n center_index = center_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"Crystal Image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a rectangular area on an `Image` from its upper left corner `x` and `y` coordinates, and a `width` and `height`.\n\nSee `Operation::Crop#crop` and `Operation::Draw#draw_square` for examples using it.","summary":"

Represents a rectangular area on an Image from its upper left corner #x and #y coordinates, and a #width and #height.

","constructors":[{"html_id":"center(x:UInt16,y:UInt16,width:UInt16,height:UInt16):Region-class-method","name":"center","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","location":{"filename":"src/cr-image/region.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L11"},"def":{"name":"center","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"return_type":"Region","visibility":"Public","body":"new(x - (width // 2), y - (height // 2), width, height)"}},{"html_id":"new(x:UInt16,y:UInt16,width:UInt16,height:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"new","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(x, y, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"center:Tuple(Int32,Int32)-instance-method","name":"center","doc":"Return the `{x, y}` tuple of the center coordinates of this `Region`","summary":"

Return the {x, y} tuple of the center coordinates of this Region

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L21"},"def":{"name":"center","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{(width.to_i // 2) + x.to_i, (height.to_i // 2) + y.to_i}"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@x.clone, @y.clone, @width.clone, @height.clone)"}},{"html_id":"copy_with(x_x=@x,y_y=@y,width_width=@width,height_height=@height)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"args_string":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","args_html":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L5"},"def":{"name":"copy_with","args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"visibility":"Public","body":"self.class.new(_x, _y, _width, _height)"}},{"html_id":"crop(image:Image):Image-instance-method","name":"crop","doc":"Crop a provided `Image` with this region, using `Operation::Crop#crop`","summary":"

Crop a provided Image with this region, using Operation::Crop#crop

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/region.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L16"},"def":{"name":"crop","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.crop(self)"}},{"html_id":"height:UInt16-instance-method","name":"height","abstract":false,"def":{"name":"height","return_type":"UInt16","visibility":"Public","body":"@height"}},{"html_id":"to_tuple:Tuple(Int32,Int32,Int32,Int32)-instance-method","name":"to_tuple","doc":"Return this `Region` as a `x`, `y`, `width`, and `height` tuple","summary":"

Return this Region as a #x, #y, #width, and #height tuple

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/region.cr#L26"},"def":{"name":"to_tuple","return_type":"Tuple(Int32, Int32, Int32, Int32)","visibility":"Public","body":"{x.to_i, y.to_i, width.to_i, height.to_i}"}},{"html_id":"width:UInt16-instance-method","name":"width","abstract":false,"def":{"name":"width","return_type":"UInt16","visibility":"Public","body":"@width"}},{"html_id":"x:UInt16-instance-method","name":"x","abstract":false,"def":{"name":"x","return_type":"UInt16","visibility":"Public","body":"@x"}},{"html_id":"y:UInt16-instance-method","name":"y","abstract":false,"def":{"name":"y","return_type":"UInt16","visibility":"Public","body":"@y"}}]},{"html_id":"Crystal Image/CrImage/RepeatView","path":"CrImage/RepeatView.html","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":52,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L52"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to the nearest edge of that `Map`","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to the nearest edge of that Map

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = RepeatView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L53"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = ((x - @half_width) + @map_x).clamp(0, @map.width - 1)\nadjusted_y = ((y - @half_height) + @map_y).clamp(0, @map.height - 1)\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/rgba_image.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L2"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L36"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L29"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image with red, green, blue, and alpha color channels (i.e. a color image). This image type is likely the one read from and written to file (or `IO`).","summary":"

An image with red, green, blue, and alpha color channels (i.e.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L10"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L13"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):Color-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Color","args_html":"(x : Int32, y : Int32) : Color","location":{"filename":"src/cr-image/rgba_image.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L49"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Color","visibility":"Public","body":"index = (y * width) + x\nColor.new(red[index], green[index], blue[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the channel corresponding to `channel_type`","summary":"

Return the channel corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L55"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red\nwhen ChannelType::Green\n @green\nwhen ChannelType::Blue\n @blue\nwhen ChannelType::Alpha\n @alpha\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the corresponding `channel_type` with `channel`","summary":"

Set the corresponding channel_type with channel

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L66"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red = channel\nwhen ChannelType::Green\n @green = channel\nwhen ChannelType::Blue\n @blue = channel\nwhen ChannelType::Alpha\n @alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@blue"}},{"html_id":"blue=(blue:Array(UInt8))-instance-method","name":"blue=","abstract":false,"args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"args_string":"(blue : Array(UInt8))","args_html":"(blue : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue=","args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@blue = blue"}},{"html_id":"clone:RGBAImage-instance-method","name":"clone","doc":"Create a copy of this image","summary":"

Create a copy of this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L21"},"def":{"name":"clone","return_type":"RGBAImage","visibility":"Public","body":"self.class.new(@red.clone, @green.clone, @blue.clone, @alpha.clone, @width, @height)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L41"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L33"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nnil\n"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@green"}},{"html_id":"green=(green:Array(UInt8))-instance-method","name":"green=","abstract":false,"args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"args_string":"(green : Array(UInt8))","args_html":"(green : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green=","args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@green = green"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"mask_from(&block:Color,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":103,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L103"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Color, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(Color.new(red.unsafe_fetch(i), green.unsafe_fetch(i), blue.unsafe_fetch(i), alpha.unsafe_fetch(i)), x, y)\nend)\n"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@red"}},{"html_id":"red=(red:Array(UInt8))-instance-method","name":"red=","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"args_string":"(red : Array(UInt8))","args_html":"(red : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red=","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@red = red"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels in this image","summary":"

Return the number of pixels in this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L99"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"to_gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert color image to `GrayscaleImage`, using the NTSC formula as default values.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Convert color image to GrayscaleImage, using the NTSC formula as default values.

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","location":{"filename":"src/cr-image/rgba_image.cr","line_number":83,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L83"},"def":{"name":"to_gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(red.map_with_index do |red_pix, i|\n (Math.min(255, ((red_pix * red_multiplier) + (@green[i] * green_multiplier)) + (@blue[i] * blue_multiplier))).to_u8\nend, width, height)"}},{"html_id":"to_pluto:Pluto::ImageRGBA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L37"},"def":{"name":"to_pluto","return_type":"Pluto::ImageRGBA","visibility":"Public","body":"Pluto::ImageRGBA.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":94,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L94"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"self"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L30"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.red.to_u16 << 8, color.green.to_u16 << 8, color.blue.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"Crystal Image/CrImage/UInt8Map","path":"CrImage/UInt8Map.html","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":495,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L495"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `UInt8` types. This type is useful for `MapImpl` operations around channels.","summary":"

Implementation of MapImpl for UInt8 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":502,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L502"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":498,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L498"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":496,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/map.cr#L496"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Window","path":"CrImage/Window.html","kind":"class","full_name":"CrImage::Window(T)","name":"Window","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L8"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/BlackView","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView"},{"html_id":"Crystal Image/CrImage/ErrorView","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView"},{"html_id":"Crystal Image/CrImage/RepeatView","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a read-only view on top of a `Map`.\n\nConstructing one of these over a larger `Map` allows for a re-indexed view within that map. If needing to sum all values\nwithin a certain area, a `Window` can be constructed around that area and then summed from that.\n\nSee `RepeatView`, `ErrorView`, and `BlackView` for specific edge handling cases.","summary":"

Represents a read-only view on top of a Map.

","constructors":[{"html_id":"new(width:Int32,height:Int32,map:CrImage::Map(T),map_x:Int32,map_y:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","args_html":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"visibility":"Public","body":"_ = Window(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L22"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"half_height:Int32-instance-method","name":"half_height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L10"},"def":{"name":"half_height","return_type":"Int32","visibility":"Public","body":"@half_height"}},{"html_id":"half_width:Int32-instance-method","name":"half_width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L9"},"def":{"name":"half_width","return_type":"Int32","visibility":"Public","body":"@half_width"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L12"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"map:Map(T)-instance-method","name":"map","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L13"},"def":{"name":"map","return_type":"Map(T)","visibility":"Public","body":"@map"}},{"html_id":"map_x:Int32-instance-method","name":"map_x","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L14"},"def":{"name":"map_x","return_type":"Int32","visibility":"Public","body":"@map_x"}},{"html_id":"map_y:Int32-instance-method","name":"map_y","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L15"},"def":{"name":"map_y","return_type":"Int32","visibility":"Public","body":"@map_y"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Calculate the mean for all values in the window","summary":"

Calculate the mean for all values in the window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L41"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"sum / size"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the size of this window","summary":"

Return the size of this window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L46"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"sum:Float64-instance-method","name":"sum","doc":"Sum all values in the window together","summary":"

Sum all values in the window together

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":25,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L25"},"def":{"name":"sum","return_type":"Float64","visibility":"Public","body":"sum(&.itself)"}},{"html_id":"sum(&:T,Int32,Int32,self->T):Float64-instance-method","name":"sum","doc":"Iterate over all values within the window and sum the result of the passed in block","summary":"

Iterate over all values within the window and sum the result of the passed in block

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L30"},"def":{"name":"sum","yields":4,"block_arity":4,"block_arg":{"name":"","external_name":"","restriction":"(T, Int32, Int32, self -> T)"},"return_type":"Float64","visibility":"Public","body":"ret = 0_f64\nheight.times do |y|\n width.times do |x|\n ret = ret + (yield self[x, y], x, y, self).to_f64\n end\nend\nret\n"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/cr-image/window_view.cr#L11"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]}]},{"html_id":"Crystal Image/Pluto","path":"Pluto.html","kind":"module","full_name":"Pluto","name":"Pluto","abstract":false,"locations":[{"filename":"lib/pluto/src/pluto.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto.cr#L3"},{"filename":"lib/pluto/src/pluto/channel_type.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/channel_type.cr#L1"},{"filename":"src/pluto.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L20"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This project was initially a fork of [Pluto](https://github.com/phenopolis/pluto/), and so can very easily convert\nbetween the underlying format used by `CrImage` and `Pluto`. To easily convert a `Pluto` image to `CrImage`, simply:\n\n```\nrequire \"cr-image/pluto\"\n\nimage # => Pluto::ImageRGBA\nimage.to_crimage # => CrImage::RGBAImage\nimage.to_crimage.to_pluto # => Pluto::ImageRGBA\n```\nThis also works with `Pluto::ImageGA` and `CrImage::GrayscaleImage`, respectively.\n\n> Why are `ImageRGBA` and `RGBAImage` names mirrored?\n\nThe current `CrImage` names are a carry over from when originally forked from `Pluto`. However, after `Pluto` renamed `RGBAImage` to `ImageRGBA`, I noticed it became\nmore difficult to visually distinguish between `ImageRGBA` and `ImageGA`, as opposed to `RGBAImage` and `GrayscaleImage`, so I kept the older names.","summary":"

This project was initially a fork of Pluto, and so can very easily convert between the underlying format used by CrImage and Pluto.

","types":[{"html_id":"Crystal Image/Pluto/ImageGA","path":"Pluto/ImageGA.html","kind":"class","full_name":"Pluto::ImageGA","name":"ImageGA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_ga.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/image_ga.cr#L3"},{"filename":"src/pluto.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::GrayscaleImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/pluto.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L29"},"def":{"name":"to_crimage","return_type":"CrImage::GrayscaleImage","visibility":"Public","body":"new(gray.clone, alpha.clone, width, height)"}}]},{"html_id":"Crystal Image/Pluto/ImageRGBA","path":"Pluto/ImageRGBA.html","kind":"class","full_name":"Pluto::ImageRGBA","name":"ImageRGBA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_rgba.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/pluto/src/pluto/image_rgba.cr#L3"},{"filename":"src/pluto.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","doc":"Con","summary":"

Con

","abstract":false,"location":{"filename":"src/pluto.cr","line_number":23,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/pluto.cr#L23"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"CrImage::RGBAImage.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}}]}]},{"html_id":"Crystal Image/StumpyCore","path":"StumpyCore.html","kind":"module","full_name":"StumpyCore","name":"StumpyCore","abstract":false,"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/canvas.cr#L3"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba.cr#L4"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/mixing.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/rgba/mixing.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/utils.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/utils.cr#L1"},{"filename":"src/stumpy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"A module owned by [StumpyCr](https://github.com/stumpycr/stumpy_core)","summary":"

A module owned by StumpyCr

","types":[{"html_id":"Crystal Image/StumpyCore/Canvas","path":"StumpyCore/Canvas.html","kind":"class","full_name":"StumpyCore::Canvas","name":"Canvas","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/lib/stumpy_core/src/stumpy_core/canvas.cr#L31"},{"filename":"src/stumpy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L6"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/StumpyCore","kind":"module","full_name":"StumpyCore","name":"StumpyCore"},"doc":"A canvas is 2D array of `RGBA` pixels\n\nTo create a canvas of size `400` x `200`\n\n```\ncanvas = StumpyCore::Canvas.new(400, 200)\n```\n\nThe default background color is transparent,\nbut it can be passed in as a parameter or as a block\nthat returns the color value for each `{x, y}` pair.\n\n```\ncanvas2 = StumpyCore::Canvas.new(400, 200, RGBA::WHITE)\n```\n\n```\ncanvas3 = StumpyCore::Canvas.new(256, 256) do |x, y|\n RGBA.from_rgb_n(x, y, 255, 8)\nend\n```\n![image](https://github.com/stumpycr/stumpy_core/blob/feature/images/rainbow.png?raw=true)\n\nBecause of the way pixels are stored in a `Slice`,\n`Canvas`es are limited to `Int32::MAX = 2147483647` pixels in total,\ne.g. a maximal size of 46340x46340 for a square image.","summary":"

A canvas is 2D array of RGBA pixels

","instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/stumpy.cr#L7"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"size = width * height\nred = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\neach_row do |row|\n row.each do |rgba|\n red << (rgba.r >> 8).to_u8\n green << (rgba.g >> 8).to_u8\n blue << (rgba.b >> 8).to_u8\n alpha << (rgba.a >> 8).to_u8\n end\nend\nCrImage::RGBAImage.new(red, green, blue, alpha, width, height)\n"}}]}]},{"html_id":"Crystal Image/Tutorial","path":"Tutorial.html","kind":"module","full_name":"Tutorial","name":"Tutorial","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/chromakey_tutorial.cr#L35"},{"filename":"src/tutorials/tutorial.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/tutorial.cr#L7"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This fictional module exists to provide tutorials for using CrImage in the documentation\n\nSee:\n* `EdgeDetection`\n* `ChromaKey`\n* `FindDifferences`","summary":"

This fictional module exists to provide tutorials for using CrImage in the documentation

","types":[{"html_id":"Crystal Image/Tutorial/ChromaKey","path":"Tutorial/ChromaKey.html","kind":"module","full_name":"Tutorial::ChromaKey","name":"ChromaKey","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/chromakey_tutorial.cr#L35"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can swap out the background by creating a mask representing the pixels that are close in color, and replacing them using an `MaskApply#apply_color` method.\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"sample.jpg\")\n\n# Grab a color from the background, for comparison\nbackground = image[10, 10]\n\n# Construct a mask of all pixels within a color distance of our background\nbackground_mask = image.mask_from do |color|\n # 25 chosen through trial-and-error\n color.dist(background) < 25\nend\n .closing! # Remove small `true` regions\n .opening! # Remove small `false` regions\n\n# Now make the background blue\nimage\n .apply_color(background_mask, CrImage::Color.of(\"#0000cc\"))\n .save(\"chromakey.jpg\")\n```\n\nResults in image:\n\n\"Background\n\nThis script ran on my machine in `4ms` in `--release` mode.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/EdgeDetection","path":"Tutorial/EdgeDetection.html","kind":"module","full_name":"Tutorial::EdgeDetection","name":"EdgeDetection","abstract":false,"locations":[{"filename":"src/tutorials/edge_detection_tutorial.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/edge_detection_tutorial.cr#L38"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can run the [Sobel Operator](https://en.wikipedia.org/wiki/Sobel_operator) to detect edges in it:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nvertical_sobel = CrImage::IntMap.new([\n [-1, -2, -1],\n [0, 0, 0],\n [1, 2, 1],\n])\n\nhorizontal_sobel = CrImage::IntMap.new([\n [-1, 0, 1],\n [-2, 0, 2],\n [-1, 0, 1],\n])\n\nimage = CrImage::GrayscaleImage.open(\"sample.jpg\")\n\ndx = image.cross_correlate(horizontal_sobel)\ndy = image.cross_correlate(vertical_sobel)\n\n(dx ** 2 + dy ** 2).to_gray(scale: true).save(\"edge_detection.jpg\")\n```\n\nResults in image:\n\n\"Black\n\nThis script ran on my machine in `11ms` in `--release` mode.\n\n**Note**: This tutorial is using `cross_correlate`. For large images (or medium-to-large operators), the `cross_correlate_fft` may perform better.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/FindDifferences","path":"Tutorial/FindDifferences.html","kind":"module","full_name":"Tutorial::FindDifferences","name":"FindDifferences","abstract":false,"locations":[{"filename":"src/tutorials/find_differences.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/8d87c4608dd8d360bdcec0f512f3398afc189ac9/src/tutorials/find_differences.cr#L55"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `differences.jpg` image:\n\n\"Two\n\nWe can programatically detect _most_ of the differences between these two images:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"differences.jpg\")\nret = image.clone\n\n# Perform a blur to remove random noise\nimg1 = image.gaussian_blur(1)[2...340, ..]\nimg2 = image.gaussian_blur(1)[361...699, ..]\n\n# Convert each color channel into a IntMap\nred_img1 = CrImage::UInt8Map.new(img1.width, img1.red).to_i\ngre_img1 = CrImage::UInt8Map.new(img1.width, img1.green).to_i\nblu_img1 = CrImage::UInt8Map.new(img1.width, img1.blue).to_i\nred_img2 = CrImage::UInt8Map.new(img2.width, img2.red).to_i\ngre_img2 = CrImage::UInt8Map.new(img2.width, img2.green).to_i\nblu_img2 = CrImage::UInt8Map.new(img2.width, img2.blue).to_i\n\n# Calculate a pixel by pixel difference calculation, convert it to a `Mask`\nred_mask = (red_img1 - red_img2).abs.>(50)\ngre_mask = (gre_img1 - gre_img2).abs.>(50)\nblu_mask = (blu_img1 - blu_img2).abs.>(50)\n\n# Combine the different color channel masks\ncombo_mask = (red_mask | blu_mask | gre_mask).dilate!\n\n# Expensive way to make a thick box.\n3.times do\n combo_mask.dilate!.segments.each do |v|\n # Draw a box in the first image\n ret.draw_square!(v.region.x + 2, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n # ... and the second image\n ret.draw_square!(v.region.x + 361, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n end\nend\n\nret.save(\"differences_end.jpg\")\n```\n\nResults in image:\n\n\"Two\n\nThis script ran on my machine in `66ms` in `--release` mode.\n\n**NOTE**: There's a difference in the seeds on one of the watermelons that don't survive the blurring process, and so aren't picked\nup by the differences algorithm above.","summary":"

Given differences.jpg image:

"}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"Crystal Image","body":"

Crystal Image (Processing)

\n\nThis shard aims to provide feature rich image processing abilities, both for the purpose of\nimage manipulation as well as feature / information extraction from those images.\n\nThe code here originated as a fork from [Pluto](https://github.com/phenopolis/pluto) and further takes inspiration from [Stumpy](https://github.com/stumpycr/stumpy_core),\nand support converting to and from both of those libraries.\n\nAll sample images used are from [Unsplash](https://unsplash.com/).\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cr-image:\n github: vici37/cr-image\n ```\n\n2. Run `shards install`\n\n## Usage\n\nCrImage supports the formats:\n* PPM\n* JPEG (requires `libturbojpeg`)\n* PNG (natively by default, or optionally through requires `libspng`)\n* WebP (requires `libwebp`)\n\nFor the formats that require a linked library, they must be `require`d explicitly:\n\n```crystal\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\nrequire \"cr-image/webp\"\nrequire \"cr-image/png\" # replaces native crystal with libspng\n\n# Or, alternatively\nrequire \"cr-image/all_formats\"\n```\n\n### Example\n\nAssuming an image `moon.jpg` already exists\n\n\"Picture\n\n```crystal\nrequire \"cr-image\"\n\nimage = CrImage::RGBAImage.open(\"moon.jpg\")\n\n# create a mask identifying all pixels with light (i.e. the moon)\nmoon_mask = image\n .to_gray\n .threshold(8) # pixels are UInt8, with 0 as black and 255 as white\n\n# Crop out the moon from the image, and save it to a new file\nimage.crop(\n moon_mask.region # smallest area that encompasses all true bits in mask\n).save(\"moon_cropped.jpg\")\n\n```\n\nYields this image:\n\n\"Cropped\n\n[See the tutorials](http://troy.sornson.io/cr-image/Tutorial.html) for more examples.\n\n### [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core) Conversion\n\nIf your library or application already uses Pluto or Stumpy and you want to use\nsome of the functionality of this library, CrImage also provides some optional\nconversion methods:\n\n```crystal\nrequire \"cr-image/pluto\"\npluto_image # => Pluto::ImageRGBA\npluto_image.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_pluto # => Pluto::ImageRGBA\n```\n\n**NOTE:** Currently Pluto and CrImage share the same bindings for `libturbojpeg`, `libspng`, and `libwebp`. If you\nuse Pluto, you _cannot_ use those formats from CrImage.\n\n\n```crystal\nrequire \"cr-image/stumpy\"\nstumpy_canvas # => StumpyCore::Canvas\nstumpy_canvas.to_crimage # => CrImage::RGBAImage\n\ncr_image # => CrImage::RGBAImage\ncr_image.to_stumpy # => StumpyCore::Canvas\n```\n\n**NOTE:** Stumpy uses `UInt16` for its underlying raw image storage per channel per pixel, while Pluto and\nCrImage uses `UInt8`. Converting from a Stumpy `Canvas` object to `RGBAImage` may lose quality if the original\nimage used 16 bit color channels (i.e. 16-bit PNG). Most image formats tend to use 8-bit color channels.\n\n## Development\n\nThis requires `libwebp`, `libspng`, and `libturbojpeg` to run. Then:\n\n```\n> make test\n```\n\nTo ensure all tests run and pass.\n\n## Contributing\n\n1. [Fork it](https://github.com/Vici37/cr-image/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Troy Sornson](https://github.com/Vici37) - creator and maintainer\n","program":{"html_id":"Crystal Image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"Crystal Image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"Crystal Image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image.cr#L21"},{"filename":"src/cr-image/edge_policy.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L1"},{"filename":"src/cr-image/map.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L1"},{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/region.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L1"},{"filename":"src/cr-image/window_view.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L1"},{"filename":"src/lib-formats/bindings/lib_jpeg_turbo.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_jpeg_turbo.cr#L1"},{"filename":"src/lib-formats/bindings/lib_spng.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_spng.cr#L1"},{"filename":"src/lib-formats/bindings/lib_webp.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/bindings/lib_webp.cr#L1"},{"filename":"src/pluto.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L35"},{"filename":"src/stumpy.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This module by itself isn't very interesting. Try taking a look through the [tutorials](./Tutorial.html) for better examples.","summary":"

This module by itself isn't very interesting.

","types":[{"html_id":"Crystal Image/CrImage/BlackView","path":"CrImage/BlackView.html","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L76"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to zero (or black)","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to zero (or black)

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = BlackView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":77,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L77"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n return T.zero\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/channel_type.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Red","name":"Red","value":"0"},{"id":"Green","name":"Green","value":"1"},{"id":"Blue","name":"Blue","value":"2"},{"id":"Gray","name":"Gray","value":"3"},{"id":"Alpha","name":"Alpha","value":"4"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_color_channel` and `GrayscaleImage#each_color_channel`","summary":"

Enum representing different image channels supported by CrImage

","instance_methods":[{"html_id":"alpha?-instance-method","name":"alpha?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L9"},"def":{"name":"alpha?","visibility":"Public","body":"self == Alpha"}},{"html_id":"blue?-instance-method","name":"blue?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"html_id":"default:UInt8-instance-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L11"},"def":{"name":"default","return_type":"UInt8","visibility":"Public","body":"alpha? ? 255_u8 : 0_u8"}},{"html_id":"gray?-instance-method","name":"gray?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L8"},"def":{"name":"gray?","visibility":"Public","body":"self == Gray"}},{"html_id":"green?-instance-method","name":"green?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L6"},"def":{"name":"green?","visibility":"Public","body":"self == Green"}},{"html_id":"red?-instance-method","name":"red?","abstract":false,"location":{"filename":"src/cr-image/channel_type.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"Crystal Image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/color.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for parsing and representing colors that can be used for certain\nmethods in CrImage.\n\nSee `Operation::MaskApply#apply_color`, `Operation::Draw#draw_square`, or `Operation::Draw#draw_circle`","summary":"

Utility class for parsing and representing colors that can be used for certain methods in CrImage.

","constructors":[{"html_id":"default:Color-class-method","name":"default","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L11"},"def":{"name":"default","return_type":"Color","visibility":"Public","body":"new(ChannelType::Red.default, ChannelType::Green.default, ChannelType::Blue.default, ChannelType::Alpha.default)"}},{"html_id":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=ChannelType::Alpha.default)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L8"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"UInt8"},{"name":"green","external_name":"green","restriction":"UInt8"},{"name":"blue","external_name":"blue","restriction":"UInt8"},{"name":"alpha","default_value":"ChannelType::Alpha.default","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"of(color:String):Color-class-method","name":"of","doc":"Parse color from a hex string:\n\n```\nColor.of(\"#1\") # same as \"#11\" => Color.new(17, 17, 17, 255)\nColor.of(\"#01\") # => Color.new(1, 1, 1, 255)\nColor.of(\"#123\") # same as \"#112233\" => Color.new(17, 34, 51, 255)\nColor.of(\"#1234\") # same as \"#11223344\" => Color.new(34, 51, 68, 17)\nColor.of(\"#010203\") # => Color.new(1, 2, 3, 255)\nColor.of(\"#01020304\") # => Color.new(2, 3, 4, 1)\n```","summary":"

Parse color from a hex string:

","abstract":false,"args":[{"name":"color","external_name":"color","restriction":"String"}],"args_string":"(color : String) : Color","args_html":"(color : String) : Color","location":{"filename":"src/cr-image/color.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L49"},"def":{"name":"of","args":[{"name":"color","external_name":"color","restriction":"String"}],"return_type":"Color","visibility":"Public","body":"if ((!(color.starts_with?(\"#\"))) || (!({2, 3, 4, 5, 7, 9}.includes?(color.size)))) || (color.match(/^#[^0-9a-f]/i))\n raise(\"Invalid hex color '#{color}': must start with '#' followed by 1, 2, 3, 4, 6, or 9 alphanumeric characters (0-9 or a-f)\")\nend\ncase color.size\nwhen 2\n gray = (color[1].to_i(16)).to_u8\n gray = (gray << 4) + gray\n self.new(gray, gray, gray)\nwhen 3\n gray = (color[1, 2].to_i(16)).to_u8\n self.new(gray, gray, gray)\nwhen 4\n red = (color[1].to_i(16)).to_u8\n green = (color[2].to_i(16)).to_u8\n blue = (color[3].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue)\nwhen 5\n alpha = (color[1].to_i(16)).to_u8\n red = (color[2].to_i(16)).to_u8\n green = (color[3].to_i(16)).to_u8\n blue = (color[4].to_i(16)).to_u8\n self.new((red << 4) + red, (green << 4) + green, (blue << 4) + blue, (alpha << 4) + alpha)\nwhen 7\n red = (color[1, 2].to_i(16)).to_u8\n green = (color[3, 2].to_i(16)).to_u8\n blue = (color[5, 2].to_i(16)).to_u8\n self.new(red, green, blue)\nelse\n alpha = (color[1, 2].to_i(16)).to_u8\n red = (color[3, 2].to_i(16)).to_u8\n green = (color[5, 2].to_i(16)).to_u8\n blue = (color[7, 2].to_i(16)).to_u8\n self.new(red, green, blue, alpha)\nend\n"}},{"html_id":"random:Color-class-method","name":"random","doc":"Generate a random color with full (255) opacity","summary":"

Generate a random color with full (255) opacity

","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L16"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), ChannelType::Alpha.default)\n"}}],"instance_methods":[{"html_id":"==(other:Color):Bool-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"}],"args_string":"(other : Color) : Bool","args_html":"(other : Color) : Bool","location":{"filename":"src/cr-image/color.cr","line_number":93,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L93"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Color"}],"return_type":"Bool","visibility":"Public","body":"(((red == other.red) && (green == other.green)) && (blue == other.blue)) && (alpha == other.alpha)"}},{"html_id":"[](channel_type:ChannelType):UInt8-instance-method","name":"[]","doc":"Receive the UInt8 portion of this color corresponding to `channel_type`","summary":"

Receive the UInt8 portion of this color corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : UInt8","args_html":"(channel_type : ChannelType) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L29"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"UInt8","visibility":"Public","body":"case channel_type\nin ChannelType::Red\n red\nin ChannelType::Green\n green\nin ChannelType::Blue\n blue\nin ChannelType::Alpha\n alpha\nin ChannelType::Gray\n gray\nend"}},{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"alpha","visibility":"Public","body":"@alpha"}},{"html_id":"blue:UInt8-instance-method","name":"blue","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"html_id":"dist(other:Color,*,manhattan:Bool=false):Float64-instance-method","name":"dist","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"args_string":"(other : Color, *, manhattan : Bool = false) : Float64","args_html":"(other : Color, *, manhattan : Bool = false) : Float64","location":{"filename":"src/cr-image/color.cr","line_number":100,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L100"},"def":{"name":"dist","args":[{"name":"other","external_name":"other","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"manhattan","default_value":"false","external_name":"manhattan","restriction":"Bool"}],"splat_index":1,"return_type":"Float64","visibility":"Public","body":"if manhattan\n ((red.to_f - other.red).abs + (blue.to_i - other.blue).abs) + (green.to_i - other.green).abs\nelse\n Math.sqrt((((red.to_i - other.red) ** 2) + ((green.to_i - other.green) ** 2)) + ((blue.to_i - other.blue) ** 2))\nend"}},{"html_id":"gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):UInt8-instance-method","name":"gray","doc":"Convert this Color to a single UInt8 gray value","summary":"

Convert this Color to a single UInt8 gray value

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8","location":{"filename":"src/cr-image/color.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L22"},"def":{"name":"gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"UInt8","visibility":"Public","body":"Math.min(255_u8, (((red * red_multiplier) + (blue * blue_multiplier)) + (green * green_multiplier)).to_u8)"}},{"html_id":"green:UInt8-instance-method","name":"green","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"green","visibility":"Public","body":"@green"}},{"html_id":"red:UInt8-instance-method","name":"red","abstract":false,"location":{"filename":"src/cr-image/color.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"Crystal Image/CrImage/ComplexMap","path":"CrImage/ComplexMap.html","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":606,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L606"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"instance_methods":[{"html_id":"ifft:FloatMap-instance-method","name":"ifft","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":609,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L609"},"def":{"name":"ifft","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, (FftUtil.ifft2d(width, raw)).map(&.real))"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":613,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L613"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"self"}},{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":621,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L621"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to FloatMap\"))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":617,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L617"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"raise(Exception.new(\"Unable to convert ComplexMap to IntMap\"))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":607,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L607"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/EdgePolicy","path":"CrImage/EdgePolicy.html","kind":"enum","full_name":"CrImage::EdgePolicy","name":"EdgePolicy","abstract":false,"ancestors":[{"html_id":"Crystal Image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"Crystal Image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/edge_policy.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Black","name":"Black","value":"0"},{"id":"Repeat","name":"Repeat","value":"1"},{"id":"None","name":"None","value":"2"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A general enum for determining behavior around edges of `Image` or `Map`s. See also `Operator::Pad`","summary":"

A general enum for determining behavior around edges of Image or Maps.

","instance_methods":[{"html_id":"black?-instance-method","name":"black?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L4"},"def":{"name":"black?","visibility":"Public","body":"self == Black"}},{"html_id":"none?-instance-method","name":"none?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L6"},"def":{"name":"none?","visibility":"Public","body":"self == None"}},{"html_id":"repeat?-instance-method","name":"repeat?","abstract":false,"location":{"filename":"src/cr-image/edge_policy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/edge_policy.cr#L5"},"def":{"name":"repeat?","visibility":"Public","body":"self == Repeat"}}]},{"html_id":"Crystal Image/CrImage/ErrorView","path":"CrImage/ErrorView.html","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L61"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of teh underlying `Map` causes an error","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of teh underlying Map causes an error

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = ErrorView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":62,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L62"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = (x - @half_width) + @map_x\nadjusted_y = (y - @half_height) + @map_y\nif (adjusted_x < 0 || adjusted_x >= @map.width) || (adjusted_y < 0 || adjusted_y >= @map.height)\n raise(Exception.new(\"Coordinates #{x}, #{y} correspond to #{adjusted_x}, #{adjusted_y} in sliding window sized #{width}x#{height} centered at #{@map_x}, #{@map_y}, which is outside\"))\nend\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"Crystal Image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/exception.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Exception class for any errors thrown by CrImage","summary":"

Exception class for any errors thrown by CrImage

","constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/cr-image/exception.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L5"},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(error_code:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"args_string":"(error_code : Int32)","args_html":"(error_code : Int32)","location":{"filename":"src/cr-image/exception.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L9"},"def":{"name":"new","args":[{"name":"error_code","external_name":"error_code","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(error_code)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(handle:LibJPEGTurbo::Handle)-class-method","name":"new","abstract":false,"args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"args_string":"(handle : LibJPEGTurbo::Handle)","args_html":"(handle : LibJPEGTurbo::Handle)","location":{"filename":"src/cr-image/exception.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L13"},"def":{"name":"new","args":[{"name":"handle","external_name":"handle","restriction":"LibJPEGTurbo::Handle"}],"visibility":"Public","body":"_ = allocate\n_.initialize(handle)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"error_code:Int32|Nil-instance-method","name":"error_code","abstract":false,"location":{"filename":"src/cr-image/exception.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"Crystal Image/CrImage/FftUtil","path":"CrImage/FftUtil.html","kind":"class","full_name":"CrImage::FftUtil","name":"FftUtil","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/fft_util.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Utility class for Fast Fourier Transforms\n\nAt some point in the future, this may be moved to its own shard.","summary":"

Utility class for Fast Fourier Transforms

","class_methods":[{"html_id":"fft1d(inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L59"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if buf = buffer\nelse\n buf = Array(Complex).new(inp.size) do\n Complex.zero\n end\nend\nFftUtil.fft1d(Array(Complex).new(inp.size) do |i|\n Complex.new(inp.unsafe_fetch(i))\nend, buf)\n"}},{"html_id":"fft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"fft1d","doc":"Perform Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be the same length as `inp`","summary":"

Perform Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L68"},"def":{"name":"fft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.fft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"fft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)|Slice(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"fft1d_unsafe","doc":"Calculates Fast Fourier Transform of `ret`. Uses and modifies `ret` in place.\n\nCan optionally pass in `buffer` which must be the same length as `inp`. This method makes no bound checks or error checks.","summary":"

Calculates Fast Fourier Transform of ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) | Slice(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L76"},"def":{"name":"fft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex) | Slice(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = (-Math::PI.i) / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret\n"}},{"html_id":"fft2d(width:Int32,inp:Array(Float64),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Float64), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L10"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Float64)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"FftUtil.fft2d(width, inp.map(&.to_c), buffer)"}},{"html_id":"fft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"fft2d","doc":"Perform Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L15"},"def":{"name":"fft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.fft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"fft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"fft2d_unsafe","doc":"Perform Fast Fourier Transform, using and rewriting `ret` for the output, as a 2 dimensional array with `width`. `buffer` must be an array\nof length at least the longer of `width` or `height` of the input array.","summary":"

Perform Fast Fourier Transform, using and rewriting ret for the output, as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L28"},"def":{"name":"fft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.fft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.fft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}},{"html_id":"ifft1d(inp:Array(Complex),buffer:Array(Complex)=inp.dup):Array(Complex)-class-method","name":"ifft1d","doc":"Perform Inverse Fast Fourier Transform on `inp`.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`.","summary":"

Perform Inverse Fast Fourier Transform on inp.

","abstract":false,"args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","args_html":"(inp : Array(Complex), buffer : Array(Complex) = inp.dup) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L165"},"def":{"name":"ifft1d","args":[{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"inp.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"if inp.size == inp.size.next_power_of_two\nelse\n raise(Exception.new(\"Input is of size #{inp.size}, which is not a power of 2 (next power of 2: #{inp.size.next_power_of_two})\"))\nend\nFftUtil.ifft1d_unsafe(inp.dup, buffer)\n"}},{"html_id":"ifft1d_unsafe(ret:Array(Complex)|Slice(Complex),buffer:Array(Complex)=ret.dup):Array(Complex)|Slice(Complex)-class-method","name":"ifft1d_unsafe","doc":"Perform Inverse Fast Fourier Transform on `ret`. Will use and overwrite the original values in `ret` to do so.\n\nCan optionally pass in `buffer` which must be at least the same size of `inp`. This method makes no bound checks or error checks.","summary":"

Perform Inverse Fast Fourier Transform on ret.

","abstract":false,"args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","args_html":"(ret : Array(Complex) | Slice(Complex), buffer : Array(Complex) = ret.dup) : Array(Complex) | Slice(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L173"},"def":{"name":"ifft1d_unsafe","args":[{"name":"ret","external_name":"ret","restriction":"Array(Complex) | Slice(Complex)"},{"name":"buffer","default_value":"ret.dup","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex) | Slice(Complex)","visibility":"Public","body":"shape = 1\nhalf = ret.size\nreal_half = (ret.size >> 1)\nwhile half > 1\n double_half = half\n half = half >> 1\n neg_i_pi_div_shape = Math::PI.i / shape\n buffer.to_unsafe.copy_from(ret.to_unsafe, ret.size)\n half_offset = half\n shape.times do |i|\n term = Math.exp(neg_i_pi_div_shape * i)\n half.times do |j|\n offset = j + half_offset\n buffer.unsafe_put(offset, (buffer.unsafe_fetch(offset)) * term)\n end\n half_offset = half_offset + double_half\n end\n offset = -1\n counter = -1\n real_half.times do |i|\n offset = offset + 1\n counter = counter + 1\n if counter == half\n counter = 0\n offset = offset + half\n end\n ret.unsafe_put(i, (buffer.unsafe_fetch(offset)) + (buffer.unsafe_fetch(offset + half)))\n ret.unsafe_put(i + real_half, (buffer.unsafe_fetch(offset)) - (buffer.unsafe_fetch(offset + half)))\n end\n shape = shape << 1\nend\nret.map!(&./(ret.size))\n"}},{"html_id":"ifft2d(width:Int32,inp:Array(Complex),buffer:Array(Complex)|Nil=nil):Array(Complex)-class-method","name":"ifft2d","doc":"Perform Inverse Fast Fourier Transform, treating as `inp` as a 2 dimensional array with `width`.\n\nCan optionally pass in `buffer` which must be an array at least the larger of `width` or `inp.size // width`.","summary":"

Perform Inverse Fast Fourier Transform, treating as inp as a 2 dimensional array with width.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"args_string":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","args_html":"(width : Int32, inp : Array(Complex), buffer : Array(Complex) | Nil = nil) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":124,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L124"},"def":{"name":"ifft2d","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"inp","external_name":"inp","restriction":"Array(Complex)"},{"name":"buffer","default_value":"nil","external_name":"buffer","restriction":"Array(Complex) | ::Nil"}],"return_type":"Array(Complex)","visibility":"Public","body":"if width == width.next_power_of_two\nelse\n raise(Exception.new(\"Width #{width} must be power of 2 (next power of two: #{width.next_power_of_two})\"))\nend\nheight = inp.size // width\nif height == height.next_power_of_two\nelse\n raise(Exception.new(\"Input height #{height} must be power of 2 (next power of two: #{(height).next_power_of_two})\"))\nend\nif buf = buffer\nelse\n buf = Array(Complex).new(Math.max(width, inp.size // width)) do\n Complex.zero\n end\nend\nFftUtil.ifft2d_unsafe(width, inp.dup, buf)\n"}},{"html_id":"ifft2d_unsafe(width:Int32,ret:Array(Complex),buffer:Array(Complex)):Array(Complex)-class-method","name":"ifft2d_unsafe","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"args_string":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","args_html":"(width : Int32, ret : Array(Complex), buffer : Array(Complex)) : Array(Complex)","location":{"filename":"src/cr-image/fft_util.cr","line_number":135,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/fft_util.cr#L135"},"def":{"name":"ifft2d_unsafe","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"ret","external_name":"ret","restriction":"Array(Complex)"},{"name":"buffer","external_name":"buffer","restriction":"Array(Complex)"}],"return_type":"Array(Complex)","visibility":"Public","body":"height = ret.size // width\nheight_buffer = Array(Complex).new(height) do\n Complex.zero\nend\nbeginning = -width\nheight.times do\n beginning = beginning + width\n slice = Slice(Complex).new(ret.to_unsafe + beginning, width)\n FftUtil.ifft1d_unsafe(slice, buffer)\nend\nwidth.times do |x|\n spot = 0\n height.times do |i|\n height_buffer.unsafe_put(i, ret.unsafe_fetch(spot + x))\n spot = spot + width\n end\n FftUtil.ifft1d_unsafe(height_buffer, buffer)\n spot = 0\n height.times do |i|\n ret.unsafe_put(spot + x, height_buffer.unsafe_fetch(i))\n spot = spot + width\n end\nend\nret\n"}}]},{"html_id":"Crystal Image/CrImage/FloatMap","path":"CrImage/FloatMap.html","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":508,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L508"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Float64` types.","summary":"

Implementation of MapImpl for Float64 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":519,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L519"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"self"}},{"html_id":"to_f64:self-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":511,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L511"},"def":{"name":"to_f64","return_type":"self","visibility":"Public","body":"self"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":515,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L515"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":509,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L509"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Format","path":"CrImage/Format.html","kind":"module","full_name":"CrImage::Format","name":"Format","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}, {extension: \".png\", method: \"png\"}, {extension: \".jpeg\", method: \"jpeg\"}, {extension: \".jpg\", method: \"jpeg\"}, {extension: \".png\", method: \"png\"}, {extension: \".webp\", method: \"webp\"}] of Nil"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Provides a convenience method for saving image files to the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage.save(\"image.jpg\")\n```\nSee `Open` for a convenience method to read images from the filesystem","summary":"

Provides a convenience method for saving image files to the filesystem.

","types":[{"html_id":"Crystal Image/CrImage/Format/JPEG","path":"CrImage/Format/JPEG.html","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG","abstract":false,"locations":[{"filename":"src/lib-formats/jpeg.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/jpeg.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to jpeg. Requires `libturbojpeg` to function.\n\n```\nimage = File.open(\"image.jpg\") { |file| CrImage::RGBAImage.from_jpeg(file) }\nFile.open(\"other_image.jpg\") { |file| image.to_jpeg(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\nimage.save(\"other_image.jpg\")\n```","summary":"

Provides methods to read from and write to jpeg.

","instance_methods":[{"html_id":"to_jpeg(io:IO,quality:Int32=100):Nil-instance-method","name":"to_jpeg","doc":"Output the image as JPEG to `io`","summary":"

Output the image as JPEG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, quality : Int32 = 100) : Nil","args_html":"(io : IO, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/jpeg.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/jpeg.cr#L74"},"def":{"name":"to_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"handle = LibJPEGTurbo.init_compress\nimage_data = IO::Memory.new(size * 3)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\nend\nbuffer = Pointer(UInt8).null\ncheck_jpeg(handle, LibJPEGTurbo.compress2(handle, image_data.buffer, @width, 0, @height, LibJPEGTurbo::PixelFormat::RGB, pointerof(buffer), out size, LibJPEGTurbo::Subsampling::S444, quality, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibJPEGTurbo.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Open","path":"CrImage/Format/Open.html","kind":"module","full_name":"CrImage::Format::Open","name":"Open","abstract":false,"locations":[{"filename":"src/cr-image/format/open.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/open.cr#L12"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides a convenience method for opening up image files from the filesystem.\nCurrently supports:\n* PPM (`.ppm`)\n* WebP (`.webp`)\n* JPEG (`.jpeg`, `.jpg`)\n* PNG (`.png`)\n\n```\nimage = CrImage::RGBAImage.open(\"image.jpg\")\n```\nSee `Save` for a convenience method to write to the filesystem.","summary":"

Provides a convenience method for opening up image files from the filesystem.

","instance_methods":[{"html_id":"open(filename:String):self-instance-method","name":"open","doc":"Reads this image from file using the provided filename.","summary":"

Reads this image from file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/open.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/open.cr#L14"},"def":{"name":"open","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"{% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then File.open(filename) { |file| self.from_{{ format[:method].id }}(file) }\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\nend.join(\", \")).id }}\"\n end\n {% end %}"}}]},{"html_id":"Crystal Image/CrImage/Format/PNG","path":"CrImage/Format/PNG.html","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG","abstract":false,"locations":[{"filename":"src/cr-image/format/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/png.cr#L15"},{"filename":"src/lib-formats/png.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/png.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PNG. Requires `libspng` to function.\n\n```\nimage = File.open(\"image.png\") { |file| CrImage::RGBAImage.from_png(file) }\nFile.open(\"other_image.png\") { |file| image.to_png(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.png\")\nimage.save(\"other_image.png\")\n```","summary":"

Provides methods to read from and write to PNG.

","instance_methods":[{"html_id":"to_png(io:IO):Nil-instance-method","name":"to_png","doc":"Output the image as PNG to `io`","summary":"

Output the image as PNG to io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/lib-formats/png.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/png.cr#L72"},"def":{"name":"to_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::Encoder)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_option(ctx, LibSPNG::Option::EncodeToBuffer, true)\nLibSPNG.set_png_buffer(ctx, image_data.buffer, image_data.size)\nihdr = LibSPNG::IHDR.new\nihdr.width = @width\nihdr.height = @height\nihdr.color_type = LibSPNG::ColorType::TrueColorAlpha\nihdr.bit_depth = 8\nLibSPNG.set_ihdr(ctx, pointerof(ihdr))\nerror = LibSPNG.encode_image(ctx, image_data.buffer, image_data.size, LibSPNG::Format::PNG, LibSPNG::EncodeFlags::Finalize)\ncheck_png(error)\nbuffer = LibSPNG.get_png_buffer(ctx, out size, pointerof(error))\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to get a buffer\"))\nend\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibC.free(buffer)\n"}}]},{"html_id":"Crystal Image/CrImage/Format/PPM","path":"CrImage/Format/PPM.html","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM","abstract":false,"locations":[{"filename":"src/cr-image/format/ppm.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/ppm.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to PPM.\n\n```\nimage = File.open(\"image.ppm\") { |file| CrImage::RGBAImage.from_ppm(file) }\nFile.open(\"other_image.ppm\") { |file| image.to_ppm(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.ppm\")\nimage.save(\"other_image.ppm\")\n```","summary":"

Provides methods to read from and write to PPM.

","instance_methods":[{"html_id":"to_ppm(io:IO):Nil-instance-method","name":"to_ppm","doc":"Output this image to `io` using PPM image encoding","summary":"

Output this image to io using PPM image encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","args_html":"(io : IO) : Nil","location":{"filename":"src/cr-image/format/ppm.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/ppm.cr#L56"},"def":{"name":"to_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"Nil","visibility":"Public","body":"io << \"P6\\n\"\n(((io << @width) << \" \") << @height) << \"\\n\"\nio << \"255\\n\"\nsize.times do |index|\n io.write_byte(red.unsafe_fetch(index))\n io.write_byte(green.unsafe_fetch(index))\n io.write_byte(blue.unsafe_fetch(index))\nend\n"}}]},{"html_id":"Crystal Image/CrImage/Format/Save","path":"CrImage/Format/Save.html","kind":"module","full_name":"CrImage::Format::Save","name":"Save","abstract":false,"locations":[{"filename":"src/cr-image/format/save.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"instance_methods":[{"html_id":"save(filename:String):self-instance-method","name":"save","doc":"Write this image to file using the provided filename.\n\nThis method _will not_ create intermediate directory paths. This method will throw an\nerror if they don't exist.","summary":"

Write this image to file using the provided filename.

","abstract":false,"args":[{"name":"filename","external_name":"filename","restriction":"String"}],"args_string":"(filename : String) : self","args_html":"(filename : String) : self","location":{"filename":"src/cr-image/format/save.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/format/save.cr#L20"},"def":{"name":"save","args":[{"name":"filename","external_name":"filename","restriction":"String"}],"return_type":"self","visibility":"Public","body":"File.open(filename, \"w\") do |file|\n {% if true %}\n case filename\n {% for format in SUPPORTED_FORMATS %}\n when .ends_with?({{ format[:extension] }}) then to_{{ format[:method].id }}(file)\n {% end %}\n else raise Exception.new \"Unknown file extension for filename #{filename}, cr-image only supports {{ (CrImage::Format::SUPPORTED_FORMATS.map() do |__arg0|\n __arg0[:extension].id\n end.join(\", \")).id }}\"\n end\n {% end %}\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Format/WebP","path":"CrImage/Format/WebP.html","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP","abstract":false,"locations":[{"filename":"src/lib-formats/webp.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/webp.cr#L15"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Format","kind":"module","full_name":"CrImage::Format","name":"Format"},"doc":"Provides methods to read from and write to WebP. Requires `libwebp` to function.\n\n```\nimage = File.open(\"image.webp\") { |file| CrImage::RGBAImage.from_webp(file) }\nFile.open(\"other_image.webp\") { |file| image.to_webp(file) }\n```\nAlternatively, you can use the convenience methods in the `Open` and `Save` modules\nto acheive the same thing:\n```\nimage = CrImage::RGBAImage.open(\"image.webp\")\nimage.save(\"other_image.webp\")\n```","summary":"

Provides methods to read from and write to WebP.

","instance_methods":[{"html_id":"to_webp(io:IO,*,lossy:Bool=false,quality:Int32=100):Nil-instance-method","name":"to_webp","doc":"Write image to `io` using WebP encoding","summary":"

Write image to io using WebP encoding

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"args_string":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","args_html":"(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil","location":{"filename":"src/lib-formats/webp.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/lib-formats/webp.cr#L59"},"def":{"name":"to_webp","args":[{"name":"io","external_name":"io","restriction":"IO"},{"name":"","external_name":"","restriction":""},{"name":"lossy","default_value":"false","external_name":"lossy","restriction":"Bool"},{"name":"quality","default_value":"100","external_name":"quality","restriction":"Int32"}],"splat_index":1,"return_type":"Nil","visibility":"Public","body":"image_data = IO::Memory.new(size * 4)\nsize.times do |index|\n image_data.write_byte(red.unsafe_fetch(index))\n image_data.write_byte(green.unsafe_fetch(index))\n image_data.write_byte(blue.unsafe_fetch(index))\n image_data.write_byte(alpha.unsafe_fetch(index))\nend\nsize, buffer = lossy ? lossy_encode(image_data, quality) : lossless_encode(image_data)\ncheck_webp(size)\nbytes = Bytes.new(buffer, size)\nio.write(bytes)\nLibWebP.free(buffer)\n"}}]}]},{"html_id":"Crystal Image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L13"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L42"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L38"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image in Grayscale. These image types are the easiest to perform feature and information extraction from, where\nthere is only one channel to examine, and so has methods for constructing `Mask`s from (see `#threshold` below).\n\nAn `RGBAImage` would become a `GrayscaleImage` this way:\n```\nimage.to_gray\n```\n\n\"Woman\n\"Woman","summary":"

An image in Grayscale.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage from a set of color channels (delegates to `RGBAImage#to_gray`)","summary":"

Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray)

","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L20"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"},{"name":"green","external_name":"green","restriction":"Array(UInt8)"},{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"},{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"(RGBAImage.new(red, green, blue, alpha, width, height)).to_gray"}},{"html_id":"new(gray:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L24"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32, height : Int32)","args_html":"(gray : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(gray:Array(UInt8),width:Int32)-class-method","name":"new","doc":"Create a GrayscaleImage with only an `Array(UInt8)` (alpha channel initialized as `255` throughout)","summary":"

Create a GrayscaleImage with only an Array(UInt8) (alpha channel initialized as 255 throughout)

","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"args_string":"(gray : Array(UInt8), width : Int32)","args_html":"(gray : Array(UInt8), width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L38"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, width)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"<(*args,**options)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.<(*args, **options)"}},{"html_id":"<(*args,**options,&)-instance-method","name":"<","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.<(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"<=(arg)-instance-method","name":"<=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"<=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! <= arg"}},{"html_id":"==(arg)-instance-method","name":"==","doc":"Returns `false` (other can only be a `Value` here).","summary":"

Returns false (other can only be a Value here).

","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"==","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! == arg"}},{"html_id":">(*args,**options)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.>(*args, **options)"}},{"html_id":">(*args,**options,&)-instance-method","name":">","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.>(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":">=(arg)-instance-method","name":">=","abstract":false,"args":[{"name":"arg","external_name":"arg","restriction":""}],"args_string":"(arg)","args_html":"(arg)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":">=","args":[{"name":"arg","external_name":"arg","restriction":""}],"visibility":"Public","body":"to_map! >= arg"}},{"html_id":"[](x:Int32,y:Int32):Pixel-instance-method","name":"[]","doc":"Return a `Pixel` representing this cell in the image.","summary":"

Return a Pixel representing this cell in the image.

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Pixel","args_html":"(x : Int32, y : Int32) : Pixel","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Pixel","visibility":"Public","body":"index = (y * width) + x\nPixel.new(gray[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the `Array(UInt8)` corresponding to `channel_type`","summary":"

Return the Array(UInt8) corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L97"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"if channel_type == ChannelType::Alpha\n return @alpha\nend\n@gray\n"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the underlying `Array(UInt8)` of `channel_type` to the new `channel`.\n\nWarning: this method does not check the size of the incoming array, and if it's a different\nsize from what the current image represents, this could break it. We recommend against using\nthis method except for from other methods that will be updating the `width` and `height` immediately after.","summary":"

Set the underlying Array(UInt8) of channel_type to the new channel.

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L107"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Gray\n self.gray = channel\nwhen ChannelType::Alpha\n self.alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for GrayscaleImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return `alpha` channel","summary":"

Return #alpha channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":69,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L69"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L15"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the \"`blue`\" channel (returns `gray`)","summary":"

Return the "#blue" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L64"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"clone:GrayscaleImage-instance-method","name":"clone","doc":"Create a new GrayscaleImage as a copy of this one","summary":"

Create a new GrayscaleImage as a copy of this one

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L44"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone, @width, @height)"}},{"html_id":"cross_correlate(map:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(map : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":221,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L221"},"def":{"name":"cross_correlate","args":[{"name":"map","external_name":"map","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"to_imap.cross_correlate(map, edge_policy: edge_policy)"}},{"html_id":"cross_correlate(*args,**options)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options)"}},{"html_id":"cross_correlate(*args,**options,&)-instance-method","name":"cross_correlate","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"cross_correlate","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.cross_correlate(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"cross_correlate_fft(map:Map)-instance-method","name":"cross_correlate_fft","abstract":false,"args":[{"name":"map","external_name":"map","restriction":"Map"}],"args_string":"(map : Map)","args_html":"(map : Map)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":225,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L225"},"def":{"name":"cross_correlate_fft","args":[{"name":"map","external_name":"map","restriction":"Map"}],"visibility":"Public","body":"to_imap.cross_correlate_fft(map)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L80"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Gray` channels and channel types.","summary":"

Run provided block with the ChannelType::Gray channels and channel types.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L74"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @gray, ChannelType::Gray\nnil\n"}},{"html_id":"gray:Array(UInt8)-instance-method","name":"gray","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"gray=(gray:Array(UInt8))-instance-method","name":"gray=","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"args_string":"(gray : Array(UInt8))","args_html":"(gray : Array(UInt8))","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L14"},"def":{"name":"gray=","args":[{"name":"gray","external_name":"gray","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@gray = gray"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the \"`green`\" channel (returns `gray`)","summary":"

Return the "#green" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L59"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L17"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"invert-instance-method","name":"invert","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`).\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":171,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L171"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert grayscale pixels (replace each pixel will `255 - p` for all `p` in `@gray`). Modifies self.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Invert grayscale pixels (replace each pixel will 255 - p for all p in @gray).

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L182"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(*args,**options)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mask_from(*args, **options)"}},{"html_id":"mask_from(*args,**options,&)-instance-method","name":"mask_from","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mask_from","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mask_from(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"mean(*args,**options)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_map!.mean(*args, **options)"}},{"html_id":"mean(*args,**options,&)-instance-method","name":"mean","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":204,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L204"},"def":{"name":"mean","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_map!.mean(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the \"`red`\" channel (returns `gray`)","summary":"

Return the "#red" channel (returns #gray)

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L54"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@gray"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels this image contains","summary":"

Return the number of pixels this image contains

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":160,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"threshold(threshold:Int):Mask-instance-method","name":"threshold","doc":"Construct a simple threshold `Mask` containing all pixels with a `UInt8` value greater than `threshold`\nGiven sample image:\n\n\"Woman\n\n```\nimage\n .to_gray # convert color image to grayscale one\n .threshold(128) # generate a mask using threshold operator\n .to_gray # convert mask to grayscale image\n .save(\"threshold_example.jpg\") # save mask as grayscale\n```\n\"Black","summary":"

Construct a simple threshold Mask containing all pixels with a UInt8 value greater than #threshold Given sample image:

","abstract":false,"args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"args_string":"(threshold : Int) : Mask","args_html":"(threshold : Int) : Mask","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":200,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L200"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"self >= threshold"}},{"html_id":"to_a:Array(UInt8)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `Array(UInt8)` corresponding to the `ChannelType::Gray` channel","summary":"

Receive a copy of the underlying Array(UInt8) corresponding to the ChannelType::Gray channel

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":217,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L217"},"def":{"name":"to_a","return_type":"Array(UInt8)","visibility":"Public","body":"gray.dup"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":155,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L155"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"html_id":"to_imap:IntMap-instance-method","name":"to_imap","doc":"Convert this image into a `IntMap`","summary":"

Convert this image into a IntMap

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":207,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L207"},"def":{"name":"to_imap","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, gray.map(&.to_i))"}},{"html_id":"to_map!:UInt8Map-instance-method","name":"to_map!","doc":"Convert this image into a `UInt8Map`. Does not clone underlying `gray` channel, both this image and map share the same data.","summary":"

Convert this image into a UInt8Map.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":212,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L212"},"def":{"name":"to_map!","return_type":"UInt8Map","visibility":"Public","body":"UInt8Map.new(width, @gray)"}},{"html_id":"to_pluto:Pluto::ImageGA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L43"},"def":{"name":"to_pluto","return_type":"Pluto::ImageGA","visibility":"Public","body":"Pluto::ImageGA.new(gray.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba(color_map:Hash(UInt8,Color),*,default:Color=Color.default):RGBAImage-instance-method","name":"to_rgba","doc":"Convert this grayscale image to an RGBA one using the provided color map.\n\nThe provided map should have a key for all 0-255 possible gray pixel values, otherwise the `default`\n`Color` will be used instead (default is black).\n\n```\ncolors = 256.times.to_a.map { |i| {i.to_u8, CrImage::Color.random} }.to_h\ngray_image.to_rgba(colors).save(\"to_rgba_color_map_sample.jpg\")\n```\n\n\"Woman\n\nBecomes\n\n\"Random","summary":"

Convert this grayscale image to an RGBA one using the provided color map.

","abstract":false,"args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"args_string":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","args_html":"(color_map : Hash(UInt8, Color), *, default : Color = Color.default) : RGBAImage","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L137"},"def":{"name":"to_rgba","args":[{"name":"color_map","external_name":"color_map","restriction":"Hash(UInt8, Color)"},{"name":"","external_name":"","restriction":""},{"name":"default","default_value":"Color.default","external_name":"default","restriction":"Color"}],"splat_index":1,"return_type":"RGBAImage","visibility":"Public","body":"red = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\ngray.each do |pixel|\n color = color_map[pixel]? || default\n red << color.red\n green << color.green\n blue << color.blue\n alpha << color.alpha\nend\nRGBAImage.new(red, green, blue, alpha, width, height)\n"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Convert this `GrayscaleImage` to an `RGBAImage`.\n\nNo color will be provided, all pixels will remain gray.","summary":"

Convert this GrayscaleImage to an RGBAImage.

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":118,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L118"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L39"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.gray.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}],"types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage/Pixel","path":"CrImage/GrayscaleImage/Pixel.html","kind":"struct","full_name":"CrImage::GrayscaleImage::Pixel","name":"Pixel","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},"constructors":[{"html_id":"new(gray:UInt8,alpha:UInt8)-class-method","name":"new","abstract":false,"args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"args_string":"(gray : UInt8, alpha : UInt8)","args_html":"(gray : UInt8, alpha : UInt8)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"new","args":[{"name":"gray","external_name":"gray","restriction":"UInt8"},{"name":"alpha","external_name":"alpha","restriction":"UInt8"}],"visibility":"Public","body":"_ = allocate\n_.initialize(gray, alpha)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"alpha:UInt8-instance-method","name":"alpha","abstract":false,"def":{"name":"alpha","return_type":"UInt8","visibility":"Public","body":"@alpha"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@gray.clone, @alpha.clone)"}},{"html_id":"copy_with(gray_gray=@gray,alpha_alpha=@alpha)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"args_string":"(gray _gray = @gray, alpha _alpha = @alpha)","args_html":"(gray _gray = @gray, alpha _alpha = @alpha)","location":{"filename":"src/cr-image/grayscale_image.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/grayscale_image.cr#L86"},"def":{"name":"copy_with","args":[{"name":"_gray","default_value":"@gray","external_name":"gray","restriction":""},{"name":"_alpha","default_value":"@alpha","external_name":"alpha","restriction":""}],"visibility":"Public","body":"self.class.new(_gray, _alpha)"}},{"html_id":"gray:UInt8-instance-method","name":"gray","abstract":false,"def":{"name":"gray","return_type":"UInt8","visibility":"Public","body":"@gray"}}]}]},{"html_id":"Crystal Image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Common base class for `GrayscaleImage` and `RGBAImage`. All `Image`s are readable and saveable\nto the filesystem or `IO` stream.","summary":"

Common base class for GrayscaleImage and RGBAImage.

","instance_methods":[{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Get the `Array(UInt8)` corresponding to `channel_type`)","summary":"

Get the Array(UInt8) corresponding to channel_type)

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":57,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L57"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the `Array(UInt8)` corresponding to `channel_type`) to `channel`","summary":"

Set the Array(UInt8) corresponding to channel_type) to channel

","abstract":true,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/image.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L59"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L42"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":40,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L40"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L54"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block on each channel supported by this image.","summary":"

Run provided block on each channel supported by this image.

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":51,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L51"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L38"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L46"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L36"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size (total pixels) in image (`width` * `height`)","summary":"

Size (total pixels) in image (#width * #height)

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":48,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L48"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":true,"location":{"filename":"src/cr-image/image.cr","line_number":44,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L44"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}],"macros":[{"html_id":"subsclasses_include(mod)-macro","name":"subsclasses_include","abstract":false,"args":[{"name":"mod","external_name":"mod","restriction":""}],"args_string":"(mod)","args_html":"(mod)","location":{"filename":"src/cr-image/image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/image.cr#L4"},"def":{"name":"subsclasses_include","args":[{"name":"mod","external_name":"mod","restriction":""}],"visibility":"Public","body":" \n{% for sub in @type.subclasses %}\n class ::{{ sub }}\n include {{ mod }}\n end\n {% end %}\n\n \n"}}]},{"html_id":"Crystal Image/CrImage/IntMap","path":"CrImage/IntMap.html","kind":"class","full_name":"CrImage::IntMap","name":"IntMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L478"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `Int32` types.","summary":"

Implementation of MapImpl for Int32 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":485,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L485"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"to_f64"}},{"html_id":"to_f64:FloatMap-instance-method","name":"to_f64","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":481,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L481"},"def":{"name":"to_f64","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f64))"}},{"html_id":"to_i:self-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":489,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L489"},"def":{"name":"to_i","return_type":"self","visibility":"Public","body":"self"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":479,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L479"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Map","path":"CrImage/Map.html","kind":"module","full_name":"CrImage::Map(T)","name":"Map","abstract":false,"locations":[{"filename":"src/cr-image/map.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L3"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/Mask","kind":"class","full_name":"CrImage::Mask","name":"Mask"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/OneMap","kind":"class","full_name":"CrImage::OneMap","name":"OneMap"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An interface for 2 dimensional data. Used for various masking and correlation methods.","summary":"

An interface for 2 dimensional data.

","instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L9"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L8"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L11"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","abstract":true,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L10"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":""}},{"html_id":"height:Int32-instance-method","name":"height","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L5"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L7"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":""}},{"html_id":"size:Int32-instance-method","name":"size","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L6"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":""}},{"html_id":"width:Int32-instance-method","name":"width","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L4"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/MapImpl","path":"CrImage/MapImpl.html","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":45,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L45"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"}],"including_types":[{"html_id":"Crystal Image/CrImage/ComplexMap","kind":"class","full_name":"CrImage::ComplexMap","name":"ComplexMap"},{"html_id":"Crystal Image/CrImage/FloatMap","kind":"class","full_name":"CrImage::FloatMap","name":"FloatMap"},{"html_id":"Crystal Image/CrImage/IntMap","kind":"class","full_name":"CrImage::IntMap","name":"IntMap"},{"html_id":"Crystal Image/CrImage/UInt8Map","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"A collection of implementations of `NumericMap(T)`, intended to be included in base classes.\n\nSee `IntMap`, `FloatMap`, and `ComplexMap`.","summary":"

A collection of implementations of NumericMap(T), intended to be included in base classes.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:T)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"args_string":"(width : Int32, height : Int32, initial : T)","args_html":"(width : Int32, height : Int32, initial : T)","location":{"filename":"src/cr-image/map.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L82"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","external_name":"initial","restriction":"T"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,raw:Array(T))-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"args_string":"(width : Int32, raw : Array(T))","args_html":"(width : Int32, raw : Array(T))","location":{"filename":"src/cr-image/map.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L63"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"raw","external_name":"raw","restriction":"Array(T)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other:Array(Array(T)))-class-method","name":"new","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"args_string":"(other : Array(Array(T)))","args_html":"(other : Array(Array(T)))","location":{"filename":"src/cr-image/map.cr","line_number":67,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L67"},"def":{"name":"new","args":[{"name":"other","external_name":"other","restriction":"Array(Array(T))"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &)","args_html":"(width : Int32, height : Int32, &)","location":{"filename":"src/cr-image/map.cr","line_number":76,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L76"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":1,"block_arity":1,"visibility":"Public","body":"_ = allocate\n_.initialize(width, height) do |_arg0|\n yield _arg0\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"*(num:Int|Float):self-instance-method","name":"*","doc":"Multiply each point in this `Map` by `num`","summary":"

Multiply each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":284,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L284"},"def":{"name":"*","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i * num\nend)"}},{"html_id":"+(num:Int|Float):self-instance-method","name":"+","doc":"Add each point in this `Map` by `num`","summary":"

Add each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : self","args_html":"(num : Int | Float) : self","location":{"filename":"src/cr-image/map.cr","line_number":289,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L289"},"def":{"name":"+","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i + num\nend)"}},{"html_id":"+(other:self):self-instance-method","name":"+","doc":"Add each point of this `Map` with each point in `other`","summary":"

Add each point of this Map with each point in other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : self","args_html":"(other : self) : self","location":{"filename":"src/cr-image/map.cr","line_number":304,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L304"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Dimensions should match (caller: #{width}x#{height}, callee: #{other.width}x#{other.height})\"))\nend\nself.class.new(width, @raw.map_with_index do |val, i|\n val + other[i]\nend)\n"}},{"html_id":"-(other:NumericMap(T)):self-instance-method","name":"-","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : self","args_html":"(other : NumericMap(T)) : self","location":{"filename":"src/cr-image/map.cr","line_number":196,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L196"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"self","visibility":"Public","body":"if (width == other.width) && (height == other.height)\nelse\n raise(Exception.new(\"Unable to subtract a map of different dimensions: #{width}x#{height} vs #{other.width}x#{other.height}\"))\nend\nself.class.new(width, raw.map_with_index do |v, i|\n v - other.raw[i]\nend)\n"}},{"html_id":"-(num:Int):self-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int"}],"args_string":"(num : Int) : self","args_html":"(num : Int) : self","location":{"filename":"src/cr-image/map.cr","line_number":294,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L294"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Int"}],"return_type":"self","visibility":"Public","body":"self.class.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"-(num:Float):FloatMap-instance-method","name":"-","doc":"Subtract each point in this `Map` by `num`","summary":"

Subtract each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Float"}],"args_string":"(num : Float) : FloatMap","args_html":"(num : Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":299,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L299"},"def":{"name":"-","args":[{"name":"num","external_name":"num","restriction":"Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i - num\nend)"}},{"html_id":"/(num:Int|Float):FloatMap-instance-method","name":"/","doc":"Divides each point in this `Map` by `num`\n\nTODO: ComplexMap shouldn't return a FloatMap","summary":"

Divides each point in this Map by num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : FloatMap","args_html":"(num : Int | Float) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":279,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L279"},"def":{"name":"/","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map do |i|\n i / num\nend)"}},{"html_id":"<(num:Int|Float):Mask-instance-method","name":"<","doc":"Construct a `Mask` identifying all pixels smaller than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray < 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels smaller than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":257,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L257"},"def":{"name":"<","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val < num\nend"}},{"html_id":"<=(num:Int|Float):Mask-instance-method","name":"<=","doc":"Construct a `Mask` identifying all pixels smaller than or equal to `num`. See `#<` for example.","summary":"

Construct a Mask identifying all pixels smaller than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":262,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L262"},"def":{"name":"<=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val <= num\nend"}},{"html_id":"==(num:Int|Float):Mask-instance-method","name":"==","doc":"Construct a `Mask` identifying all pixels equal to `num`","summary":"

Construct a Mask identifying all pixels equal to num

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":267,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L267"},"def":{"name":"==","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val == num\nend"}},{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Check if this `Map` is equal to `other`","summary":"

Check if this Map is equal to other

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/cr-image/map.cr","line_number":272,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L272"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"(other.width == width) && (@raw == other.raw)"}},{"html_id":">(num:Int|Float):Mask-instance-method","name":">","doc":"Construct a `Mask` identifying all pixels larger than `num`.\n\n\"Woman\n\n```\ngray = image.to_gray # Convert color image to grayscale\nmask = gray > 128 # Generate a threshold mask\nmask.to_gray.save(\"greater_than_example.jpg\") # Convert and save the mask as a black and white image\n```\n\"Black","summary":"

Construct a Mask identifying all pixels larger than num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":238,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L238"},"def":{"name":">","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val > num\nend"}},{"html_id":">=(num:Int|Float):Mask-instance-method","name":">=","doc":"Construct a `Mask` identify all pixels larger than or equal to `num`. See `#>` for near example.","summary":"

Construct a Mask identify all pixels larger than or equal to num.

","abstract":false,"args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"args_string":"(num : Int | Float) : Mask","args_html":"(num : Int | Float) : Mask","location":{"filename":"src/cr-image/map.cr","line_number":243,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L243"},"def":{"name":">=","args":[{"name":"num","external_name":"num","restriction":"Int | Float"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |val|\n val >= num\nend"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):self-instance-method","name":"[]","doc":"Crop the map to the values contained from `xstart` out by `xcount`, and `ystart` out by `ycount`","summary":"

Crop the map to the values contained from xstart out by xcount, and ystart out by ycount

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":152,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L152"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, xcount, ystart, ycount)"}},{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","doc":"Get element at coordinates `x` and `y`","summary":"

Get element at coordinates x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":106,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L106"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"if x >= width || x < 0\n raise(Exception.new(\"X coordinate #{x} is outside of Map width #{width}\"))\nend\nif y >= height || y < 0\n raise(Exception.new(\"Y coordinate #{y} is outside of Map height #{height}\"))\nend\nindex = (y * width) + x\nself[index]\n"}},{"html_id":"[](xrange:Range,ystart:Int32):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in row at `ystart`","summary":"

Crop the map, returning only the values in row at ystart

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : self","args_html":"(xrange : Range, ystart : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":137,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L137"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), ystart, 1)"}},{"html_id":"[](xstart:Int32,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map, returning only the values in column at `xstart`","summary":"

Crop the map, returning only the values in column at xstart

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : self","args_html":"(xstart : Int32, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":142,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L142"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(xstart, 1, *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","doc":"Crop the map to the values contained in `xrange` and `yrange`","summary":"

Crop the map to the values contained in xrange and yrange

","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/map.cr","line_number":147,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L147"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"internal_crop(*resolve_to_start_and_count(xrange, width), *resolve_to_start_and_count(yrange, height))"}},{"html_id":"[](index:Int32):T-instance-method","name":"[]","doc":"Get element at `index` from underlying `raw` Array.","summary":"

Get element at index from underlying #raw Array.

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T","args_html":"(index : Int32) : T","location":{"filename":"src/cr-image/map.cr","line_number":101,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L101"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"@raw[index]"}},{"html_id":"[]?(x:Int32,y:Int32):T|Nil-instance-method","name":"[]?","doc":"Get lement at coordinates `x` and `y`, or `nil` if coordinates are out of bounds","summary":"

Get lement at coordinates x and y, or nil if coordinates are out of bounds

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T | Nil","args_html":"(x : Int32, y : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":119,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L119"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"if x < 0 || x >= width\n return nil\nend\nif y < 0 || y >= height\n return nil\nend\nindex = (y * width) + x\n@raw[index]?\n"}},{"html_id":"[]?(index:Int32):T|Nil-instance-method","name":"[]?","doc":"Get element at `index`, or `nil` if out of bounds","summary":"

Get element at index, or nil if out of bounds

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : T | Nil","args_html":"(index : Int32) : T | Nil","location":{"filename":"src/cr-image/map.cr","line_number":114,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L114"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"T | ::Nil","visibility":"Public","body":"@raw[index]?"}},{"html_id":"column(x:Int32):self-instance-method","name":"column","doc":"Get a single dimensional `Map` representing teh column at `x`","summary":"

Get a single dimensional Map representing teh column at x

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"}],"args_string":"(x : Int32) : self","args_html":"(x : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":132,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L132"},"def":{"name":"column","args":[{"name":"x","external_name":"x","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(x, 1, 0, height)"}},{"html_id":"cross_correlate(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Repeat):FloatMap-instance-method","name":"cross_correlate","doc":"Perform a brute force cross correlation calculation with provided `template`.","summary":"

Perform a brute force cross correlation calculation with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Repeat) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":393,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L393"},"def":{"name":"cross_correlate","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Repeat","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"half_width = template.width >> 1\nhalf_height = template.height >> 1\nstart_x, start_y = (edge_policy.none? ? {half_width, half_height} : {0, 0})\nend_x, end_y = (edge_policy.none? ? {(width - half_width) - 1, (height - half_height) - 1} : {width - 1, height - 1})\nret = Array(Float64).new((end_x - start_x) * (end_y - start_y))\n(start_y.upto(end_y)).each do |y|\n (start_x.upto(end_x)).each do |x|\n view = case edge_policy\n in EdgePolicy::Repeat\n RepeatView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::Black\n BlackView(T).new(template.width, template.height, self, x, y)\n in EdgePolicy::None\n ErrorView(T).new(template.width, template.height, self, x, y)\n end\n ret << view.sum do |pixel, vx, vy|\n template[vx, vy] * pixel\n end\n end\nend\nretf = FloatMap.new((end_x - start_x) + 1, ret)\nretf\n"}},{"html_id":"cross_correlate_fft(template:Map,*,edge_policy:EdgePolicy=EdgePolicy::Black):FloatMap-instance-method","name":"cross_correlate_fft","doc":"Perform a Fast Fourier Transform cross correlation (convolution?) with provided `template`. See `FftUtil`","summary":"

Perform a Fast Fourier Transform cross correlation (convolution?) with provided template.

","abstract":false,"args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"args_string":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","args_html":"(template : Map, *, edge_policy : EdgePolicy = EdgePolicy::Black) : FloatMap","location":{"filename":"src/cr-image/map.cr","line_number":421,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L421"},"def":{"name":"cross_correlate_fft","args":[{"name":"template","external_name":"template","restriction":"Map"},{"name":"","external_name":"","restriction":""},{"name":"edge_policy","default_value":"EdgePolicy::Black","external_name":"edge_policy","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"FloatMap","visibility":"Public","body":"max_width, max_height = Math.pw2ceil(width + template.width), Math.pw2ceil(height + template.height)\npad_type = edge_policy.none? ? EdgePolicy::Black : edge_policy\nwidth_range, height_range = case edge_policy\nin EdgePolicy::Black, EdgePolicy::Repeat\n {(template.width)...(width + template.width), (template.height)...(height + template.height)}\nin EdgePolicy::None\n {(template.width + (template.width // 2))..(((template.width + width) - template.width) + 1), (template.height + (template.height // 2))..(((template.height + height) - template.height) + 1)}\nend\norig_pad_fft = pad(top: (template.height // 2) + (template.height % 2), bottom: (max_height - height) - ((template.height // 2) + (template.height % 2)), right: (max_width - width) - ((template.width // 2) + (template.width % 2)), left: (template.width // 2) + (template.width % 2), pad_type: pad_type).to_c\nmap_pad_fft = template.pad(bottom: max_height - template.height, right: max_width - template.width).to_c\nbuffer = Array(Complex).new(Math.max(max_width, max_height)) do\n Complex.zero\nend\nFftUtil.fft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nFftUtil.fft2d_unsafe(max_width, map_pad_fft.raw, buffer)\norig_pad_fft.raw.map_with_index! do |o, i|\n o * map_pad_fft[i]\nend\nFftUtil.ifft2d_unsafe(max_width, orig_pad_fft.raw, buffer)\nret = (FloatMap.new(max_width, orig_pad_fft.raw.map(&.real)))[width_range, height_range]\nret\n"}},{"html_id":"fft:ComplexMap-instance-method","name":"fft","doc":"Performe a Fast Fourier Transform, padding out this `Map` so dimensions are a power of 2. See `FftUtil`","summary":"

Performe a Fast Fourier Transform, padding out this Map so dimensions are a power of 2.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":461,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L461"},"def":{"name":"fft","return_type":"ComplexMap","visibility":"Public","body":"map = pad(bottom: (Math.pw2ceil(height)) - height, right: (Math.pw2ceil(width)) - width).to_c\nbuffer = Array(Complex).new(Math.max(map.height, map.width)) do\n Complex.zero\nend\nComplexMap.new(map.width, FftUtil.fft2d_unsafe(map.width, map.raw, buffer))\n"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":86,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L86"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@raw.size // @width"}},{"html_id":"mask_from(&block:T,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","doc":"Construct a `Mask` from this `GrayscaleImage` using the passed in block to determine if a given pixel should be true or not\n\n```\n# Construct a mask identifying the bright pixels in the bottom left corner of image\nimage.to_gray.mask_from do |pixel, x, y|\n x < image.width // 2 && # left half of image\n y > (image.height // 2) && # bottom half of image\n pixel > 128 # only \"bright\" pixels\nend\n```\n\"Woman\n->\n\"Mask","summary":"

Construct a Mask from this GrayscaleImage using the passed in block to determine if a given pixel should be true or not

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":214,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L214"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(T, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(@raw[i], x, y)\nend)\n"}},{"html_id":"max:T-instance-method","name":"max","doc":"Return the maximum value in this `Map`","summary":"

Return the maximum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":187,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L187"},"def":{"name":"max","return_type":"T","visibility":"Public","body":"@raw.max"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Return the average of the elements in this `Map`","summary":"

Return the average of the elements in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":177,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L177"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@raw.sum / size"}},{"html_id":"min:T-instance-method","name":"min","doc":"Return the minimum value in this `Map`","summary":"

Return the minimum value in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":182,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L182"},"def":{"name":"min","return_type":"T","visibility":"Public","body":"@raw.min"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):self-instance-method","name":"pad","doc":"Pad the borders of this `Map` corresponding to `pad_type`.","summary":"

Pad the borders of this Map corresponding to pad_type.

","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : self","location":{"filename":"src/cr-image/map.cr","line_number":336,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L336"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"top = top > 0 ? top : all\nbottom = bottom > 0 ? bottom : all\nleft = left > 0 ? left : all\nright = right > 0 ? right : all\nnew_width = (left + width) + right\nnew_raw = initial_raw_pad(pad_type, new_width, top, bottom, left, right, pad_black_value)\nheight.times do |y|\n adjusted_y = y + top\n ((new_raw.to_unsafe + (adjusted_y * new_width)) + left).copy_from(raw.to_unsafe + (y * width), width)\nend\nif pad_type.repeat?\n if top > 0\n copy = new_raw[new_width * top, new_width]\n top.times do |i|\n new_raw[i * new_width, new_width] = copy\n end\n end\n if bottom > 0\n copy = new_raw[new_width * ((top + height) - 1), new_width]\n bottom.times do |i|\n new_raw[((i + top) + height) * new_width, new_width] = copy\n end\n end\nend\nself.class.new(new_width, new_raw)\n"}},{"html_id":"raw:Array(T)-instance-method","name":"raw","doc":"Return the raw array underlying the map","summary":"

Return the raw array underlying the map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":61,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L61"},"def":{"name":"raw","return_type":"Array(T)","visibility":"Public","body":"@raw"}},{"html_id":"row(y:Int32):self-instance-method","name":"row","doc":"Get a single dimensional `Map` representing the row at `y`","summary":"

Get a single dimensional Map representing the row at y

","abstract":false,"args":[{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(y : Int32) : self","args_html":"(y : Int32) : self","location":{"filename":"src/cr-image/map.cr","line_number":127,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L127"},"def":{"name":"row","args":[{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"internal_crop(0, width, y, 1)"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Return the shape of the map - `{width, height}`","summary":"

Return the shape of the map - {width, height}

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":91,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L91"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Size of the map - `width * height`","summary":"

Size of the map - width * height

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":96,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L96"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@raw.size"}},{"html_id":"sum:T-instance-method","name":"sum","doc":"Return the sum of all values in this `Map`","summary":"

Return the sum of all values in this Map

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":192,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L192"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":"@raw.sum"}},{"html_id":"to_a:Array(T)-instance-method","name":"to_a","doc":"Receive a copy of the underlying `raw` array.","summary":"

Receive a copy of the underlying #raw array.

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":326,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L326"},"def":{"name":"to_a","return_type":"Array(T)","visibility":"Public","body":"@raw.dup"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","doc":"Convert this `Map` to a `ComplexMap`","summary":"

Convert this Map to a ComplexMap

","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":331,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L331"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, raw.map(&.to_c))"}},{"html_id":"to_gray(*,scale:Bool=false):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Map` to a `GrayscaleImage`.\n\nSet `scale: true` so that all of the values will scale, such that `max` will become `255u8`, and `min` will become `0u8`. All other values will be\nlinearly scaled between those values.","summary":"

Convert this Map to a GrayscaleImage.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"args_string":"(*, scale : Bool = false) : GrayscaleImage","args_html":"(*, scale : Bool = false) : GrayscaleImage","location":{"filename":"src/cr-image/map.cr","line_number":313,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L313"},"def":{"name":"to_gray","args":[{"name":"","external_name":"","restriction":""},{"name":"scale","default_value":"false","external_name":"scale","restriction":"Bool"}],"splat_index":0,"return_type":"GrayscaleImage","visibility":"Public","body":"if scale\n max_val = max\n min_val = min\n multiplier = 255 / (max_val - min_val)\n GrayscaleImage.new(@raw.map do |v|\n (((v - min_val) * multiplier).clamp(0, 255)).to_u8\n end, width)\nelse\n GrayscaleImage.new(@raw.map(&.to_u8), width)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":58,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L58"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/mask.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L39"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel\nfrom an image. This can include whether a particular pixel has a value within certain conditions, OR\nif that pixel should be zeroed out or not.\n\nSee `[]=` methods below for examples of how to manually construct masks.\n\n(x,y) - coordinates. Represent these positions in a Mask of size 10x10:\n\n```\n[\n (0,0), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (0,7), (0,8), (0,9),\n (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9),\n (2,0), (2,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,7), (2,8), (2,9),\n (3,0), (3,1), (3,2), (3,3), (3,4), (3,5), (3,6), (3,7), (3,8), (3,9),\n (4,0), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), (4,7), (4,8), (4,9),\n (5,0), (5,1), (5,2), (5,3), (5,4), (5,5), (5,6), (5,7), (5,8), (5,9),\n (6,0), (6,1), (6,2), (6,3), (6,4), (6,5), (6,6), (6,7), (6,8), (6,9),\n (7,0), (7,1), (7,2), (7,3), (7,4), (7,5), (7,6), (7,7), (7,8), (7,9),\n (8,0), (8,1), (8,2), (8,3), (8,4), (8,5), (8,6), (8,7), (8,8), (8,9),\n (9,0), (9,1), (9,2), (9,3), (9,4), (9,5), (9,6), (9,7), (9,8), (9,9),\n]\n```\n\nAnd every position is a Bool value.\n\nDifferent ways to refer to coordinates:\n```\nmask.at(0, 0) # => (0,0)\nmask[0, 0] # => (0,0), same as .at(0, 0)\nmask[0..1, 4] # => (4,0), (4,1)\nmask[3, 3..5] # => (3,3), (3,4), (3,5)\nmask[2..3, 4..5] # => (2,4), (2,5), (3,4), (3,5)\n```\n\nSee `Operation::Crop` and `Operation::MaskApply` for how this can be useful","summary":"

Mask is a wrapper around BitArray, where each flag represents a boolean bit of information about a pixel from an image.

","constructors":[{"html_id":"new(width:Int32,height:Int32,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` of width x height, preset to `initial`","summary":"

Construct a new Mask of width x height, preset to initial

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(width : Int32, height : Int32, initial : Bool = true)","args_html":"(width : Int32, height : Int32, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L54"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,int:Int)-class-method","name":"new","doc":"Construct a new `Mask` from an integer (useful for testing or small mask construction)","summary":"

Construct a new Mask from an integer (useful for testing or small mask construction)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"args_string":"(width : Int32, height : Int32, int : Int)","args_html":"(width : Int32, height : Int32, int : Int)","location":{"filename":"src/cr-image/mask.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L66"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"},{"name":"int","external_name":"int","restriction":"Int"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, int)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(image:Image,initial:Bool=true)-class-method","name":"new","doc":"Construct a new `Mask` from the dimensions of passed in `image` with an initial bit","summary":"

Construct a new Mask from the dimensions of passed in image with an initial bit

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"args_string":"(image : Image, initial : Bool = true)","args_html":"(image : Image, initial : Bool = true)","location":{"filename":"src/cr-image/mask.cr","line_number":72,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L72"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"initial","default_value":"true","external_name":"initial","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, initial)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,bits:BitArray)-class-method","name":"new","doc":"Construct a new `Mask` with a set width and bits from `bits`","summary":"

Construct a new Mask with a set width and bits from #bits

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"args_string":"(width : Int32, bits : BitArray)","args_html":"(width : Int32, bits : BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L49"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"bits","external_name":"bits","restriction":"::BitArray"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32,&block:Int32,Int32->Bool)-class-method","name":"new","doc":"Construct a new `Mask` of width x height using `&block` to determine if a bit should be true or not (passed in `x` and `y` coordinates)","summary":"

Construct a new Mask of width x height using &block to determine if a bit should be true or not (passed in x and y coordinates)

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","args_html":"(width : Int32, height : Int32, &block : Int32, Int32 -> Bool)","location":{"filename":"src/cr-image/mask.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L59"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"yields":2,"block_arity":2,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32 -> Bool)"},"visibility":"Public","body":"_ = allocate\n_.initialize(width, height, &block) do |_arg0, _arg1|\n yield _arg0, _arg1\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(other_bits:Array(BitArray))-class-method","name":"new","doc":"Construct a new `Mask` from an array of `BitArray`. See `#[](xs : Range, ys : Range) : Array(BitArray)`\n\nThis assumes `other_bits[0]` corresponds to `x == 0` in the mask, and the corresponding\n`BitArray` represents all bits for that row. All `BitArray`s must be of the same size in\n`other_bits`.","summary":"

Construct a new Mask from an array of BitArray.

","abstract":false,"args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"args_string":"(other_bits : Array(BitArray))","args_html":"(other_bits : Array(BitArray))","location":{"filename":"src/cr-image/mask.cr","line_number":82,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L82"},"def":{"name":"new","args":[{"name":"other_bits","external_name":"other_bits","restriction":"Array(BitArray)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(other_bits)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:Mask)-instance-method","name":"==","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask)","args_html":"(other : Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":188,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L188"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":180,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L180"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"Array(BitArray)","visibility":"Public","body":"ycount.times.to_a.map do |y|\n BitArray.new(xcount) do |x|\n self[x + xstart, y + ystart]\n end\nend"}},{"html_id":"[](x:Int32,y:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `x` and `y`","summary":"

Return the bit at x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool","args_html":"(x : Int32, y : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":153,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L153"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\n@bits[(y * width) + x]\n"}},{"html_id":"[](xs:Range,y:Int32):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial row specified","summary":"

Return a new BitArray corresponding to the partial row specified

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(xs : Range, y : Int32) : BitArray","args_html":"(xs : Range, y : Int32) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":159,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L159"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(xs, width)\nBitArray.new(count) do |x|\n self[x + start, y]\nend\n"}},{"html_id":"[](x:Int32,ys:Range):BitArray-instance-method","name":"[]","doc":"Return a new `BitArray` corresponding to the partial column specified","summary":"

Return a new BitArray corresponding to the partial column specified

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(x : Int32, ys : Range) : BitArray","args_html":"(x : Int32, ys : Range) : BitArray","location":{"filename":"src/cr-image/mask.cr","line_number":165,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L165"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"BitArray","visibility":"Public","body":"start, count = resolve_to_start_and_count(ys, height)\nBitArray.new(count) do |y|\n self[x, y + start]\nend\n"}},{"html_id":"[](xs:Range,ys:Range):Array(BitArray)-instance-method","name":"[]","doc":"Return an `Array(BitArray)` for the partial box (of partial rows and partial columns) of this mask.\n\nCan be used to construct another mask from.","summary":"

Return an Array(BitArray) for the partial box (of partial rows and partial columns) of this mask.

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"args_string":"(xs : Range, ys : Range) : Array(BitArray)","args_html":"(xs : Range, ys : Range) : Array(BitArray)","location":{"filename":"src/cr-image/mask.cr","line_number":173,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L173"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xs, width)\nystart, ycount = resolve_to_start_and_count(ys, height)\nself[xstart, xcount, ystart, ycount]\n"}},{"html_id":"[](index:Int32):Bool-instance-method","name":"[]","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":140,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L140"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"@bits[index]"}},{"html_id":"[]=(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bit for coordinate `x` and `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20, 20] = true\nmask.to_gray.save(\"mask_point.jpg\")\n```\n\"Black","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":208,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L208"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"self.set(x, y, value)"}},{"html_id":"[]=(xs:Range,y:Int32,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial row `xs` at column `y`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_row.jpg\")\n```\n\"Black","summary":"

Set the bits for partial row xs at column y

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, y : Int32, value : Bool) : Bool","args_html":"(xs : Range, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":220,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L220"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if y >= height\n raise(IndexError.new(\"Out of bounds: #{y} is beyond the bounds of this mask's height of #{height}\"))\nend\nstart_x, count_x = resolve_to_start_and_count(xs, width)\n@bits.fill(value, (y * width) + start_x, count_x)\nclear_caches\nvalue\n"}},{"html_id":"[]=(x:Int32,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for row `x` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for row x and partial columns ys

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, ys : Range, value : Bool) : Bool","args_html":"(x : Int32, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":236,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L236"},"def":{"name":"[]=","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width\n raise(IndexError.new(\"Out of bounds: #{x} is beyond the bounds of this mask's width of #{width}\"))\nend\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n set(x, y + start_y, value)\nend\nvalue\n"}},{"html_id":"[]=(xs:Range,ys:Range,value:Bool):Bool-instance-method","name":"[]=","doc":"Set the bits for partial rows `xs` and partial columns `ys`\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20..40] = true\nmask.to_gray.save(\"mask_partial_column.jpg\")\n```\n\"Black","summary":"

Set the bits for partial rows xs and partial columns ys

","abstract":false,"args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(xs : Range, ys : Range, value : Bool) : Bool","args_html":"(xs : Range, ys : Range, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":253,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L253"},"def":{"name":"[]=","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"start_x, count_x = resolve_to_start_and_count(xs, width)\nstart_y, count_y = resolve_to_start_and_count(ys, height)\ncount_y.times.to_a.each do |y|\n @bits.fill(value, ((y + start_y) * width) + start_x, count_x)\nend\nclear_caches\nvalue\n"}},{"html_id":"[]?(x:Int32,y:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Bool | Nil","args_html":"(x : Int32, y : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":148,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L148"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[(y * width) + x]?"}},{"html_id":"[]?(index:Int32):Bool|Nil-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool | Nil","args_html":"(index : Int32) : Bool | Nil","location":{"filename":"src/cr-image/mask.cr","line_number":144,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L144"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool | ::Nil","visibility":"Public","body":"@bits[index]?"}},{"html_id":"|(other:Mask):Mask-instance-method","name":"|","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"Mask"}],"args_string":"(other : Mask) : Mask","args_html":"(other : Mask) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":487,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L487"},"def":{"name":"|","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n bits[i] | other.bits[i]\nend)"}},{"html_id":"apply(image:Image):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":269,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L269"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.apply(self)"}},{"html_id":"apply(image:Image,&block:UInt8,ChannelType,Int32,Int32->UInt8):Image-instance-method","name":"apply","doc":"Apply this mask to the provided image with `Operation::MaskApply#apply`","summary":"

Apply this mask to the provided image with Operation::MaskApply#apply

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","args_html":"(image : Image, &block : UInt8, ChannelType, Int32, Int32 -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":274,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L274"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8)"},"return_type":"Image","visibility":"Public","body":"image.apply(self, &block)"}},{"html_id":"at(index:Int32):Bool-instance-method","name":"at","doc":"Return the bit at `index`","summary":"

Return the bit at index

","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Bool","args_html":"(index : Int32) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L134"},"def":{"name":"at","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if index >= size\n raise(\"Index #{index} exceeds mask size #{@bits.size}\")\nend\n@bits[index]\n"}},{"html_id":"bits:BitArray-instance-method","name":"bits","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":43,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L43"},"def":{"name":"bits","return_type":"BitArray","visibility":"Public","body":"@bits"}},{"html_id":"clone-instance-method","name":"clone","doc":"Create a new `Mask` from this one without modifying it","summary":"

Create a new Mask from this one without modifying it

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L107"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"closing(*,diagonal:Bool=true):Mask-instance-method","name":"closing","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":478,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L478"},"def":{"name":"closing","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.closing!(diagonal: diagonal)"}},{"html_id":"closing!(*,diagonal:Bool=true):Mask-instance-method","name":"closing!","doc":"[Closing](https://en.wikipedia.org/wiki/Mathematical_morphology#Closing) operator","summary":"

Closing operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":483,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L483"},"def":{"name":"closing!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"dilate!(diagonal: diagonal).erode!(diagonal: diagonal)"}},{"html_id":"dilate(*,diagonal:Bool=true):Mask-instance-method","name":"dilate","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":419,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L419"},"def":{"name":"dilate","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.dilate!(diagonal: diagonal)"}},{"html_id":"dilate!(*,diagonal:Bool=true):self-instance-method","name":"dilate!","doc":"[Dilation](https://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) operator","summary":"

Dilation operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : self","args_html":"(*, diagonal : Bool = true) : self","location":{"filename":"src/cr-image/mask.cr","line_number":424,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L424"},"def":{"name":"dilate!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"self","visibility":"Public","body":"clear_caches\nnew_bits = bits.dup\nx = -1\ny = 0\nbits.size.times do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n if bits[i]\n next\n end\n new_bits[i] = (((((x != 0) && bits[i - 1]) || ((x != (width - 1)) && bits[i + 1])) || ((y != 0) && bits[i - width])) || ((y != (height - 1)) && bits[i + width])) || (diagonal && ((((((x != 0) && (y != 0)) && bits[(i - width) - 1]) || (((x != (width - 1)) && (y != 0)) && bits[(i - width) + 1])) || (((x != 0) && (y != (height - 1))) && bits[(i + width) - 1])) || (((x != (width - 1)) && (y != (height - 1))) && bits[(i + width) + 1])))\nend\n@bits = new_bits\nself\n"}},{"html_id":"erode(*,diagonal:Bool=true):Mask-instance-method","name":"erode","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":458,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L458"},"def":{"name":"erode","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.erode!(diagonal: diagonal)"}},{"html_id":"erode!(*,diagonal:Bool=true):Mask-instance-method","name":"erode!","doc":"[Erosion](https://en.wikipedia.org/wiki/Mathematical_morphology#Erosion) operator","summary":"

Erosion operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":463,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L463"},"def":{"name":"erode!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"invert!.dilate!(diagonal: diagonal).invert!"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L111"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@bits.size // width"}},{"html_id":"invert-instance-method","name":"invert","doc":"Return a new `Mask` that's a copy of this one with all bits inverted.","summary":"

Return a new Mask that's a copy of this one with all bits inverted.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":129,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L129"},"def":{"name":"invert","visibility":"Public","body":"clone.invert!"}},{"html_id":"invert!-instance-method","name":"invert!","doc":"Invert all bits in this instance of `Mask`. Modifies self.\n\n\"Black\n\nBecomes\n\n\"White","summary":"

Invert all bits in this instance of Mask.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":122,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L122"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"html_id":"opening(*,diagonal:Bool=true):Mask-instance-method","name":"opening","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":468,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L468"},"def":{"name":"opening","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"clone.opening!(diagonal: diagonal)"}},{"html_id":"opening!(*,diagonal:Bool=true):Mask-instance-method","name":"opening!","doc":"[Opening](https://en.wikipedia.org/wiki/Mathematical_morphology#Opening) operator","summary":"

Opening operator

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Mask","args_html":"(*, diagonal : Bool = true) : Mask","location":{"filename":"src/cr-image/mask.cr","line_number":473,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L473"},"def":{"name":"opening!","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Mask","visibility":"Public","body":"erode!(diagonal: diagonal).dilate!(diagonal: diagonal)"}},{"html_id":"region:Region-instance-method","name":"region","doc":"Returns the bounding box of the mask where all true bits are contained. Any pixels outside of the region are false\n\n```\nmask = CrImage::Mask.new(50, 50, false)\nmask[20..40, 20] = true\nmask[20, 20..40] = true\nmask.region # => Region(x: 20, y: 20, width: 20, height: 20)\n```\n\n\"Black","summary":"

Returns the bounding box of the mask where all true bits are contained.

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":296,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L296"},"def":{"name":"region","return_type":"Region","visibility":"Public","body":"@region || (@region = calculate_region)"}},{"html_id":"segments(*,diagonal:Bool=true):Array(Mask)-instance-method","name":"segments","doc":"Return an array of `Mask`s, each one corresponding to an area of contiguous true bits (identified from flood fills).\n\nMay specify `diagonal: false` for only 4-way (up, down, left, right) flood fill instead of default 8-way.\nStarting with sample mask:\n```\nmask = CrImage::Mask.new(50, 50, false)\n\nmask[5..45, 5..45] = true\nmask[15..35, 15..35] = false\nmask[21..25, 21..25] = true\nmask[26..30, 26..30] = true\n```\n\n\"Black\n\nIts segments look like:\n```\nmask.segments.each_with_index do |segment, i|\n segment.to_gray.save(\"mask_8-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\nUsing `diagonal: false` yields:\n```\nmask.segments(diagonal: false).each_with_index do |segment, i|\n segment.to_gray.save(\"mask_4-way_segments_example_#{i}.jpg\")\nend\n```\nYields the images:\n\n\"Black\n\"Black\n\"Black","summary":"

Return an array of Masks, each one corresponding to an area of contiguous true bits (identified from flood fills).

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"args_string":"(*, diagonal : Bool = true) : Array(Mask)","args_html":"(*, diagonal : Bool = true) : Array(Mask)","location":{"filename":"src/cr-image/mask.cr","line_number":360,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L360"},"def":{"name":"segments","args":[{"name":"","external_name":"","restriction":""},{"name":"diagonal","default_value":"true","external_name":"diagonal","restriction":"Bool"}],"splat_index":0,"return_type":"Array(Mask)","visibility":"Public","body":"diagonal ? (@segments_8_way || (@segments_8_way = calculate_segments(diagonal))) : (@segments_4_way || (@segments_4_way = calculate_segments(diagonal)))"}},{"html_id":"set(x:Int32,y:Int32,value:Bool):Bool-instance-method","name":"set","doc":"Set the bit for coordinate `x` and `y`","summary":"

Set the bit for coordinate x and y

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(x : Int32, y : Int32, value : Bool) : Bool","args_html":"(x : Int32, y : Int32, value : Bool) : Bool","location":{"filename":"src/cr-image/mask.cr","line_number":194,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L194"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"Bool","visibility":"Public","body":"if x >= width || y >= height\n raise(IndexError.new(\"Out of bounds: this mask is #{width}x#{height}, and (#{x},#{y}) is outside of that\"))\nend\nclear_caches\n@bits[(y * width) + x] = value\n"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","doc":"Returns the dimension of this mask (width x height)","summary":"

Returns the dimension of this mask (width x height)

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":102,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L102"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":97,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L97"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"bits.size"}},{"html_id":"to_gray:GrayscaleImage-instance-method","name":"to_gray","doc":"Convert this `Mask` to a `GrayscaleImage`, with false bits becoming 0, and true bits becoming 255","summary":"

Convert this Mask to a GrayscaleImage, with false bits becoming 0, and true bits becoming 255

","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":264,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L264"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(bits.map do |b|\n b ? 255_u8 : 0_u8\nend, width, height)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":42,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/mask.cr#L42"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/NumericMap","path":"CrImage/NumericMap.html","kind":"module","full_name":"CrImage::NumericMap(T)","name":"NumericMap","abstract":false,"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"including_types":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl(T)","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Additional methods for `Map` that assume `T` is a numeric type. See `MapImpl`","summary":"

Additional methods for Map that assume T is a numeric type.

","instance_methods":[{"html_id":"+(other:NumericMap(T)):NumericMap(T)-instance-method","name":"+","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":39,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L39"},"def":{"name":"+","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"-(other:NumericMap(T)):NumericMap(T)-instance-method","name":"-","abstract":true,"args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"args_string":"(other : NumericMap(T)) : NumericMap(T)","args_html":"(other : NumericMap(T)) : NumericMap(T)","location":{"filename":"src/cr-image/map.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L38"},"def":{"name":"-","args":[{"name":"other","external_name":"other","restriction":"NumericMap(T)"}],"return_type":"NumericMap(T)","visibility":"Public","body":""}},{"html_id":"max:T-instance-method","name":"max","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L35"},"def":{"name":"max","return_type":"T","visibility":"Public","body":""}},{"html_id":"min:T-instance-method","name":"min","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L36"},"def":{"name":"min","return_type":"T","visibility":"Public","body":""}},{"html_id":"sum:T-instance-method","name":"sum","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":34,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L34"},"def":{"name":"sum","return_type":"T","visibility":"Public","body":""}},{"html_id":"to_c:NumericMap(Complex)-instance-method","name":"to_c","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L31"},"def":{"name":"to_c","return_type":"NumericMap(Complex)","visibility":"Public","body":""}},{"html_id":"to_f:NumericMap(Float64)-instance-method","name":"to_f","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L32"},"def":{"name":"to_f","return_type":"NumericMap(Float64)","visibility":"Public","body":""}},{"html_id":"to_i:NumericMap(Int32)-instance-method","name":"to_i","abstract":true,"location":{"filename":"src/cr-image/map.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L30"},"def":{"name":"to_i","return_type":"NumericMap(Int32)","visibility":"Public","body":""}}]},{"html_id":"Crystal Image/CrImage/OneMap","path":"CrImage/OneMap.html","kind":"class","full_name":"CrImage::OneMap","name":"OneMap","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":525,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L525"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Memory efficient implementation of `MapImpl` when all values are equal to `1`","summary":"

Memory efficient implementation of MapImpl when all values are equal to 1

","constructors":[{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/map.cr","line_number":531,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L531"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](xstart:Int32,xcount:Int32,ystart:Int32,ycount:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"args_string":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","args_html":"(xstart : Int32, xcount : Int32, ystart : Int32, ycount : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":574,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L574"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"xcount","external_name":"xcount","restriction":"Int32"},{"name":"ystart","external_name":"ystart","restriction":"Int32"},{"name":"ycount","external_name":"ycount","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"OneMap.new(xcount, ycount)"}},{"html_id":"[](x:Int32,y:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":550,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L550"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[](xstart:Int32,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xstart : Int32, yrange : Range) : OneMap","args_html":"(xstart : Int32, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":558,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L558"},"def":{"name":"[]","args":[{"name":"xstart","external_name":"xstart","restriction":"Int32"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, ycount = range_to_index_and_count(yrange)\nOneMap.new(1, ycount)\n"}},{"html_id":"[](xrange:Range,ystart:Int32):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"args_string":"(xrange : Range, ystart : Int32) : OneMap","args_html":"(xrange : Range, ystart : Int32) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":563,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L563"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"ystart","external_name":"ystart","restriction":"Int32"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\nOneMap.new(xcount, 1)\n"}},{"html_id":"[](xrange:Range,yrange:Range):OneMap-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : OneMap","args_html":"(xrange : Range, yrange : Range) : OneMap","location":{"filename":"src/cr-image/map.cr","line_number":568,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L568"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"OneMap","visibility":"Public","body":"_, xcount = range_to_index_and_count(xrange)\n_, ycount = range_to_index_and_count(yrange)\nOneMap.new(xcount, ycount)\n"}},{"html_id":"[](index:Int32):Int32-instance-method","name":"[]","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":542,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L542"},"def":{"name":"[]","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(x:Int32,y:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Int32","args_html":"(x : Int32, y : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":554,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L554"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"[]?(index:Int32):Int32-instance-method","name":"[]?","abstract":false,"args":[{"name":"index","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : Int32","args_html":"(index : Int32) : Int32","location":{"filename":"src/cr-image/map.cr","line_number":546,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L546"},"def":{"name":"[]?","args":[{"name":"index","external_name":"index","restriction":"Int32"}],"return_type":"Int32","visibility":"Public","body":"1"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":529,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L529"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black,pad_black_value:T=T.zero):OneMap|IntMap-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black, pad_black_value : T = T.zero) : OneMap | IntMap","location":{"filename":"src/cr-image/map.cr","line_number":582,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L582"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"},{"name":"pad_black_value","default_value":"T.zero","external_name":"pad_black_value","restriction":"T"}],"splat_index":1,"return_type":"OneMap | IntMap","visibility":"Public","body":"case pad_type\nin EdgePolicy::Black\n to_i.pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: pad_black_value)\nin EdgePolicy::Repeat\n top = top > 0 ? top : all\n bottom = bottom > 0 ? bottom : all\n left = left > 0 ? left : all\n right = right > 0 ? right : all\n @width = @width + (left + right)\n @height = @height + (top + bottom)\n self\nin EdgePolicy::None\n raise(Exception.new(\"Pad method doesn't support edge policy None\"))\nend"}},{"html_id":"shape:Tuple(Int32,Int32)-instance-method","name":"shape","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":534,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L534"},"def":{"name":"shape","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{width, height}"}},{"html_id":"size:Int32-instance-method","name":"size","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":538,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L538"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"width * height"}},{"html_id":"to_c:ComplexMap-instance-method","name":"to_c","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":601,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L601"},"def":{"name":"to_c","return_type":"ComplexMap","visibility":"Public","body":"ComplexMap.new(width, Array(Complex).new(size) do\n Complex.new(1)\nend)"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":597,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L597"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, Array(Int32).new(size) do\n 1\nend)"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":528,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L528"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"Crystal Image/CrImage/Operation","path":"CrImage/Operation.html","kind":"module","full_name":"CrImage::Operation","name":"Operation","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"},{"filename":"src/cr-image/operation/operation.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/operation.cr#L2"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Module for containing individual operations for `Image` classes.","summary":"

Module for containing individual operations for Image classes.

","types":[{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","path":"CrImage/Operation/BilinearResize.html","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Resize an image using a bilinear resizing algorithm.\n\nTaking sample `image`:\n\n\"Woman\n\n```\nputs image.width, image.height # => 159x199\nimage.bilinear_resize(40, 50).save(\"small_sample.jpg\")\nimage.bilinear_resize(200, 250).save(\"larger_sample.jpg\")\n```\n\"Sample\n\"Sample","summary":"

Resize an image using a bilinear resizing algorithm.

","instance_methods":[{"html_id":"bilinear_resize(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize","doc":"Resizes image to new dimensions","summary":"

Resizes image to new dimensions

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L16"},"def":{"name":"bilinear_resize","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.bilinear_resize!(width, height)"}},{"html_id":"bilinear_resize!(width:Int32,height:Int32):self-instance-method","name":"bilinear_resize!","doc":"Resizes image to new dimensions. Modifies self.","summary":"

Resizes image to new dimensions.

","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(width : Int32, height : Int32) : self","args_html":"(width : Int32, height : Int32) : self","location":{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/bilinear_resize.cr#L21"},"def":{"name":"bilinear_resize!","args":[{"name":"width","external_name":"width","restriction":"Int32"},{"name":"height","external_name":"height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"x_ratio = width > 1 ? (@width - 1) / (width - 1) : 0\ny_ratio = height > 1 ? (@height - 1) / (height - 1) : 0\neach_channel do |channel, channel_type|\n resized_channel = Array.new(width * height) do\n 0_u8\n end\n height.times do |h|\n width.times do |w|\n x = w * x_ratio\n y = h * y_ratio\n x_ceil = Math.min(@width - 1, x.ceil.to_i)\n x_floor = x.floor.to_i\n y_ceil = Math.min(@height - 1, y.ceil.to_i)\n y_floor = y.floor.to_i\n value = case\n when (x_ceil == x_floor) && (y_ceil == y_floor)\n x_index = x.to_i\n y_index = y.to_i\n channel.unsafe_fetch((@width * y_index) + x_index)\n when x_ceil == x_floor\n x_index = x.to_i\n q_1 = channel.unsafe_fetch((@width * y_ceil) + x_index)\n q_2 = channel.unsafe_fetch((@width * y_floor) + x_index)\n ((q_2 * (y_ceil - y)) + (q_1 * (y - y_floor))).to_u8\n when y_ceil == y_floor\n y_index = y.to_i\n q_1 = channel.unsafe_fetch((@width * y_index) + x_ceil)\n q_2 = channel.unsafe_fetch((@width * y_index) + x_floor)\n ((q_2 * (x_ceil - x)) + (q_1 * (x - x_floor))).to_u8\n else\n v_1 = channel.unsafe_fetch((@width * y_floor) + x_floor)\n v_2 = channel.unsafe_fetch((@width * y_floor) + x_ceil)\n v_3 = channel.unsafe_fetch((@width * y_ceil) + x_floor)\n v_4 = channel.unsafe_fetch((@width * y_ceil) + x_ceil)\n q_1 = (v_1 * (x_ceil - x)) + (v_2 * (x - x_floor))\n q_2 = (v_3 * (x_ceil - x)) + (v_4 * (x - x_floor))\n ((q_1 * (y_ceil - y)) + (q_2 * (y - y_floor))).to_u8\n end\n resized_channel.unsafe_put((width * h) + w, value)\n end\n end\n self[channel_type] = resized_channel\nend\n@width = width\n@height = height\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","path":"CrImage/Operation/BoxBlur.html","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/box_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blurs the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.box_blur(1).save(\"blurred_1_sample.jpg\")\nimage.box_blur(5).save(\"blurred_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blurs the image

","instance_methods":[{"html_id":"box_blur(value:Int32):self-instance-method","name":"box_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L14"},"def":{"name":"box_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.box_blur!(value)"}},{"html_id":"box_blur!(value:Int32):self-instance-method","name":"box_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/box_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/box_blur.cr#L18"},"def":{"name":"box_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"horizontal_blur!(value)\nvertical_blur!(value)\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Brightness","path":"CrImage/Operation/Brightness.html","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness","abstract":false,"locations":[{"filename":"src/cr-image/operation/brightness.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Brightens an image (increases white value)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.brightness(2.0)\n```\n\"Brightened","summary":"

Brightens an image (increases white value)

","instance_methods":[{"html_id":"brightness(value:Float64):self-instance-method","name":"brightness","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L12"},"def":{"name":"brightness","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.brightness!(value)"}},{"html_id":"brightness!(value:Float64):self-instance-method","name":"brightness!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/brightness.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/brightness.cr#L16"},"def":{"name":"brightness!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"each_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, ( (channel.unsafe_fetch(index)) * value))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","path":"CrImage/Operation/ChannelSwap.html","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap","abstract":false,"locations":[{"filename":"src/cr-image/operation/channel_swap.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Swaps channels of `ChannelType` supported by an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.channel_swap(:green, :red) # Crystal autocasting of symbols to Pluto::ChannelType enum is magic\n```\n\"Channel","summary":"

Swaps channels of ChannelType supported by an image

","instance_methods":[{"html_id":"channel_swap(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L12"},"def":{"name":"channel_swap","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"clone.channel_swap!(a, b)"}},{"html_id":"channel_swap!(a:ChannelType,b:ChannelType):self-instance-method","name":"channel_swap!","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"args_string":"(a : ChannelType, b : ChannelType) : self","args_html":"(a : ChannelType, b : ChannelType) : self","location":{"filename":"src/cr-image/operation/channel_swap.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/channel_swap.cr#L16"},"def":{"name":"channel_swap!","args":[{"name":"a","external_name":"a","restriction":"ChannelType"},{"name":"b","external_name":"b","restriction":"ChannelType"}],"return_type":"self","visibility":"Public","body":"ch_a, ch_b = self[a], self[b]\nself[a] = ch_b\nself[b] = ch_a\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Contrast","path":"CrImage/Operation/Contrast.html","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast","abstract":false,"locations":[{"filename":"src/cr-image/operation/contrast.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Increases contrast of an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.contrast(20)\n```\n\"Contrasted","summary":"

Increases contrast of an image

","instance_methods":[{"html_id":"contrast(value:Float64):self-instance-method","name":"contrast","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L12"},"def":{"name":"contrast","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"clone.contrast!(value)"}},{"html_id":"contrast!(value:Float64):self-instance-method","name":"contrast!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64) : self","args_html":"(value : Float64) : self","location":{"filename":"src/cr-image/operation/contrast.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/contrast.cr#L16"},"def":{"name":"contrast!","args":[{"name":"value","external_name":"value","restriction":"Float64"}],"return_type":"self","visibility":"Public","body":"factor = (259 * (value + 255)) / (255 * (259 - value))\neach_color_channel do |channel|\n size.times do |index|\n channel.unsafe_put(index, (Math.min(255, Math.max(0, (factor * ((channel.unsafe_fetch(index)).to_i - 128)) + 128))).to_u8)\n end\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Crop","path":"CrImage/Operation/Crop.html","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop","abstract":false,"locations":[{"filename":"src/cr-image/operation/crop.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Crops an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\n# These calls are equivalent\nimage.crop(40, 30, 80, 80)\nimage[40...120, 30...110]\n```\n\"Cropped","summary":"

Crops an image

","instance_methods":[{"html_id":"[](xrange:Range,yrange:Range):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"args_string":"(xrange : Range, yrange : Range) : self","args_html":"(xrange : Range, yrange : Range) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range"},{"name":"yrange","external_name":"yrange","restriction":"Range"}],"return_type":"self","visibility":"Public","body":"xstart, xcount = resolve_to_start_and_count(xrange, width)\nystart, ycount = resolve_to_start_and_count(yrange, height)\ncrop(xstart, ystart, xcount, ycount)\n"}},{"html_id":"crop(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L18"},"def":{"name":"crop","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.crop!(x, y, new_width, new_height)"}},{"html_id":"crop(region:Region):self-instance-method","name":"crop","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L14"},"def":{"name":"crop","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop(*region.to_tuple)"}},{"html_id":"crop!(x:Int32,y:Int32,new_width:Int32,new_height:Int32):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","args_html":"(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":32,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L32"},"def":{"name":"crop!","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"},{"name":"new_width","external_name":"new_width","restriction":"Int32"},{"name":"new_height","external_name":"new_height","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"each_channel do |channel, channel_type|\n self[channel_type] = (UInt8Map.new(width, channel))[x, new_width, y, new_height].raw\nend\n@width = new_width\n@height = new_height\nself\n"}},{"html_id":"crop!(region:Region):self-instance-method","name":"crop!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"}],"args_string":"(region : Region) : self","args_html":"(region : Region) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/crop.cr#L28"},"def":{"name":"crop!","args":[{"name":"region","external_name":"region","restriction":"Region"}],"return_type":"self","visibility":"Public","body":"crop!(*region.to_tuple)"}}]},{"html_id":"Crystal Image/CrImage/Operation/Draw","path":"CrImage/Operation/Draw.html","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw","abstract":false,"locations":[{"filename":"src/cr-image/operation/draw.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L17"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Draws shapes in the image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.draw_square(40, 30, 80, 80, CrImage::Color.of(\"#00f\"))\nimage.draw_circle(80, 70, 40, CrImage::Color.of(\"#00f\"))\nimage.draw_line(50, 50, 70, 90, CrImage::Color.of(\"#0f0\"))\n```\n\"Woman\n\"Woman\n\"Woman\n\nCan also use the `fill: true` parameter to fill in the drawn shapes","summary":"

Draws shapes in the image

","instance_methods":[{"html_id":"draw_circle(x:Int,y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle centered at x, y with radius","summary":"

Draw a circle centered at x, y with radius

","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":59,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L59"},"def":{"name":"draw_circle","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(x, y, radius, color, fill: fill)"}},{"html_id":"draw_circle(region:Region,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":54,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L54"},"def":{"name":"draw_circle","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":3,"return_type":"self","visibility":"Public","body":"clone.draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_circle!(center_x:Int,center_y:Int,radius:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_circle!","abstract":false,"args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","args_html":"(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":68,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L68"},"def":{"name":"draw_circle!","args":[{"name":"center_x","external_name":"center_x","restriction":"Int"},{"name":"center_y","external_name":"center_y","restriction":"Int"},{"name":"radius","external_name":"radius","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":4,"return_type":"self","visibility":"Public","body":"min_x = Math.max(0, center_x - radius)\nmax_x = Math.min(width - 1, center_x + radius)\nmax_y = Math.min(height - 1, center_y + radius)\neach_color_channel do |channel, channel_type|\n 0.upto(radius) do |y|\n theta_0 = Math.asin((Math.max(0, ( y - 1))) / radius.to_f)\n theta_1 = Math.asin(y / radius.to_f)\n x_0 = (radius * (Math.cos(theta_0))).round\n x_1 = (radius * (Math.cos(theta_1))).round\n lower_x_outer = (Math.max(min_x, center_x - x_0)).to_i\n lower_x_inner = (Math.max(min_x, center_x - x_1)).to_i\n upper_x_outer = (Math.min(max_x, center_x + x_0)).to_i\n upper_x_inner = (Math.min(max_x, center_x + x_1)).to_i\n lower_y = center_y - y\n upper_y = center_y + y\n lower_y_outside_of_image = (center_y - y) < 0 || (center_y - y) > max_y\n upper_y_outside_of_image = (center_y + y) < 0 || (center_y + y) > max_y\n left_outer_x_beyond_right_of_image = (center_x - x_0) > max_x\n right_outer_x_beyond_left_of_image = (center_x + x_0) < 0\n left_inner_x_beyond_left_of_image = (center_x - x_1) < 0\n right_inner_x_beyond_right_of_image = (center_x + x_1) > max_x\n if fill\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (left_outer_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (upper_x_outer - lower_x_outer) + 1] = Array(UInt8).new((upper_x_outer - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n else\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || lower_y_outside_of_image\n else\n channel[index_of(lower_x_outer, lower_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || lower_y_outside_of_image\n else\n channel[index_of(upper_x_inner, lower_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n if (left_inner_x_beyond_left_of_image || left_outer_x_beyond_right_of_image) || upper_y_outside_of_image\n else\n channel[index_of(lower_x_outer, upper_y), (lower_x_inner - lower_x_outer) + 1] = Array(UInt8).new((lower_x_inner - lower_x_outer) + 1) do\n color[channel_type]\n end\n end\n if (right_inner_x_beyond_right_of_image || right_outer_x_beyond_left_of_image) || upper_y_outside_of_image\n else\n channel[index_of(upper_x_inner, upper_y), (upper_x_outer - upper_x_inner) + 1] = Array(UInt8).new((upper_x_outer - upper_x_inner) + 1) do\n color[channel_type]\n end\n end\n end\n end\nend\nself\n"}},{"html_id":"draw_circle!(region:Region,color:Color,*,fill:Bool=false,radius:Int32|Nil=nil):self-instance-method","name":"draw_circle!","doc":"Draw a circle around the region's center (see `Region#center`)","summary":"

Draw a circle around the region's center (see Region#center)

","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":64,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L64"},"def":{"name":"draw_circle!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"},{"name":"radius","default_value":"nil","external_name":"radius","restriction":"Int32 | ::Nil"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_circle!(*region.center, radius, color, fill: fill)"}},{"html_id":"draw_line(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":134,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L134"},"def":{"name":"draw_line","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.draw_line!(x1, y1, x2, y2, color)"}},{"html_id":"draw_line!(x1:Int32,y1:Int32,x2:Int32,y2:Int32,color:Color):self-instance-method","name":"draw_line!","doc":"Implementation of http://www.edepot.com/linec.html","summary":"

Implementation of http://www.edepot.com/linec.html

","abstract":false,"args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","args_html":"(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":139,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L139"},"def":{"name":"draw_line!","args":[{"name":"x1","external_name":"x1","restriction":"Int32"},{"name":"y1","external_name":"y1","restriction":"Int32"},{"name":"x2","external_name":"x2","restriction":"Int32"},{"name":"y2","external_name":"y2","restriction":"Int32"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"if (0 <= x1 && x1 < width) && (0 <= y1 && y1 < height)\nelse\n raise(Exception.new(\"First point (#{x1},#{y1}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nif (0 <= x2 && x2 < width) && (0 <= y2 && y2 < height)\nelse\n raise(Exception.new(\"Second point (#{x2},#{y2}) lies outside of the available drawing window (#{width}x#{height})\"))\nend\nrise_by_height = false\nshort = y2 - y1\nlong = x2 - x1\nif short.abs > long.abs\n short, long = long, short\n rise_by_height = true\nend\nend_val = long\ngradient = long == 0 ? short : short / long.abs.to_f\nif rise_by_height\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + jump.to_i, y1 + i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nelse\n each_color_channel do |channel, channel_type|\n jump = 0.0\n 0.to(end_val) do |i|\n channel[index_of(x1 + i, y1 + jump.to_i)] = color[channel_type]\n jump = jump + gradient\n end\n end\nend\nself\n"}},{"html_id":"draw_square(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L22"},"def":{"name":"draw_square","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"clone.draw_square!(x, y, box_width, box_height, color, fill: fill)"}},{"html_id":"draw_square(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L18"},"def":{"name":"draw_square","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"clone.draw_square!(region, color, fill: fill)"}},{"html_id":"draw_square!(x:Int,y:Int,box_width:Int,box_height:Int,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","args_html":"(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L30"},"def":{"name":"draw_square!","args":[{"name":"x","external_name":"x","restriction":"Int"},{"name":"y","external_name":"y","restriction":"Int"},{"name":"box_width","external_name":"box_width","restriction":"Int"},{"name":"box_height","external_name":"box_height","restriction":"Int"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":5,"return_type":"self","visibility":"Public","body":"if (x + box_width) > width\n raise(\"Box dimensions extend #{((x + box_width) - width) + 1} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{((y + box_height) - height) + 1} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_color_channel do |channel, channel_type|\n channel[( (y_i * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n channel[((y_i + box_height) * width) + x_i, box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n box_height.times do |i|\n if i == 0\n next\n end\n if fill\n channel[( ((y_i + i) * width) + x_i), box_width] = Array(UInt8).new(box_width) do\n color[channel_type]\n end\n else\n channel.unsafe_put(((y_i + i) * width) + x_i, color[channel_type])\n channel.unsafe_put(((((y_i + i) * width) + x_i) + box_width) - 1, color[channel_type])\n end\n end\nend\nself\n"}},{"html_id":"draw_square!(region:Region,color:Color,*,fill:Bool=false):self-instance-method","name":"draw_square!","abstract":false,"args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"args_string":"(region : Region, color : Color, *, fill : Bool = false) : self","args_html":"(region : Region, color : Color, *, fill : Bool = false) : self","location":{"filename":"src/cr-image/operation/draw.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/draw.cr#L26"},"def":{"name":"draw_square!","args":[{"name":"region","external_name":"region","restriction":"Region"},{"name":"color","external_name":"color","restriction":"Color"},{"name":"","external_name":"","restriction":""},{"name":"fill","default_value":"false","external_name":"fill","restriction":"Bool"}],"splat_index":2,"return_type":"self","visibility":"Public","body":"draw_square!(*region.to_tuple, color, fill: fill)"}}]},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","path":"CrImage/Operation/GaussianBlur.html","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Applies a 3x3 Gaussian blur. Implementation derived from [here](https://blog.ivank.net/fastest-gaussian-blur.html)\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.gaussian_blur(1).save(\"gaussian_1_sample.jpg\")\nimage.gaussian_blur(5).save(\"gaussian_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Applies a 3x3 Gaussian blur.

","instance_methods":[{"html_id":"gaussian_blur(sigma:Int32):self-instance-method","name":"gaussian_blur","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L14"},"def":{"name":"gaussian_blur","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.gaussian_blur!(sigma)"}},{"html_id":"gaussian_blur!(sigma:Int32):self-instance-method","name":"gaussian_blur!","abstract":false,"args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"args_string":"(sigma : Int32) : self","args_html":"(sigma : Int32) : self","location":{"filename":"src/cr-image/operation/gaussian_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/gaussian_blur.cr#L18"},"def":{"name":"gaussian_blur!","args":[{"name":"sigma","external_name":"sigma","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"n = 3\nw_ideal = Math.sqrt((((12 * sigma) * sigma) / n) + 1)\nw_l = w_ideal.floor.to_i\nif (w_l % 2) == 0\n w_l = w_l - 1\nend\nm_ideal = (((((12 * sigma) * sigma) - ((n * w_l) * w_l)) - ((4 * n) * w_l)) - (3 * n)) / ((-4 * w_l) - 4)\nm = m_ideal.round\nsizes = [] of Int32\nn.times do |i|\n sizes << (if i < m\n w_l\n else\n w_l + 2\n end)\nend\nbox_blur!(((sizes.unsafe_fetch(0)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(1)) - 1) // 2)\nbox_blur!(((sizes.unsafe_fetch(2)) - 1) // 2)\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","path":"CrImage/Operation/HistogramEqualize.html","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize","abstract":false,"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":19,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Provides methods for histogram and histogram equalization. Follows method outlined [here](https://www.sci.utah.edu/~acoste/uou/Image/project1/Arthur_COSTE_Project_1_report.html)\n\nIf an image is particularly dark or particularly bright with low contrast, the `Operation::Contrast#contrast` method will only\nmake the image darker or lighter. For images like these, equalizing the image along its histogram will produce better results.\n\n\"A\n\n```\nimage.contrast(10).save(\"contrast.jpg\")\nimage.histogram_equalize.save(\"equalized.jpg\")\n```\n\"Darker\n\"A\n\nThis method does not work well when a given method has a bimodal distribution of color pixels. For example:\n\n\"Woman\n\"Highly","summary":"

Provides methods for histogram and histogram equalization.

","instance_methods":[{"html_id":"histogram(channel_type:ChannelType):Histogram-instance-method","name":"histogram","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Histogram","args_html":"(channel_type : ChannelType) : Histogram","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":107,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L107"},"def":{"name":"histogram","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Histogram","visibility":"Public","body":"Histogram.new(self, channel_type)"}},{"html_id":"histogram_equalize:self-instance-method","name":"histogram_equalize","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":111,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L111"},"def":{"name":"histogram_equalize","return_type":"self","visibility":"Public","body":"clone.histogram_equalize!"}},{"html_id":"histogram_equalize!:self-instance-method","name":"histogram_equalize!","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":115,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L115"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_color_channel do |channel, channel_type|\n if channel_type.alpha?\n next\n end\n remap = (histogram(channel_type)).equalize\n size.times do |i|\n channel.unsafe_put(i, remap[channel.unsafe_fetch(i)])\n end\nend\nself\n"}}],"types":[{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize/Histogram","path":"CrImage/Operation/HistogramEqualize/Histogram.html","kind":"class","full_name":"CrImage::Operation::HistogramEqualize::Histogram","name":"Histogram","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/operation/histogram.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},"doc":"A histogram of an `Image` for a specific `ChannelType`","summary":"

A histogram of an Image for a specific ChannelType

","constructors":[{"html_id":"new(image:Image,channel_type:ChannelType)-class-method","name":"new","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(image : Image, channel_type : ChannelType)","args_html":"(image : Image, channel_type : ChannelType)","location":{"filename":"src/cr-image/operation/histogram.cr","line_number":24,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L24"},"def":{"name":"new","args":[{"name":"image","external_name":"image","restriction":"Image"},{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"visibility":"Public","body":"_ = allocate\n_.initialize(image, channel_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"cdf:Hash(UInt8,Float64)-instance-method","name":"cdf","doc":"Get the cumulative distribution for the image's histogram","summary":"

Get the cumulative distribution for the image's histogram

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":56,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L56"},"def":{"name":"cdf","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"total = 0_f64\n@cumulative_distribution_histogram || (@cumulative_distribution_histogram = normalize.map do |pixel, probability|\n original = total\n total = total + probability\n {pixel, original}\nend.to_h)\n"}},{"html_id":"channel_type:CrImage::ChannelType-instance-method","name":"channel_type","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"channel_type","visibility":"Public","body":"@channel_type"}},{"html_id":"counts:Hash(UInt8,Int32)-instance-method","name":"counts","doc":"Get the raw counts for a given pixel value (0-255) in the image","summary":"

Get the raw counts for a given pixel value (0-255) in the image

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L30"},"def":{"name":"counts","return_type":"Hash(UInt8, Int32)","visibility":"Public","body":"@internal_hist || (@internal_hist = calculate_counts)"}},{"html_id":"equalize:Hash(UInt8,UInt8)-instance-method","name":"equalize","doc":"Remap the cumalitive distribution of pixels to get a new, more spread out pixel value","summary":"

Remap the cumalitive distribution of pixels to get a new, more spread out pixel value

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L66"},"def":{"name":"equalize","return_type":"Hash(UInt8, UInt8)","visibility":"Public","body":"cdf.map do |pixel, cumalative|\n {pixel, ((cumalative * 255).clamp(0, 255)).to_u8}\nend.to_h"}},{"html_id":"image:CrImage::Image-instance-method","name":"image","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L22"},"def":{"name":"image","visibility":"Public","body":"@image"}},{"html_id":"mean:Float64-instance-method","name":"mean","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":74,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L74"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"@mean || (@mean = counts.sum do |pixel, count|\n pixel.to_i64 * count\nend.to_f64 / @image.size)"}},{"html_id":"normalize:Hash(UInt8,Float64)-instance-method","name":"normalize","doc":"Get pixel counts normalized - all values between 0.0 and 1.0","summary":"

Get pixel counts normalized - all values between 0.0 and 1.0

","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":47,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L47"},"def":{"name":"normalize","return_type":"Hash(UInt8, Float64)","visibility":"Public","body":"counts.map do |pixel, count|\n {pixel, count.to_f / @image.size}\nend.to_h"}},{"html_id":"std_dev:Float64-instance-method","name":"std_dev","abstract":false,"location":{"filename":"src/cr-image/operation/histogram.cr","line_number":80,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/histogram.cr#L80"},"def":{"name":"std_dev","return_type":"Float64","visibility":"Public","body":"@std_dev || (@std_dev = Math.sqrt(counts.sum do |value, count|\n count * ((value.to_i64 - mean) ** 2)\nend.to_f64 / @image.size))"}}]}]},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","path":"CrImage/Operation/HorizontalBlur.html","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the horizontal axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.horizontal_blur(1).save(\"horizontal_1_sample.jpg\")\nimage.horizontal_blur(5).save(\"horizontal_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the horizontal axis

","instance_methods":[{"html_id":"horizontal_blur(k:Int32):self-instance-method","name":"horizontal_blur","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(k)"}},{"html_id":"horizontal_blur!(k:Int32):self-instance-method","name":"horizontal_blur!","abstract":false,"args":[{"name":"k","external_name":"k","restriction":"Int32"}],"args_string":"(k : Int32) : self","args_html":"(k : Int32) : self","location":{"filename":"src/cr-image/operation/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_blur!","args":[{"name":"k","external_name":"k","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((k + k) + 1)\neach_color_channel do |channel|\n @height.times do |y|\n center_index : Int32 = y * @width\n left__bound : Int32 = center_index\n right_bound : Int32 = center_index + k\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last__value : Int32 = (channel.unsafe_fetch((center_index + @width) - 1)).to_i\n current_sum : Int32 = (k + 1) * first_value\n (0..(k - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + i))\n end\n (0..k).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n center_index = center_index + 1\n end\n ((k + 1)..((@width - k) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + 1\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n ((@width - k)..(@width - 1)).each do\n current_sum = current_sum + (last__value - (channel.unsafe_fetch(left__bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left__bound = left__bound + 1\n center_index = center_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","path":"CrImage/Operation/MaskApply.html","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply","abstract":false,"locations":[{"filename":"src/cr-image/operation/mask_apply.cr","line_number":27,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Apply a mask to an image\n\nTaking sample `image`:\n\n\"Woman\n\nAnd mask\n\n\"Black\n\n```\nmask = CrImage::Mask.new(image, false)\nmask[50..90, 65..75] = true\nmask.to_gray.save(\"apply_mask_mask.jpg\")\n\nimage.apply(mask).save(\"apply_mask.jpg\")\n\nimage.apply_color(mask, CrImage::Color.of(\"#00f\")).save(\"apply_mask_color.jpg\")\n\nimage.apply(mask) do |pixel, channel_type, x, y|\n Math.min(255, pixel + 50).to_u8 if channel_type.blue?\nend.save(\"apply_mask_block.jpg\")\n```\n\"Image\n\"Thin\n\"Thin","summary":"

Apply a mask to an image

","instance_methods":[{"html_id":"apply(mask:Mask):self-instance-method","name":"apply","doc":"Black out all pixels but those found in the mask","summary":"

Black out all pixels but those found in the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L29"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"clone.apply!(mask)"}},{"html_id":"apply(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply","doc":"Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.\n\nDoes not change values not matched by the mask","summary":"

Apply block to all pixels that match mask, replacing pixel value if block returns non-nil value.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L36"},"def":{"name":"apply","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"clone.apply!(mask, &block)"}},{"html_id":"apply!(mask:Mask):self-instance-method","name":"apply!","doc":"TODO: add apply version that accepts 1+ ChannelType that the mask should apply to (i.e. make a background completely transparent, not just transparent black)","summary":"

TODO add apply version that accepts 1+ ChannelType that the mask should apply to (i.e.

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask) : self","args_html":"(mask : Mask) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L46"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? pixel : 0_u8\n end\nend\nself\n"}},{"html_id":"apply!(mask:Mask,&block:UInt8,ChannelType,Int32,Int32->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L55"},"def":{"name":"apply!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(UInt8, ChannelType, Int32, Int32 -> UInt8 | ::Nil)"},"return_type":"self","visibility":"Public","body":"if (mask.width == width) && (mask.height == height)\nelse\n raise(\"Mask of #{mask.width}x#{mask.height} doesn't match image dimensions #{width}x#{height}\")\nend\neach_channel do |channel, channel_type|\n channel.map_with_index! do |pixel, i|\n mask.at(i) ? (block.call(pixel, channel_type, i % width, i // width)) || pixel : pixel\n end\nend\nself\n"}},{"html_id":"apply_color(mask:Mask,color:Color):self-instance-method","name":"apply_color","doc":"Change the color of all pixels that match the mask","summary":"

Change the color of all pixels that match the mask

","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L41"},"def":{"name":"apply_color","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"clone.apply_color!(mask, color)"}},{"html_id":"apply_color!(mask:Mask,color:Color):self-instance-method","name":"apply_color!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"args_string":"(mask : Mask, color : Color) : self","args_html":"(mask : Mask, color : Color) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/mask_apply.cr#L66"},"def":{"name":"apply_color!","args":[{"name":"mask","external_name":"mask","restriction":"Mask"},{"name":"color","external_name":"color","restriction":"Color"}],"return_type":"self","visibility":"Public","body":"apply!(mask) do |_, channel_type|\n color[channel_type]\nend"}}]},{"html_id":"Crystal Image/CrImage/Operation/Pad","path":"CrImage/Operation/Pad.html","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad","abstract":false,"locations":[{"filename":"src/cr-image/operation/pad.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Pads an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.pad(left: 50, right: 50)\nimage.pad(left: 50, right: 50, pad_type: CrImage::EdgePolicy::Repeat)\n```\n\"Picture\n\"Picture","summary":"

Pads an image

","instance_methods":[{"html_id":"pad(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L14"},"def":{"name":"pad","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.pad!(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type)"}},{"html_id":"pad!(all:Int32=0,*,top:Int32=0,bottom:Int32=0,left:Int32=0,right:Int32=0,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"pad!","abstract":false,"args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/pad.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/pad.cr#L18"},"def":{"name":"pad!","args":[{"name":"all","default_value":"0","external_name":"all","restriction":"Int32"},{"name":"","external_name":"","restriction":""},{"name":"top","default_value":"0","external_name":"top","restriction":"Int32"},{"name":"bottom","default_value":"0","external_name":"bottom","restriction":"Int32"},{"name":"left","default_value":"0","external_name":"left","restriction":"Int32"},{"name":"right","default_value":"0","external_name":"right","restriction":"Int32"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"orig_width = width\neach_channel do |channel, channel_type|\n padded = (UInt8Map.new(orig_width, channel)).pad(all, top: top, bottom: bottom, left: left, right: right, pad_type: pad_type, pad_black_value: channel_type.default)\n self[channel_type] = padded.raw\n @width = padded.width\n @height = padded.height\nend\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/Rotate","path":"CrImage/Operation/Rotate.html","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate","abstract":false,"locations":[{"filename":"src/cr-image/operation/rotate.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Rotates an image\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.rotate(45)\nimage.rotate(45, pad: true)\n```\n\"Rotated\n\"Rotated","summary":"

Rotates an image

","instance_methods":[{"html_id":"rotate(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate","doc":"Rotates an image by `degrees`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L20"},"def":{"name":"rotate","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"clone.rotate!(degrees, center_x: center_x, center_y: center_y, radius: radius, pad: pad, pad_type: pad_type)"}},{"html_id":"rotate!(degrees:Float64,*,center_x:Int32=width//2,center_y:Int32=height//2,radius:Int32=-1,pad:Bool=false,pad_type:EdgePolicy=EdgePolicy::Black):self-instance-method","name":"rotate!","doc":"Rotates an image by `degrees`. Modifies `self`\n\n`center_x` and `center_y` represents the point in the image that will be rotated around. Defaults to image center.\n`radius` can be used to only rotate a smaller circular region in the image. Can't be used with `pad`\n`pad` can be used to pad out the image so that corners that would normally be occluded, are visible.\n`pad_type` behaves the same as `pad_type` in `Pad`","summary":"

Rotates an image by degrees.

","abstract":false,"args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"args_string":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","args_html":"(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self","location":{"filename":"src/cr-image/operation/rotate.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/rotate.cr#L38"},"def":{"name":"rotate!","args":[{"name":"degrees","external_name":"degrees","restriction":"Float64"},{"name":"","external_name":"","restriction":""},{"name":"center_x","default_value":"width // 2","external_name":"center_x","restriction":"Int32"},{"name":"center_y","default_value":"height // 2","external_name":"center_y","restriction":"Int32"},{"name":"radius","default_value":"-1","external_name":"radius","restriction":"Int32"},{"name":"pad","default_value":"false","external_name":"pad","restriction":"Bool"},{"name":"pad_type","default_value":"EdgePolicy::Black","external_name":"pad_type","restriction":"EdgePolicy"}],"splat_index":1,"return_type":"self","visibility":"Public","body":"if pad_type.none?\n raise(Exception.new(\"Edge policy None doesn't apply to rotation\"))\nend\nif pad && radius >= 0\n raise(Exception.new(\"Can't pad image and limit rotation by radius\"))\nend\nradians = ((-Math::PI) * degrees) / 180\nsin = Math.sin(radians)\ncos = Math.cos(radians)\nradius_sq = radius * radius\nnew_width, new_size, out_center_x, out_center_y = output_dimensions(pad, degrees, center_x, center_y)\neach_channel do |channel, channel_type|\n new_x = -1\n new_y = 0\n self[channel_type] = Array.new(new_size) do |i|\n new_x = new_x + 1\n if new_x == new_width\n new_x = 0\n new_y = new_y + 1\n end\n if radius >= 0 && (((new_x - center_x) ** 2) + ((new_y - center_y) ** 2)) > radius_sq\n next channel.unsafe_fetch(i)\n end\n orig_x = (((cos * (new_x - out_center_x)) - (sin * (new_y - out_center_y))) + center_x).round.to_i\n orig_y = (((sin * (new_x - out_center_x)) + (cos * (new_y - out_center_y))) + center_y).round.to_i\n if pad_type.black?\n if ((orig_x < 0 || orig_x >= width) || orig_y < 0) || orig_y >= height\n next channel_type.default\n end\n else\n orig_x = orig_x.clamp(0, width - 1)\n orig_y = orig_y.clamp(0, height - 1)\n end\n channel.unsafe_fetch((orig_y * width) + orig_x)\n end\nend\n@width = new_width\n@height = new_size // new_width\nself\n"}}]},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","path":"CrImage/Operation/VerticalBlur.html","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur","abstract":false,"locations":[{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"Crystal Image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"Crystal Image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"Crystal Image/CrImage/Operation","kind":"module","full_name":"CrImage::Operation","name":"Operation"},"doc":"Blur an image along the vertical axis\n\nTaking sample `image`:\n\n\"Woman\n\n```\nimage.vertical_blur(1).save(\"vertical_1_sample.jpg\")\nimage.vertical_blur(5).save(\"vertical_5_sample.jpg\")\n```\n\"Blurred\n\"Blurred","summary":"

Blur an image along the vertical axis

","instance_methods":[{"html_id":"vertical_blur(value:Int32):self-instance-method","name":"vertical_blur","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L14"},"def":{"name":"vertical_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.vertical_blur!(value)"}},{"html_id":"vertical_blur!(value:Int32):self-instance-method","name":"vertical_blur!","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Int32"}],"args_string":"(value : Int32) : self","args_html":"(value : Int32) : self","location":{"filename":"src/cr-image/operation/vertical_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/operation/vertical_blur.cr#L18"},"def":{"name":"vertical_blur!","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"buffer = Bytes.new(size, 0)\nmultiplier = 1 / ((value + value) + 1)\neach_color_channel do |channel|\n @width.times do |x|\n center_index : Int32 = x\n left_bound : Int32 = center_index\n right_bound : Int32 = center_index + (value * @width)\n first_value : Int32 = (channel.unsafe_fetch(center_index)).to_i\n last_value : Int32 = (channel.unsafe_fetch(center_index + (@width * (@height - 1)))).to_i\n current_sum : Int32 = (value + 1) * first_value\n (0..(value - 1)).each do |i|\n current_sum = current_sum + (channel.unsafe_fetch(center_index + (i * @width)))\n end\n (0..value).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - first_value)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n current_sum = current_sum + ((channel.unsafe_fetch(right_bound)).to_i - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n right_bound = right_bound + @width\n center_index = center_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n current_sum = current_sum + (last_value - (channel.unsafe_fetch(left_bound)).to_i)\n buffer.unsafe_put(center_index, (current_sum * multiplier).to_u8)\n left_bound = left_bound + @width\n center_index = center_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"Crystal Image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"Crystal Image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"Crystal Image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a rectangular area on an `Image` from its upper left corner `x` and `y` coordinates, and a `width` and `height`.\n\nSee `Operation::Crop#crop` and `Operation::Draw#draw_square` for examples using it.","summary":"

Represents a rectangular area on an Image from its upper left corner #x and #y coordinates, and a #width and #height.

","constructors":[{"html_id":"center(x:UInt16,y:UInt16,width:UInt16,height:UInt16):Region-class-method","name":"center","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16) : Region","location":{"filename":"src/cr-image/region.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L11"},"def":{"name":"center","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"return_type":"Region","visibility":"Public","body":"new(x - (width // 2), y - (height // 2), width, height)"}},{"html_id":"new(x:UInt16,y:UInt16,width:UInt16,height:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"args_string":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","args_html":"(x : UInt16, y : UInt16, width : UInt16, height : UInt16)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"new","args":[{"name":"x","external_name":"x","restriction":"UInt16"},{"name":"y","external_name":"y","restriction":"UInt16"},{"name":"width","external_name":"width","restriction":"UInt16"},{"name":"height","external_name":"height","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(x, y, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"center:Tuple(Int32,Int32)-instance-method","name":"center","doc":"Return the `{x, y}` tuple of the center coordinates of this `Region`","summary":"

Return the {x, y} tuple of the center coordinates of this Region

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L21"},"def":{"name":"center","return_type":"Tuple(Int32, Int32)","visibility":"Public","body":"{(width.to_i // 2) + x.to_i, (height.to_i // 2) + y.to_i}"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@x.clone, @y.clone, @width.clone, @height.clone)"}},{"html_id":"copy_with(x_x=@x,y_y=@y,width_width=@width,height_height=@height)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"args_string":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","args_html":"(x _x = @x, y _y = @y, width _width = @width, height _height = @height)","location":{"filename":"src/cr-image/region.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L5"},"def":{"name":"copy_with","args":[{"name":"_x","default_value":"@x","external_name":"x","restriction":""},{"name":"_y","default_value":"@y","external_name":"y","restriction":""},{"name":"_width","default_value":"@width","external_name":"width","restriction":""},{"name":"_height","default_value":"@height","external_name":"height","restriction":""}],"visibility":"Public","body":"self.class.new(_x, _y, _width, _height)"}},{"html_id":"crop(image:Image):Image-instance-method","name":"crop","doc":"Crop a provided `Image` with this region, using `Operation::Crop#crop`","summary":"

Crop a provided Image with this region, using Operation::Crop#crop

","abstract":false,"args":[{"name":"image","external_name":"image","restriction":"Image"}],"args_string":"(image : Image) : Image","args_html":"(image : Image) : Image","location":{"filename":"src/cr-image/region.cr","line_number":16,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L16"},"def":{"name":"crop","args":[{"name":"image","external_name":"image","restriction":"Image"}],"return_type":"Image","visibility":"Public","body":"image.crop(self)"}},{"html_id":"height:UInt16-instance-method","name":"height","abstract":false,"def":{"name":"height","return_type":"UInt16","visibility":"Public","body":"@height"}},{"html_id":"to_tuple:Tuple(Int32,Int32,Int32,Int32)-instance-method","name":"to_tuple","doc":"Return this `Region` as a `x`, `y`, `width`, and `height` tuple","summary":"

Return this Region as a #x, #y, #width, and #height tuple

","abstract":false,"location":{"filename":"src/cr-image/region.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/region.cr#L26"},"def":{"name":"to_tuple","return_type":"Tuple(Int32, Int32, Int32, Int32)","visibility":"Public","body":"{x.to_i, y.to_i, width.to_i, height.to_i}"}},{"html_id":"width:UInt16-instance-method","name":"width","abstract":false,"def":{"name":"width","return_type":"UInt16","visibility":"Public","body":"@width"}},{"html_id":"x:UInt16-instance-method","name":"x","abstract":false,"def":{"name":"x","return_type":"UInt16","visibility":"Public","body":"@x"}},{"html_id":"y:UInt16-instance-method","name":"y","abstract":false,"def":{"name":"y","return_type":"UInt16","visibility":"Public","body":"@y"}}]},{"html_id":"Crystal Image/CrImage/RepeatView","path":"CrImage/RepeatView.html","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},"ancestors":[{"html_id":"Crystal Image/CrImage/Window","kind":"class","full_name":"CrImage::Window","name":"Window"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":52,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L52"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An implementation of `Window`, where the value of a point in the window that is off the edge of the underlying `Map` resolves to the nearest edge of that `Map`","summary":"

An implementation of Window, where the value of a point in the window that is off the edge of the underlying Map resolves to the nearest edge of that Map

","constructors":[{"html_id":"new(width,height,map,map_x,map_y)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"args_string":"(width, height, map, map_x, map_y)","args_html":"(width, height, map, map_x, map_y)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":""},{"name":"height","external_name":"height","restriction":""},{"name":"map","external_name":"map","restriction":""},{"name":"map_x","external_name":"map_x","restriction":""},{"name":"map_y","external_name":"map_y","restriction":""}],"visibility":"Public","body":"_ = RepeatView(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":53,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L53"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":"adjusted_x = ((x - @half_width) + @map_x).clamp(0, @map.width - 1)\nadjusted_y = ((y - @half_height) + @map_y).clamp(0, @map.height - 1)\n@map[(adjusted_y * @map.width) + adjusted_x]\n"}}]},{"html_id":"Crystal Image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/rgba_image.cr","line_number":2,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L2"},{"filename":"src/jpeg.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/jpeg.cr#L4"},{"filename":"src/pluto.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L36"},{"filename":"src/png.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/png.cr#L4"},{"filename":"src/stumpy.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L29"},{"filename":"src/webp.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/webp.cr#L4"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/Format/JPEG","kind":"module","full_name":"CrImage::Format::JPEG","name":"JPEG"},{"html_id":"Crystal Image/CrImage/Format/PNG","kind":"module","full_name":"CrImage::Format::PNG","name":"PNG"},{"html_id":"Crystal Image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"Crystal Image/CrImage/Format/WebP","kind":"module","full_name":"CrImage::Format::WebP","name":"WebP"},{"html_id":"Crystal Image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"Crystal Image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"Crystal Image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"Crystal Image/CrImage/Operation/Pad","kind":"module","full_name":"CrImage::Operation::Pad","name":"Pad"},{"html_id":"Crystal Image/CrImage/Operation/Rotate","kind":"module","full_name":"CrImage::Operation::Rotate","name":"Rotate"},{"html_id":"Crystal Image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"Crystal Image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"An image with red, green, blue, and alpha color channels (i.e. a color image). This image type is likely the one read from and written to file (or `IO`).","summary":"

An image with red, green, blue, and alpha color channels (i.e.

","constructors":[{"html_id":"from_jpeg(image_data:Bytes):self-class-method","name":"from_jpeg","doc":"Read `image_data` as JPEG encoded bytes","summary":"

Read image_data as JPEG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_jpeg","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"handle = LibJPEGTurbo.init_decompress\ncheck_jpeg(handle, LibJPEGTurbo.decompress_header3(handle, image_data, image_data.size, out width, out height, out _subsampling, out _colorspace))\nbuffer = Bytes.new((width * height) * 3, 0)\ncheck_jpeg(handle, LibJPEGTurbo.decompress2(handle, image_data, LibC::ULong.new(image_data.size), buffer, width, 0, height, LibJPEGTurbo::PixelFormat::RGB, 0))\ncheck_jpeg(handle, LibJPEGTurbo.destroy(handle))\nred = Array.new(width * height) do\n ChannelType::Red.default\nend\ngreen = Array.new(width * height) do\n ChannelType::Green.default\nend\nblue = Array.new(width * height) do\n ChannelType::Blue.default\nend\nalpha = Array.new(width * height) do\n ChannelType::Alpha.default\nend\n(width * height).times do |index|\n red.unsafe_put(index, buffer[index * 3])\n green.unsafe_put(index, buffer[(index * 3) + 1])\n blue.unsafe_put(index, buffer[(index * 3) + 2])\nend\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_jpeg(io:IO):self-class-method","name":"from_jpeg","doc":"Construct an Image from reading in bytes from `io`","summary":"

Construct an Image from reading in bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_jpeg","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_jpeg(io.getb_to_end)"}},{"html_id":"from_png(image_data:Bytes):self-class-method","name":"from_png","doc":"Read `image_data` and PNG encoded bytes","summary":"

Read image_data and PNG encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_png","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"ctx = LibSPNG.ctx_new(LibSPNG::CtxFlags::None)\nif ctx\nelse\n raise(::CrImage::Exception.new(\"Failed to create a context\"))\nend\nLibSPNG.set_png_buffer(ctx, image_data, image_data.size)\ncheck_png(LibSPNG.get_ihdr(ctx, out ihdr))\ncheck_png(LibSPNG.decoded_image_size(ctx, LibSPNG::Format::RGBA8, out image_size))\nimage = Bytes.new(image_size.to_i, 0_u8)\ncheck_png(LibSPNG.decode_image(ctx, image, image_size, LibSPNG::Format::RGBA8, LibSPNG::DecodeFlags::None))\nLibSPNG.ctx_free(ctx)\nsize = image_size // 4\nwidth = size // ihdr.height\nheight = ihdr.height\nred = Array.new(size) do\n 0_u8\nend\ngreen = Array.new(size) do\n 0_u8\nend\nblue = Array.new(size) do\n 0_u8\nend\nalpha = Array.new(size) do\n 0_u8\nend\nsize.times do |index|\n position = index * 4\n red.unsafe_put(index, image[position + 0])\n green.unsafe_put(index, image[position + 1])\n blue.unsafe_put(index, image[position + 2])\n alpha.unsafe_put(index, image[position + 3])\nend\nnew(red, green, blue, alpha, width.to_i, height.to_i)\n"}},{"html_id":"from_png(io:IO):self-class-method","name":"from_png","doc":"Construct an Image by reading bytes from `io`","summary":"

Construct an Image by reading bytes from io

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_png","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_png(io.getb_to_end)"}},{"html_id":"from_ppm(image_data:Bytes):self-class-method","name":"from_ppm","doc":"Read `image_data` as PPM encoded bytes","summary":"

Read image_data as PPM encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_ppm","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"from_ppm(IO::Memory.new(image_data))"}},{"html_id":"from_ppm(io:IO):self-class-method","name":"from_ppm","doc":"Read bytes from `io` as PPM encoded","summary":"

Read bytes from io as PPM encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_ppm","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"_magic_number = io.gets(\"\\n\", chomp: true)\nwidth = (io.gets(\" \", chomp: true)).try(&.to_i)\nheight = (io.gets(\"\\n\", chomp: true)).try(&.to_i)\n_maximum_color_value = io.gets(\"\\n\", chomp: true)\nif width && height\n red = Array.new(width * height) do\n ChannelType::Red.default\n end\n green = Array.new(width * height) do\n ChannelType::Green.default\n end\n blue = Array.new(width * height) do\n ChannelType::Blue.default\n end\n alpha = Array.new(width * height) do\n ChannelType::Alpha.default\n end\n (width * height).times do |index|\n red_byte = io.read_byte\n green_byte = io.read_byte\n blue_byte = io.read_byte\n if (red_byte && green_byte) && blue_byte\n red.unsafe_put(index, red_byte)\n green.unsafe_put(index, green_byte)\n blue.unsafe_put(index, blue_byte)\n else\n raise(\"The image ends prematurely\")\n end\n end\n new(red, green, blue, alpha, width, height)\nelse\n raise(\"The image doesn't have width or height\")\nend\n"}},{"html_id":"from_webp(image_data:Bytes):self-class-method","name":"from_webp","doc":"Read `image_data` as WebP encoded bytes","summary":"

Read image_data as WebP encoded bytes

","abstract":false,"args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"args_string":"(image_data : Bytes) : self","args_html":"(image_data : Bytes) : self","def":{"name":"from_webp","args":[{"name":"image_data","external_name":"image_data","restriction":"Bytes"}],"return_type":"self","visibility":"Public","body":"check_webp(LibWebP.get_info(image_data, image_data.size, out width, out height))\nbuffer = LibWebP.decode_rgba(image_data, image_data.size, pointerof(width), pointerof(height))\nred = Array.new(width * height) do\n 0_u8\nend\ngreen = Array.new(width * height) do\n 0_u8\nend\nblue = Array.new(width * height) do\n 0_u8\nend\nalpha = Array.new(width * height) do\n 0_u8\nend\n(width * height).times do |index|\n position = index * 4\n red.unsafe_put(index, buffer[position])\n green.unsafe_put(index, buffer[position + 1])\n blue.unsafe_put(index, buffer[position + 2])\n alpha.unsafe_put(index, buffer[position + 3])\nend\nLibWebP.free(buffer)\nnew(red, green, blue, alpha, width, height)\n"}},{"html_id":"from_webp(io:IO):self-class-method","name":"from_webp","doc":"Read bytes from `io` as WebP encoded","summary":"

Read bytes from io as WebP encoded

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : self","args_html":"(io : IO) : self","def":{"name":"from_webp","args":[{"name":"io","external_name":"io","restriction":"IO"}],"return_type":"self","visibility":"Public","body":"from_webp(io.getb_to_end)"}},{"html_id":"new(red:Array(UInt8),green:Array(UInt8),blue:Array(UInt8),alpha:Array(UInt8),width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","args_html":"(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L10"},"def":{"name":"new","args":[{"name":"red","external_name":"red","restriction":"::Array(::UInt8)"},{"name":"green","external_name":"green","restriction":"::Array(::UInt8)"},{"name":"blue","external_name":"blue","restriction":"::Array(::UInt8)"},{"name":"alpha","external_name":"alpha","restriction":"::Array(::UInt8)"},{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(red, green, blue, alpha, width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(width:Int32,height:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32)","args_html":"(width : Int32, height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L13"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(width, height)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):Color-instance-method","name":"[]","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : Color","args_html":"(x : Int32, y : Int32) : Color","location":{"filename":"src/cr-image/rgba_image.cr","line_number":49,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L49"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"Color","visibility":"Public","body":"index = (y * width) + x\nColor.new(red[index], green[index], blue[index], alpha[index])\n"}},{"html_id":"[](channel_type:ChannelType):Array(UInt8)-instance-method","name":"[]","doc":"Return the channel corresponding to `channel_type`","summary":"

Return the channel corresponding to channel_type

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"args_string":"(channel_type : ChannelType) : Array(UInt8)","args_html":"(channel_type : ChannelType) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L55"},"def":{"name":"[]","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red\nwhen ChannelType::Green\n @green\nwhen ChannelType::Blue\n @blue\nwhen ChannelType::Alpha\n @alpha\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"[]=(channel_type:ChannelType,channel:Array(UInt8)):Array(UInt8)-instance-method","name":"[]=","doc":"Set the corresponding `channel_type` with `channel`","summary":"

Set the corresponding channel_type with channel

","abstract":false,"args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"args_string":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","args_html":"(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":66,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L66"},"def":{"name":"[]=","args":[{"name":"channel_type","external_name":"channel_type","restriction":"ChannelType"},{"name":"channel","external_name":"channel","restriction":"Array(UInt8)"}],"return_type":"Array(UInt8)","visibility":"Public","body":"case channel_type\nwhen ChannelType::Red\n @red = channel\nwhen ChannelType::Green\n @green = channel\nwhen ChannelType::Blue\n @blue = channel\nwhen ChannelType::Alpha\n @alpha = channel\nelse\n raise(\"Unknown channel type #{channel_type} for RGBAImage\")\nend"}},{"html_id":"alpha:Array(UInt8)-instance-method","name":"alpha","doc":"Return the alpha channel","summary":"

Return the alpha channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha","return_type":"Array(UInt8)","visibility":"Public","body":"@alpha"}},{"html_id":"alpha=(alpha:Array(UInt8))-instance-method","name":"alpha=","abstract":false,"args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"args_string":"(alpha : Array(UInt8))","args_html":"(alpha : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L6"},"def":{"name":"alpha=","args":[{"name":"alpha","external_name":"alpha","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@alpha = alpha"}},{"html_id":"blue:Array(UInt8)-instance-method","name":"blue","doc":"Return the blue channel","summary":"

Return the blue channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue","return_type":"Array(UInt8)","visibility":"Public","body":"@blue"}},{"html_id":"blue=(blue:Array(UInt8))-instance-method","name":"blue=","abstract":false,"args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"args_string":"(blue : Array(UInt8))","args_html":"(blue : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L5"},"def":{"name":"blue=","args":[{"name":"blue","external_name":"blue","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@blue = blue"}},{"html_id":"clone:RGBAImage-instance-method","name":"clone","doc":"Create a copy of this image","summary":"

Create a copy of this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L21"},"def":{"name":"clone","return_type":"RGBAImage","visibility":"Public","body":"self.class.new(@red.clone, @green.clone, @blue.clone, @alpha.clone, @width, @height)"}},{"html_id":"each_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L41"},"def":{"name":"each_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nyield @alpha, ChannelType::Alpha\nnil\n"}},{"html_id":"each_color_channel(&:Array(UInt8),ChannelType->Nil):Nil-instance-method","name":"each_color_channel","doc":"Run provided block with the `ChannelType::Red`, `ChannelType::Green`, and `ChannelType::Blue` channels.","summary":"

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":33,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L33"},"def":{"name":"each_color_channel","yields":2,"block_arity":2,"block_arg":{"name":"","external_name":"","restriction":"(Array(UInt8), ChannelType -> Nil)"},"return_type":"Nil","visibility":"Public","body":"yield @red, ChannelType::Red\nyield @green, ChannelType::Green\nyield @blue, ChannelType::Blue\nnil\n"}},{"html_id":"green:Array(UInt8)-instance-method","name":"green","doc":"Return the green channel","summary":"

Return the green channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green","return_type":"Array(UInt8)","visibility":"Public","body":"@green"}},{"html_id":"green=(green:Array(UInt8))-instance-method","name":"green=","abstract":false,"args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"args_string":"(green : Array(UInt8))","args_html":"(green : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L4"},"def":{"name":"green=","args":[{"name":"green","external_name":"green","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@green = green"}},{"html_id":"height:Int32-instance-method","name":"height","doc":"Height of image","summary":"

Height of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"height=(height:Int32)-instance-method","name":"height=","abstract":false,"args":[{"name":"height","external_name":"height","restriction":"Int32"}],"args_string":"(height : Int32)","args_html":"(height : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L8"},"def":{"name":"height=","args":[{"name":"height","external_name":"height","restriction":"Int32"}],"visibility":"Public","body":"@height = height"}},{"html_id":"mask_from(&block:Color,Int32,Int32->Bool):Mask-instance-method","name":"mask_from","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":103,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L103"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Color, Int32, Int32 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"x = -1\ny = -1\nMask.new(width, BitArray.new(size) do |i|\n x = x + 1\n if x == width\n x = 0\n y = y + 1\n end\n block.call(Color.new(red.unsafe_fetch(i), green.unsafe_fetch(i), blue.unsafe_fetch(i), alpha.unsafe_fetch(i)), x, y)\nend)\n"}},{"html_id":"red:Array(UInt8)-instance-method","name":"red","doc":"Return the red channel","summary":"

Return the red channel

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red","return_type":"Array(UInt8)","visibility":"Public","body":"@red"}},{"html_id":"red=(red:Array(UInt8))-instance-method","name":"red=","abstract":false,"args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"args_string":"(red : Array(UInt8))","args_html":"(red : Array(UInt8))","location":{"filename":"src/cr-image/rgba_image.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L3"},"def":{"name":"red=","args":[{"name":"red","external_name":"red","restriction":"Array(UInt8)"}],"visibility":"Public","body":"@red = red"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the number of pixels in this image","summary":"

Return the number of pixels in this image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L99"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"to_gray(red_multiplier:Float=0.299,green_multiplier:Float=0.587,blue_multiplier:Float=0.114):GrayscaleImage-instance-method","name":"to_gray","doc":"Convert color image to `GrayscaleImage`, using the NTSC formula as default values.\n\n\"Woman\n\nBecomes\n\n\"Woman","summary":"

Convert color image to GrayscaleImage, using the NTSC formula as default values.

","abstract":false,"args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"args_string":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","args_html":"(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage","location":{"filename":"src/cr-image/rgba_image.cr","line_number":83,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L83"},"def":{"name":"to_gray","args":[{"name":"red_multiplier","default_value":"0.299","external_name":"red_multiplier","restriction":"Float"},{"name":"green_multiplier","default_value":"0.587","external_name":"green_multiplier","restriction":"Float"},{"name":"blue_multiplier","default_value":"0.114","external_name":"blue_multiplier","restriction":"Float"}],"return_type":"GrayscaleImage","visibility":"Public","body":"GrayscaleImage.new(red.map_with_index do |red_pix, i|\n (Math.min(255, ((red_pix * red_multiplier) + (@green[i] * green_multiplier)) + (@blue[i] * blue_multiplier))).to_u8\nend, width, height)"}},{"html_id":"to_pluto:Pluto::ImageRGBA-instance-method","name":"to_pluto","abstract":false,"location":{"filename":"src/pluto.cr","line_number":37,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L37"},"def":{"name":"to_pluto","return_type":"Pluto::ImageRGBA","visibility":"Public","body":"Pluto::ImageRGBA.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}},{"html_id":"to_rgba:RGBAImage-instance-method","name":"to_rgba","doc":"Returns self","summary":"

Returns self

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":94,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L94"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"self"}},{"html_id":"to_stumpy:StumpyCore::Canvas-instance-method","name":"to_stumpy","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L30"},"def":{"name":"to_stumpy","return_type":"StumpyCore::Canvas","visibility":"Public","body":"StumpyCore::Canvas.new(width, height) do |x, y|\n color = self[x, y]\n StumpyCore::RGBA.new(color.red.to_u16 << 8, color.green.to_u16 << 8, color.blue.to_u16 << 8, color.alpha.to_u16 << 8)\nend"}},{"html_id":"width:Int32-instance-method","name":"width","doc":"Width of image","summary":"

Width of image

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}},{"html_id":"width=(width:Int32)-instance-method","name":"width=","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"Int32"}],"args_string":"(width : Int32)","args_html":"(width : Int32)","location":{"filename":"src/cr-image/rgba_image.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"Crystal Image/CrImage/UInt8Map","path":"CrImage/UInt8Map.html","kind":"class","full_name":"CrImage::UInt8Map","name":"UInt8Map","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"},{"html_id":"Crystal Image/CrImage/NumericMap","kind":"module","full_name":"CrImage::NumericMap","name":"NumericMap"},{"html_id":"Crystal Image/CrImage/Map","kind":"module","full_name":"CrImage::Map","name":"Map"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/map.cr","line_number":495,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L495"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/CrImage/MapImpl","kind":"module","full_name":"CrImage::MapImpl","name":"MapImpl"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Implementation of `MapImpl` for `UInt8` types. This type is useful for `MapImpl` operations around channels.","summary":"

Implementation of MapImpl for UInt8 types.

","instance_methods":[{"html_id":"to_f:FloatMap-instance-method","name":"to_f","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":502,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L502"},"def":{"name":"to_f","return_type":"FloatMap","visibility":"Public","body":"FloatMap.new(width, @raw.map(&.to_f))"}},{"html_id":"to_i:IntMap-instance-method","name":"to_i","abstract":false,"location":{"filename":"src/cr-image/map.cr","line_number":498,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L498"},"def":{"name":"to_i","return_type":"IntMap","visibility":"Public","body":"IntMap.new(width, @raw.map(&.to_i))"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/cr-image/map.cr","line_number":496,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/map.cr#L496"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" def \n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n : self\n self.class.new(width, @raw.map(&.\n{{ call.name.id }}\n{% if call.args.size > 0 %}({{ (call.args.join(\", \")).id }}){% end %}\n))\n \nend\n \n"}}]},{"html_id":"Crystal Image/CrImage/Window","path":"CrImage/Window.html","kind":"class","full_name":"CrImage::Window(T)","name":"Window","abstract":true,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cr-image/window_view.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L8"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"Crystal Image/CrImage/BlackView","kind":"class","full_name":"CrImage::BlackView(T)","name":"BlackView"},{"html_id":"Crystal Image/CrImage/ErrorView","kind":"class","full_name":"CrImage::ErrorView(T)","name":"ErrorView"},{"html_id":"Crystal Image/CrImage/RepeatView","kind":"class","full_name":"CrImage::RepeatView(T)","name":"RepeatView"}],"namespace":{"html_id":"Crystal Image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Represents a read-only view on top of a `Map`.\n\nConstructing one of these over a larger `Map` allows for a re-indexed view within that map. If needing to sum all values\nwithin a certain area, a `Window` can be constructed around that area and then summed from that.\n\nSee `RepeatView`, `ErrorView`, and `BlackView` for specific edge handling cases.","summary":"

Represents a read-only view on top of a Map.

","constructors":[{"html_id":"new(width:Int32,height:Int32,map:CrImage::Map(T),map_x:Int32,map_y:Int32)-class-method","name":"new","abstract":false,"args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"args_string":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","args_html":"(width : Int32, height : Int32, map : CrImage::Map(T), map_x : Int32, map_y : Int32)","location":{"filename":"src/cr-image/window_view.cr","line_number":17,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L17"},"def":{"name":"new","args":[{"name":"width","external_name":"width","restriction":"::Int32"},{"name":"height","external_name":"height","restriction":"::Int32"},{"name":"map","external_name":"map","restriction":"::CrImage::Map(T)"},{"name":"map_x","external_name":"map_x","restriction":"::Int32"},{"name":"map_y","external_name":"map_y","restriction":"::Int32"}],"visibility":"Public","body":"_ = Window(T).allocate\n_.initialize(width, height, map, map_x, map_y)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](x:Int32,y:Int32):T-instance-method","name":"[]","abstract":true,"args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"args_string":"(x : Int32, y : Int32) : T","args_html":"(x : Int32, y : Int32) : T","location":{"filename":"src/cr-image/window_view.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L22"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":"Int32"},{"name":"y","external_name":"y","restriction":"Int32"}],"return_type":"T","visibility":"Public","body":""}},{"html_id":"half_height:Int32-instance-method","name":"half_height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":10,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L10"},"def":{"name":"half_height","return_type":"Int32","visibility":"Public","body":"@half_height"}},{"html_id":"half_width:Int32-instance-method","name":"half_width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":9,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L9"},"def":{"name":"half_width","return_type":"Int32","visibility":"Public","body":"@half_width"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":12,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L12"},"def":{"name":"height","return_type":"Int32","visibility":"Public","body":"@height"}},{"html_id":"map:Map(T)-instance-method","name":"map","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":13,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L13"},"def":{"name":"map","return_type":"Map(T)","visibility":"Public","body":"@map"}},{"html_id":"map_x:Int32-instance-method","name":"map_x","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L14"},"def":{"name":"map_x","return_type":"Int32","visibility":"Public","body":"@map_x"}},{"html_id":"map_y:Int32-instance-method","name":"map_y","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":15,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L15"},"def":{"name":"map_y","return_type":"Int32","visibility":"Public","body":"@map_y"}},{"html_id":"mean:Float64-instance-method","name":"mean","doc":"Calculate the mean for all values in the window","summary":"

Calculate the mean for all values in the window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":41,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L41"},"def":{"name":"mean","return_type":"Float64","visibility":"Public","body":"sum / size"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Return the size of this window","summary":"

Return the size of this window

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":46,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L46"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"@width * @height"}},{"html_id":"sum:Float64-instance-method","name":"sum","doc":"Sum all values in the window together","summary":"

Sum all values in the window together

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":25,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L25"},"def":{"name":"sum","return_type":"Float64","visibility":"Public","body":"sum(&.itself)"}},{"html_id":"sum(&:T,Int32,Int32,self->T):Float64-instance-method","name":"sum","doc":"Iterate over all values within the window and sum the result of the passed in block","summary":"

Iterate over all values within the window and sum the result of the passed in block

","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":30,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L30"},"def":{"name":"sum","yields":4,"block_arity":4,"block_arg":{"name":"","external_name":"","restriction":"(T, Int32, Int32, self -> T)"},"return_type":"Float64","visibility":"Public","body":"ret = 0_f64\nheight.times do |y|\n width.times do |x|\n ret = ret + (yield self[x, y], x, y, self).to_f64\n end\nend\nret\n"}},{"html_id":"width:Int32-instance-method","name":"width","abstract":false,"location":{"filename":"src/cr-image/window_view.cr","line_number":11,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/cr-image/window_view.cr#L11"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]}]},{"html_id":"Crystal Image/Pluto","path":"Pluto.html","kind":"module","full_name":"Pluto","name":"Pluto","abstract":false,"locations":[{"filename":"lib/pluto/src/pluto.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto.cr#L3"},{"filename":"lib/pluto/src/pluto/channel_type.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/channel_type.cr#L1"},{"filename":"src/pluto.cr","line_number":20,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L20"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This project was initially a fork of [Pluto](https://github.com/phenopolis/pluto/), and so can very easily convert\nbetween the underlying format used by `CrImage` and `Pluto`. To easily convert a `Pluto` image to `CrImage`, simply:\n\n```\nrequire \"cr-image/pluto\"\n\nimage # => Pluto::ImageRGBA\nimage.to_crimage # => CrImage::RGBAImage\nimage.to_crimage.to_pluto # => Pluto::ImageRGBA\n```\nThis also works with `Pluto::ImageGA` and `CrImage::GrayscaleImage`, respectively.\n\n> Why are `ImageRGBA` and `RGBAImage` names mirrored?\n\nThe current `CrImage` names are a carry over from when originally forked from `Pluto`. However, after `Pluto` renamed `RGBAImage` to `ImageRGBA`, I noticed it became\nmore difficult to visually distinguish between `ImageRGBA` and `ImageGA`, as opposed to `RGBAImage` and `GrayscaleImage`, so I kept the older names.","summary":"

This project was initially a fork of Pluto, and so can very easily convert between the underlying format used by CrImage and Pluto.

","types":[{"html_id":"Crystal Image/Pluto/ImageGA","path":"Pluto/ImageGA.html","kind":"class","full_name":"Pluto::ImageGA","name":"ImageGA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_ga.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/image_ga.cr#L3"},{"filename":"src/pluto.cr","line_number":28,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L28"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::GrayscaleImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/pluto.cr","line_number":29,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L29"},"def":{"name":"to_crimage","return_type":"CrImage::GrayscaleImage","visibility":"Public","body":"new(gray.clone, alpha.clone, width, height)"}}]},{"html_id":"Crystal Image/Pluto/ImageRGBA","path":"Pluto/ImageRGBA.html","kind":"class","full_name":"Pluto::ImageRGBA","name":"ImageRGBA","abstract":false,"superclass":{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},"ancestors":[{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Image","kind":"class","full_name":"Pluto::Image","name":"Image"},{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/pluto/src/pluto/image_rgba.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/pluto/src/pluto/image_rgba.cr#L3"},{"filename":"src/pluto.cr","line_number":21,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L21"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"Crystal Image/Pluto/Format/PPM","kind":"module","full_name":"Pluto::Format::PPM","name":"PPM"},{"html_id":"Crystal Image/Pluto/Format/Stumpy","kind":"module","full_name":"Pluto::Format::Stumpy","name":"Stumpy"},{"html_id":"Crystal Image/Pluto/Operation/BilinearResize","kind":"module","full_name":"Pluto::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"Crystal Image/Pluto/Operation/BoxBlur","kind":"module","full_name":"Pluto::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"Crystal Image/Pluto/Operation/Brightness","kind":"module","full_name":"Pluto::Operation::Brightness","name":"Brightness"},{"html_id":"Crystal Image/Pluto/Operation/ChannelSwap","kind":"module","full_name":"Pluto::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"Crystal Image/Pluto/Operation/Contrast","kind":"module","full_name":"Pluto::Operation::Contrast","name":"Contrast"},{"html_id":"Crystal Image/Pluto/Operation/Crop","kind":"module","full_name":"Pluto::Operation::Crop","name":"Crop"},{"html_id":"Crystal Image/Pluto/Operation/GaussianBlur","kind":"module","full_name":"Pluto::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"Crystal Image/Pluto/Operation/HorizontalBlur","kind":"module","full_name":"Pluto::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"Crystal Image/Pluto/Operation/VerticalBlur","kind":"module","full_name":"Pluto::Operation::VerticalBlur","name":"VerticalBlur"}],"namespace":{"html_id":"Crystal Image/Pluto","kind":"module","full_name":"Pluto","name":"Pluto"},"instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","doc":"Con","summary":"

Con

","abstract":false,"location":{"filename":"src/pluto.cr","line_number":23,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/pluto.cr#L23"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"CrImage::RGBAImage.new(red.clone, green.clone, blue.clone, alpha.clone, width, height)"}}]}]},{"html_id":"Crystal Image/StumpyCore","path":"StumpyCore.html","kind":"module","full_name":"StumpyCore","name":"StumpyCore","abstract":false,"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":3,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/canvas.cr#L3"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba.cr","line_number":4,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba.cr#L4"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/css_constants.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_grayscale.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_hex.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_hsl_hsv.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_relative.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/from_rgba.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/rgba/mixing.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/rgba/mixing.cr#L1"},{"filename":"lib/stumpy_core/src/stumpy_core/utils.cr","line_number":1,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/utils.cr#L1"},{"filename":"src/stumpy.cr","line_number":5,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L5"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"A module owned by [StumpyCr](https://github.com/stumpycr/stumpy_core)","summary":"

A module owned by StumpyCr

","types":[{"html_id":"Crystal Image/StumpyCore/Canvas","path":"StumpyCore/Canvas.html","kind":"class","full_name":"StumpyCore::Canvas","name":"Canvas","abstract":false,"superclass":{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Crystal Image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Crystal Image/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"lib/stumpy_core/src/stumpy_core/canvas.cr","line_number":31,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/lib/stumpy_core/src/stumpy_core/canvas.cr#L31"},{"filename":"src/stumpy.cr","line_number":6,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L6"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/StumpyCore","kind":"module","full_name":"StumpyCore","name":"StumpyCore"},"doc":"A canvas is 2D array of `RGBA` pixels\n\nTo create a canvas of size `400` x `200`\n\n```\ncanvas = StumpyCore::Canvas.new(400, 200)\n```\n\nThe default background color is transparent,\nbut it can be passed in as a parameter or as a block\nthat returns the color value for each `{x, y}` pair.\n\n```\ncanvas2 = StumpyCore::Canvas.new(400, 200, RGBA::WHITE)\n```\n\n```\ncanvas3 = StumpyCore::Canvas.new(256, 256) do |x, y|\n RGBA.from_rgb_n(x, y, 255, 8)\nend\n```\n![image](https://github.com/stumpycr/stumpy_core/blob/feature/images/rainbow.png?raw=true)\n\nBecause of the way pixels are stored in a `Slice`,\n`Canvas`es are limited to `Int32::MAX = 2147483647` pixels in total,\ne.g. a maximal size of 46340x46340 for a square image.","summary":"

A canvas is 2D array of RGBA pixels

","instance_methods":[{"html_id":"to_crimage:CrImage::RGBAImage-instance-method","name":"to_crimage","abstract":false,"location":{"filename":"src/stumpy.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/stumpy.cr#L7"},"def":{"name":"to_crimage","return_type":"CrImage::RGBAImage","visibility":"Public","body":"size = width * height\nred = Array(UInt8).new(size)\ngreen = Array(UInt8).new(size)\nblue = Array(UInt8).new(size)\nalpha = Array(UInt8).new(size)\neach_row do |row|\n row.each do |rgba|\n red << (rgba.r >> 8).to_u8\n green << (rgba.g >> 8).to_u8\n blue << (rgba.b >> 8).to_u8\n alpha << (rgba.a >> 8).to_u8\n end\nend\nCrImage::RGBAImage.new(red, green, blue, alpha, width, height)\n"}}]}]},{"html_id":"Crystal Image/Tutorial","path":"Tutorial.html","kind":"module","full_name":"Tutorial","name":"Tutorial","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/chromakey_tutorial.cr#L35"},{"filename":"src/tutorials/tutorial.cr","line_number":7,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/tutorial.cr#L7"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"doc":"This fictional module exists to provide tutorials for using CrImage in the documentation\n\nSee:\n* `EdgeDetection`\n* `ChromaKey`\n* `FindDifferences`","summary":"

This fictional module exists to provide tutorials for using CrImage in the documentation

","types":[{"html_id":"Crystal Image/Tutorial/ChromaKey","path":"Tutorial/ChromaKey.html","kind":"module","full_name":"Tutorial::ChromaKey","name":"ChromaKey","abstract":false,"locations":[{"filename":"src/tutorials/chromakey_tutorial.cr","line_number":35,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/chromakey_tutorial.cr#L35"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can swap out the background by creating a mask representing the pixels that are close in color, and replacing them using an `MaskApply#apply_color` method.\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"sample.jpg\")\n\n# Grab a color from the background, for comparison\nbackground = image[10, 10]\n\n# Construct a mask of all pixels within a color distance of our background\nbackground_mask = image.mask_from do |color|\n # 25 chosen through trial-and-error\n color.dist(background) < 25\nend\n .closing! # Remove small `true` regions\n .opening! # Remove small `false` regions\n\n# Now make the background blue\nimage\n .apply_color(background_mask, CrImage::Color.of(\"#0000cc\"))\n .save(\"chromakey.jpg\")\n```\n\nResults in image:\n\n\"Background\n\nThis script ran on my machine in `4ms` in `--release` mode.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/EdgeDetection","path":"Tutorial/EdgeDetection.html","kind":"module","full_name":"Tutorial::EdgeDetection","name":"EdgeDetection","abstract":false,"locations":[{"filename":"src/tutorials/edge_detection_tutorial.cr","line_number":38,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/edge_detection_tutorial.cr#L38"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `sample.jpg` image:\n\n\"Woman\n\nWe can run the [Sobel Operator](https://en.wikipedia.org/wiki/Sobel_operator) to detect edges in it:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nvertical_sobel = CrImage::IntMap.new([\n [-1, -2, -1],\n [0, 0, 0],\n [1, 2, 1],\n])\n\nhorizontal_sobel = CrImage::IntMap.new([\n [-1, 0, 1],\n [-2, 0, 2],\n [-1, 0, 1],\n])\n\nimage = CrImage::GrayscaleImage.open(\"sample.jpg\")\n\ndx = image.cross_correlate(horizontal_sobel)\ndy = image.cross_correlate(vertical_sobel)\n\n(dx ** 2 + dy ** 2).to_gray(scale: true).save(\"edge_detection.jpg\")\n```\n\nResults in image:\n\n\"Black\n\nThis script ran on my machine in `11ms` in `--release` mode.\n\n**Note**: This tutorial is using `cross_correlate`. For large images (or medium-to-large operators), the `cross_correlate_fft` may perform better.","summary":"

Given sample.jpg image:

"},{"html_id":"Crystal Image/Tutorial/FindDifferences","path":"Tutorial/FindDifferences.html","kind":"module","full_name":"Tutorial::FindDifferences","name":"FindDifferences","abstract":false,"locations":[{"filename":"src/tutorials/find_differences.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9f94688246a16a0c8211ce88453f158c8e691b8/src/tutorials/find_differences.cr#L55"}],"repository_name":"Crystal Image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"Crystal Image/Tutorial","kind":"module","full_name":"Tutorial","name":"Tutorial"},"doc":"Given `differences.jpg` image:\n\n\"Two\n\nWe can programatically detect _most_ of the differences between these two images:\n\n```\nrequire \"cr-image\"\nrequire \"cr-image/jpeg\"\n\nimage = CrImage::RGBAImage.open(\"differences.jpg\")\nret = image.clone\n\n# Perform a blur to remove random noise\nimg1 = image.gaussian_blur(1)[2...340, ..]\nimg2 = image.gaussian_blur(1)[361...699, ..]\n\n# Convert each color channel into a IntMap\nred_img1 = CrImage::UInt8Map.new(img1.width, img1.red).to_i\ngre_img1 = CrImage::UInt8Map.new(img1.width, img1.green).to_i\nblu_img1 = CrImage::UInt8Map.new(img1.width, img1.blue).to_i\nred_img2 = CrImage::UInt8Map.new(img2.width, img2.red).to_i\ngre_img2 = CrImage::UInt8Map.new(img2.width, img2.green).to_i\nblu_img2 = CrImage::UInt8Map.new(img2.width, img2.blue).to_i\n\n# Calculate a pixel by pixel difference calculation, convert it to a `Mask`\nred_mask = (red_img1 - red_img2).abs.>(50)\ngre_mask = (gre_img1 - gre_img2).abs.>(50)\nblu_mask = (blu_img1 - blu_img2).abs.>(50)\n\n# Combine the different color channel masks\ncombo_mask = (red_mask | blu_mask | gre_mask).dilate!\n\n# Expensive way to make a thick box.\n3.times do\n combo_mask.dilate!.segments.each do |v|\n # Draw a box in the first image\n ret.draw_square!(v.region.x + 2, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n # ... and the second image\n ret.draw_square!(v.region.x + 361, v.region.y, v.region.width, v.region.height, CrImage::Color.of(\"#f00\"))\n end\nend\n\nret.save(\"differences_end.jpg\")\n```\n\nResults in image:\n\n\"Two\n\nThis script ran on my machine in `66ms` in `--release` mode.\n\n**NOTE**: There's a difference in the seeds on one of the watermelons that don't survive the blurring process, and so aren't picked\nup by the differences algorithm above.","summary":"

Given differences.jpg image:

"}]}]}}) \ No newline at end of file