-

-Crystal Image (Processing)

+

Crystal Image (Processing)

This shard aims to provide feature rich image processing abilities, both for the purpose of image manipulation as well as feature / information extraction from those images.

The code here takes imense inspiration from Pluto and Stumpy, with diff --git a/docs/index.json b/docs/index.json index 1b06261..200b77e 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"cr-image","body":"# [Crystal Image (Processing)](http://troy.sornson.io/cr-image/)\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 takes imense inspiration from [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core), with\nan eventual goal to be able to convert between images of this and 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\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 documentation](http://troy.sornson.io/cr-image/) for more examples.\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":"cr-image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"cr-image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/region.cr#L1"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"cr-image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"cr-image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L4"}],"repository_name":"cr-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":"cr-image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_channel` and `GrayscaleImage#each_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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"cr-image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=255)-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":"255","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"255","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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L45"},"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":12,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L12"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), 255_u8)\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":89,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L89"},"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":25,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L25"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"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":18,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L18"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"cr-image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/exception.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/save.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}] of Nil"}],"namespace":{"html_id":"cr-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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/open.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/ppm.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/save.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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"}}]}]},{"html_id":"cr-image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L28"},"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"}}],"instance_methods":[{"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":70,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L70"},"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":80,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L80"},"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":58,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L58"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":53,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L53"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.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::Gray` and `ChannelType::Alpha` channels and channel types.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L63"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":48,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L48"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":112,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L112"},"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":123,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L123"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(&block:Int32,Int32,UInt8->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 |x, y, pixel|\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/grayscale_image.cr","line_number":141,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L141"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n block.call(i % width, i // width, @gray[i])\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":43,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L43"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L101"},"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":160,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |_, _, pixel|\n pixel >= threshold\nend"}},{"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":96,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L96"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"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":91,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"cr-image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L3"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":51,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L51"},"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":53,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L53"},"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":39,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L39"},"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":37,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L37"},"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":48,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L48"},"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":"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":35,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L35"},"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":43,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L43"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L33"},"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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L45"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L41"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L39"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":49,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L49"},"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":61,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L61"},"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(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":77,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L77"},"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"}},{"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":67,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L67"},"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":44,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L44"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L54"},"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"}}],"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":166,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L166"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"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":136,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L136"},"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":142,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L142"},"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":148,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L148"},"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":156,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L156"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","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.map do |y|\n BitArray.new(count_x) do |x|\n self[x + start_x, y + start_y]\n end\nend\n"}},{"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":186,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L186"},"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":198,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L198"},"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":214,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L214"},"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":231,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L231"},"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":"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":247,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L247"},"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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","args_html":"(image : Image, &block : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":252,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L252"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8, ChannelType -> 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":124,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L124"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L41"},"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":95,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L95"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L99"},"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":117,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L117"},"def":{"name":"invert","visibility":"Public","body":"new_bits = @bits.dup\nnew_bits.invert\nMask.new(width, new_bits)\n"}},{"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":110,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L110"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"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":274,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L274"},"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":342,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L342"},"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":172,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L172"},"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":"size(*args,**options)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L92"},"def":{"name":"size","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"bits.size(*args, **options)"}},{"html_id":"size(*args,**options,&)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L92"},"def":{"name":"size","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":"bits.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"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":242,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L242"},"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":40,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L40"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/operation.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/crop.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32),yrange:Range(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32)):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"args_string":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","args_html":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"if (x + new_width) > width\n raise(\"Crop dimensions extend #{(x + new_width) - width} pixels beyond width of the image (#{width})\")\nend\nif (y + new_height) > height\n raise(\"Crop dimensions extend #{(y + new_height) - height} pixels beyond height of the image (#{height})\")\nend\nnew_size = new_width * new_height\nheight_offset = y * width\neach_channel do |channel, channel_type|\n resized_channel = Array.new(new_size) do\n 0_u8\n end\n new_height.times do |new_y|\n orig_index = (height_offset + (new_y * width)) + x\n resized_channel[new_y * new_width, new_width] = channel[orig_index, new_width]\n end\n self[channel_type] = resized_channel\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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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":15,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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\"))\n```\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","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":56,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L56"},"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":52,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L52"},"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!(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":61,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L61"},"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_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":20,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L20"},"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":16,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L16"},"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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L28"},"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} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{(y + box_height) - height} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_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, 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":24,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L24"},"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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":93,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L93"},"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":97,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L97"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L101"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_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":"cr-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":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":22,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L22"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L54"},"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":"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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L28"},"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":64,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L64"},"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":"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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L45"},"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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(value)"}},{"html_id":"horizontal_blur!(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_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_channel do |channel|\n @height.times do |y|\n c_index : Int32 = y * @width\n l_index : Int32 = c_index\n r_index : Int32 = c_index + value\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch((c_index + @width) - 1)).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n c_index = c_index + 1\n end\n ((value + 1)..((@width - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n l_index = l_index + 1\n c_index = c_index + 1\n end\n ((@width - value)..(@width - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + 1\n c_index = c_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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 |x, y, pixel, channel_type|\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/d9bed74afca3be04ae53d091c3e1305befa3d314/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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"(Int32, Int32, UInt8, ChannelType -> 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/d9bed74afca3be04ae53d091c3e1305befa3d314/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:Int32,Int32,UInt8,ChannelType->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"(Int32, Int32, UInt8, ChannelType -> 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(i % width, i // width, pixel, channel_type)) || 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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_channel do |channel|\n @width.times do |x|\n c_index : Int32 = x\n l_index : Int32 = c_index\n r_index : Int32 = c_index + (value * @width)\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch(c_index + (@width * (@height - 1)))).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n c_index = c_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"cr-image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/region.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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"}}],"instance_methods":[{"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":35,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L35"},"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":46,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L46"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L14"},"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`, `ChannelType::Blue`, and `ChannelType::Alpha` channels.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L26"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":74,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L74"},"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":63,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L63"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]}]}]}} \ No newline at end of file +{"repository_name":"cr-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 takes imense inspiration from [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core), with\nan eventual goal to be able to convert between images of this and 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\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 documentation](http://troy.sornson.io/cr-image/) for more examples.\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":"cr-image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"cr-image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/region.cr#L1"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"cr-image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"cr-image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L4"}],"repository_name":"cr-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":"cr-image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_channel` and `GrayscaleImage#each_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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"cr-image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=255)-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":"255","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"255","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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L45"},"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":12,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L12"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), 255_u8)\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":89,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L89"},"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":25,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L25"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"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":18,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L18"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"cr-image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/exception.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/save.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}] of Nil"}],"namespace":{"html_id":"cr-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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/open.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/ppm.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/save.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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"}}]}]},{"html_id":"cr-image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L28"},"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"}}],"instance_methods":[{"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":70,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L70"},"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":80,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L80"},"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":58,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L58"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":53,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L53"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.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::Gray` and `ChannelType::Alpha` channels and channel types.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L63"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":48,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L48"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":112,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L112"},"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":123,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L123"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(&block:Int32,Int32,UInt8->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 |x, y, pixel|\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/grayscale_image.cr","line_number":141,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L141"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n block.call(i % width, i // width, @gray[i])\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":43,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L43"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L101"},"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":160,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |_, _, pixel|\n pixel >= threshold\nend"}},{"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":96,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L96"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"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":91,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"cr-image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L3"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":51,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L51"},"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":53,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L53"},"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":39,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L39"},"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":37,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L37"},"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":48,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L48"},"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":"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":35,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L35"},"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":43,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L43"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L33"},"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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L45"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L41"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L39"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":49,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L49"},"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":61,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L61"},"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(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":77,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L77"},"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"}},{"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":67,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L67"},"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":44,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L44"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L54"},"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"}}],"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":166,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L166"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"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":136,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L136"},"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":142,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L142"},"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":148,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L148"},"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":156,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L156"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","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.map do |y|\n BitArray.new(count_x) do |x|\n self[x + start_x, y + start_y]\n end\nend\n"}},{"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":186,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L186"},"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":198,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L198"},"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":214,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L214"},"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":231,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L231"},"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":"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":247,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L247"},"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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","args_html":"(image : Image, &block : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":252,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L252"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8, ChannelType -> 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":124,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L124"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L41"},"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":95,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L95"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L99"},"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":117,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L117"},"def":{"name":"invert","visibility":"Public","body":"new_bits = @bits.dup\nnew_bits.invert\nMask.new(width, new_bits)\n"}},{"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":110,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L110"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"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":274,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L274"},"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":342,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L342"},"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":172,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L172"},"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":"size(*args,**options)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L92"},"def":{"name":"size","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"bits.size(*args, **options)"}},{"html_id":"size(*args,**options,&)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L92"},"def":{"name":"size","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":"bits.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"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":242,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L242"},"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":40,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L40"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/operation.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/crop.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32),yrange:Range(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32)):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"args_string":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","args_html":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"if (x + new_width) > width\n raise(\"Crop dimensions extend #{(x + new_width) - width} pixels beyond width of the image (#{width})\")\nend\nif (y + new_height) > height\n raise(\"Crop dimensions extend #{(y + new_height) - height} pixels beyond height of the image (#{height})\")\nend\nnew_size = new_width * new_height\nheight_offset = y * width\neach_channel do |channel, channel_type|\n resized_channel = Array.new(new_size) do\n 0_u8\n end\n new_height.times do |new_y|\n orig_index = (height_offset + (new_y * width)) + x\n resized_channel[new_y * new_width, new_width] = channel[orig_index, new_width]\n end\n self[channel_type] = resized_channel\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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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":15,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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\"))\n```\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","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":56,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L56"},"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":52,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L52"},"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!(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":61,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L61"},"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_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":20,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L20"},"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":16,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L16"},"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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L28"},"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} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{(y + box_height) - height} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_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, 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":24,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L24"},"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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":93,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L93"},"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":97,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L97"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L101"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_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":"cr-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":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":22,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L22"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L54"},"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":"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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L28"},"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":64,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L64"},"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":"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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L45"},"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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(value)"}},{"html_id":"horizontal_blur!(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_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_channel do |channel|\n @height.times do |y|\n c_index : Int32 = y * @width\n l_index : Int32 = c_index\n r_index : Int32 = c_index + value\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch((c_index + @width) - 1)).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n c_index = c_index + 1\n end\n ((value + 1)..((@width - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n l_index = l_index + 1\n c_index = c_index + 1\n end\n ((@width - value)..(@width - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + 1\n c_index = c_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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 |x, y, pixel, channel_type|\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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"(Int32, Int32, UInt8, ChannelType -> 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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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:Int32,Int32,UInt8,ChannelType->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"(Int32, Int32, UInt8, ChannelType -> 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(i % width, i // width, pixel, channel_type)) || 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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_channel do |channel|\n @width.times do |x|\n c_index : Int32 = x\n l_index : Int32 = c_index\n r_index : Int32 = c_index + (value * @width)\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch(c_index + (@width * (@height - 1)))).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n c_index = c_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"cr-image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/region.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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"}}],"instance_methods":[{"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":35,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L35"},"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":46,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L46"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L14"},"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`, `ChannelType::Blue`, and `ChannelType::Alpha` channels.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L26"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":74,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L74"},"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":63,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L63"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]}]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index 85092c1..f672978 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"cr-image","body":"# [Crystal Image (Processing)](http://troy.sornson.io/cr-image/)\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 takes imense inspiration from [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core), with\nan eventual goal to be able to convert between images of this and 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\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 documentation](http://troy.sornson.io/cr-image/) for more examples.\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":"cr-image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"cr-image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/region.cr#L1"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"cr-image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"cr-image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L4"}],"repository_name":"cr-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":"cr-image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_channel` and `GrayscaleImage#each_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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"cr-image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=255)-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":"255","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"255","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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L45"},"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":12,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L12"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), 255_u8)\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":89,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L89"},"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":25,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L25"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"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":18,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L18"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"cr-image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/exception.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/save.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}] of Nil"}],"namespace":{"html_id":"cr-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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/open.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/ppm.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/format/save.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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"}}]}]},{"html_id":"cr-image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L28"},"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"}}],"instance_methods":[{"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":70,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L70"},"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":80,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L80"},"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":58,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L58"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":53,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L53"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.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::Gray` and `ChannelType::Alpha` channels and channel types.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L63"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":48,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L48"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":112,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L112"},"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":123,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L123"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(&block:Int32,Int32,UInt8->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 |x, y, pixel|\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/grayscale_image.cr","line_number":141,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L141"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n block.call(i % width, i // width, @gray[i])\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":43,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L43"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L101"},"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":160,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |_, _, pixel|\n pixel >= threshold\nend"}},{"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":96,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L96"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"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":91,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"cr-image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L3"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":51,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L51"},"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":53,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L53"},"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":39,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L39"},"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":37,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L37"},"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":48,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L48"},"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":"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":35,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L35"},"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":43,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L43"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L33"},"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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L45"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/image.cr#L41"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L39"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":49,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L49"},"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":61,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L61"},"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(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":77,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L77"},"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"}},{"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":67,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L67"},"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":44,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L44"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L54"},"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"}}],"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":166,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L166"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"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":136,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L136"},"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":142,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L142"},"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":148,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L148"},"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":156,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L156"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","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.map do |y|\n BitArray.new(count_x) do |x|\n self[x + start_x, y + start_y]\n end\nend\n"}},{"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":186,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L186"},"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":198,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L198"},"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":214,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L214"},"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":231,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L231"},"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":"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":247,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L247"},"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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","args_html":"(image : Image, &block : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":252,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L252"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8, ChannelType -> 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":124,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L124"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L41"},"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":95,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L95"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L99"},"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":117,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L117"},"def":{"name":"invert","visibility":"Public","body":"new_bits = @bits.dup\nnew_bits.invert\nMask.new(width, new_bits)\n"}},{"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":110,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L110"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"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":274,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L274"},"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":342,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L342"},"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":172,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L172"},"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":"size(*args,**options)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L92"},"def":{"name":"size","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"bits.size(*args, **options)"}},{"html_id":"size(*args,**options,&)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L92"},"def":{"name":"size","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":"bits.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"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":242,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L242"},"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":40,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/mask.cr#L40"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/operation.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/crop.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32),yrange:Range(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32)):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"args_string":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","args_html":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"if (x + new_width) > width\n raise(\"Crop dimensions extend #{(x + new_width) - width} pixels beyond width of the image (#{width})\")\nend\nif (y + new_height) > height\n raise(\"Crop dimensions extend #{(y + new_height) - height} pixels beyond height of the image (#{height})\")\nend\nnew_size = new_width * new_height\nheight_offset = y * width\neach_channel do |channel, channel_type|\n resized_channel = Array.new(new_size) do\n 0_u8\n end\n new_height.times do |new_y|\n orig_index = (height_offset + (new_y * width)) + x\n resized_channel[new_y * new_width, new_width] = channel[orig_index, new_width]\n end\n self[channel_type] = resized_channel\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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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":15,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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\"))\n```\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","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":56,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L56"},"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":52,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L52"},"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!(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":61,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L61"},"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_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":20,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L20"},"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":16,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L16"},"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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L28"},"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} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{(y + box_height) - height} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_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, 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":24,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/draw.cr#L24"},"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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":93,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L93"},"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":97,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L97"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L101"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_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":"cr-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":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":22,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L22"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L54"},"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":"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":28,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L28"},"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":64,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L64"},"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":"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":45,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/histogram.cr#L45"},"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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(value)"}},{"html_id":"horizontal_blur!(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_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_channel do |channel|\n @height.times do |y|\n c_index : Int32 = y * @width\n l_index : Int32 = c_index\n r_index : Int32 = c_index + value\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch((c_index + @width) - 1)).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n c_index = c_index + 1\n end\n ((value + 1)..((@width - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n l_index = l_index + 1\n c_index = c_index + 1\n end\n ((@width - value)..(@width - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + 1\n c_index = c_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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 |x, y, pixel, channel_type|\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/d9bed74afca3be04ae53d091c3e1305befa3d314/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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"(Int32, Int32, UInt8, ChannelType -> 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/d9bed74afca3be04ae53d091c3e1305befa3d314/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:Int32,Int32,UInt8,ChannelType->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"(Int32, Int32, UInt8, ChannelType -> 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(i % width, i // width, pixel, channel_type)) || 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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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_channel do |channel|\n @width.times do |x|\n c_index : Int32 = x\n l_index : Int32 = c_index\n r_index : Int32 = c_index + (value * @width)\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch(c_index + (@width * (@height - 1)))).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n c_index = c_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"cr-image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/region.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"cr-image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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"}}],"instance_methods":[{"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":35,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L35"},"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":46,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L46"},"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":14,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L14"},"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`, `ChannelType::Blue`, and `ChannelType::Alpha` channels.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L26"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/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":74,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L74"},"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":63,"url":"https://github.com/Vici37/cr-image/blob/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L63"},"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":"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/d9bed74afca3be04ae53d091c3e1305befa3d314/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/d9bed74afca3be04ae53d091c3e1305befa3d314/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"cr-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 takes imense inspiration from [Pluto](https://github.com/phenopolis/pluto) and [Stumpy](https://github.com/stumpycr/stumpy_core), with\nan eventual goal to be able to convert between images of this and 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\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 documentation](http://troy.sornson.io/cr-image/) for more examples.\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":"cr-image/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"cr-image","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage","path":"CrImage.html","kind":"module","full_name":"CrImage","name":"CrImage","abstract":false,"locations":[{"filename":"src/cr-image/operation/bilinear_resize.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/region.cr#L1"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"types":[{"html_id":"cr-image/CrImage/ChannelType","path":"CrImage/ChannelType.html","kind":"enum","full_name":"CrImage::ChannelType","name":"ChannelType","abstract":false,"ancestors":[{"html_id":"cr-image/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"cr-image/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L4"}],"repository_name":"cr-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":"cr-image/CrImage","kind":"module","full_name":"CrImage","name":"CrImage"},"doc":"Enum representing different image channels supported by CrImage\n\nSee `RGBAImage#each_channel` and `GrayscaleImage#each_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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L7"},"def":{"name":"blue?","visibility":"Public","body":"self == Blue"}},{"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/channel_type.cr#L5"},"def":{"name":"red?","visibility":"Public","body":"self == Red"}}]},{"html_id":"cr-image/CrImage/Color","path":"CrImage/Color.html","kind":"class","full_name":"CrImage::Color","name":"Color","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"new(red:UInt8,green:UInt8,blue:UInt8,alpha:UInt8=255)-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":"255","external_name":"alpha","restriction":"UInt8"}],"args_string":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","args_html":"(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = 255)","location":{"filename":"src/cr-image/color.cr","line_number":8,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"255","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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L45"},"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":12,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L12"},"def":{"name":"random","return_type":"Color","visibility":"Public","body":"r = Random.new\nnew(r.rand(UInt8), r.rand(UInt8), r.rand(UInt8), 255_u8)\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":89,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L89"},"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":25,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L25"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L6"},"def":{"name":"blue","visibility":"Public","body":"@blue"}},{"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":18,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L18"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/color.cr#L6"},"def":{"name":"red","visibility":"Public","body":"@red"}}]},{"html_id":"cr-image/CrImage/Exception","path":"CrImage/Exception.html","kind":"class","full_name":"CrImage::Exception","name":"Exception","abstract":false,"superclass":{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"cr-image/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/exception.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/exception.cr#L3"},"def":{"name":"error_code","return_type":"Int32 | ::Nil","visibility":"Public","body":"@error_code"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/save.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SUPPORTED_FORMATS","name":"SUPPORTED_FORMATS","value":"[{extension: \".ppm\", method: \"ppm\"}] of Nil"}],"namespace":{"html_id":"cr-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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/open.cr#L12"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/ppm.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/format/save.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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"}}]}]},{"html_id":"cr-image/CrImage/GrayscaleImage","path":"CrImage/GrayscaleImage.html","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L28"},"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"}}],"instance_methods":[{"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":70,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L70"},"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":80,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L80"},"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":58,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L58"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":53,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L53"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L33"},"def":{"name":"clone","return_type":"GrayscaleImage","visibility":"Public","body":"self.class.new(@gray.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::Gray` and `ChannelType::Alpha` channels and channel types.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/grayscale_image.cr","line_number":63,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L63"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":48,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L48"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":112,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L112"},"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":123,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L123"},"def":{"name":"invert!","visibility":"Public","body":"@gray.map! do |pix|\n 255_u8 - pix\nend\nself\n"}},{"html_id":"mask_from(&block:Int32,Int32,UInt8->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 |x, y, pixel|\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/grayscale_image.cr","line_number":141,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L141"},"def":{"name":"mask_from","yields":3,"block_arity":3,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8 -> Bool)"},"return_type":"Mask","visibility":"Public","body":"Mask.new(width, BitArray.new(size) do |i|\n block.call(i % width, i // width, @gray[i])\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":43,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L43"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L101"},"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":160,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L160"},"def":{"name":"threshold","args":[{"name":"threshold","external_name":"threshold","restriction":"Int"}],"return_type":"Mask","visibility":"Public","body":"mask_from do |_, _, pixel|\n pixel >= threshold\nend"}},{"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":96,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L96"},"def":{"name":"to_gray","return_type":"GrayscaleImage","visibility":"Public","body":"self"}},{"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":91,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L91"},"def":{"name":"to_rgba","return_type":"RGBAImage","visibility":"Public","body":"RGBAImage.new(@gray.clone, @gray.clone, @gray.clone, @alpha.clone, width, height)"}},{"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/grayscale_image.cr#L16"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]},{"html_id":"cr-image/CrImage/Image","path":"CrImage/Image.html","kind":"class","full_name":"CrImage::Image","name":"Image","abstract":true,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L3"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":51,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L51"},"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":53,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L53"},"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":39,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L39"},"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":37,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L37"},"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":48,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L48"},"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":"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":35,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L35"},"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":43,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L43"},"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":33,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L33"},"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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L45"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/image.cr#L41"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-image/CrImage/Mask","path":"CrImage/Mask.html","kind":"class","full_name":"CrImage::Mask","name":"Mask","abstract":false,"superclass":{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L39"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":49,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L49"},"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":61,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L61"},"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(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":77,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L77"},"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"}},{"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":67,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L67"},"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":44,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L44"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L54"},"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"}}],"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":166,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L166"},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"Mask"}],"visibility":"Public","body":"(width == other.width) && (bits == other.bits)"}},{"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":136,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L136"},"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":142,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L142"},"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":148,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L148"},"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":156,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L156"},"def":{"name":"[]","args":[{"name":"xs","external_name":"xs","restriction":"Range"},{"name":"ys","external_name":"ys","restriction":"Range"}],"return_type":"Array(BitArray)","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.map do |y|\n BitArray.new(count_x) do |x|\n self[x + start_x, y + start_y]\n end\nend\n"}},{"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":186,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L186"},"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":198,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L198"},"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":214,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L214"},"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":231,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L231"},"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":"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":247,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L247"},"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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","args_html":"(image : Image, &block : Int32, Int32, UInt8, ChannelType -> UInt8) : Image","location":{"filename":"src/cr-image/mask.cr","line_number":252,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L252"},"def":{"name":"apply","args":[{"name":"image","external_name":"image","restriction":"Image"}],"yields":4,"block_arity":4,"block_arg":{"name":"block","external_name":"block","restriction":"(Int32, Int32, UInt8, ChannelType -> 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":124,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L124"},"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":41,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L41"},"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":95,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L95"},"def":{"name":"clone","visibility":"Public","body":"Mask.new(width, bits.dup)"}},{"html_id":"height:Int32-instance-method","name":"height","abstract":false,"location":{"filename":"src/cr-image/mask.cr","line_number":99,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L99"},"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":117,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L117"},"def":{"name":"invert","visibility":"Public","body":"new_bits = @bits.dup\nnew_bits.invert\nMask.new(width, new_bits)\n"}},{"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":110,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L110"},"def":{"name":"invert!","visibility":"Public","body":"@bits.invert\nclear_caches\nself\n"}},{"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":274,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L274"},"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":342,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L342"},"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":172,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L172"},"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":"size(*args,**options)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L92"},"def":{"name":"size","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"bits.size(*args, **options)"}},{"html_id":"size(*args,**options,&)-instance-method","name":"size","doc":"How many bits are stored in this `Mask`","summary":"

How many bits are stored in this Mask

","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/cr-image/mask.cr","line_number":92,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L92"},"def":{"name":"size","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":"bits.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"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":242,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L242"},"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":40,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/mask.cr#L40"},"def":{"name":"width","return_type":"Int32","visibility":"Public","body":"@width"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/operation.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/bilinear_resize.cr#L14"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/box_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/brightness.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/channel_swap.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/contrast.cr#L11"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/crop.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32),yrange:Range(Int32,Int32)|Range(Int32,Nil)|Range(Nil,Int32)):self-instance-method","name":"[]","abstract":false,"args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"args_string":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","args_html":"(xrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32), yrange : Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)) : self","location":{"filename":"src/cr-image/operation/crop.cr","line_number":22,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/crop.cr#L22"},"def":{"name":"[]","args":[{"name":"xrange","external_name":"xrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"},{"name":"yrange","external_name":"yrange","restriction":"Range(Int32, Int32) | Range(Int32, Nil) | Range(Nil, Int32)"}],"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"if (x + new_width) > width\n raise(\"Crop dimensions extend #{(x + new_width) - width} pixels beyond width of the image (#{width})\")\nend\nif (y + new_height) > height\n raise(\"Crop dimensions extend #{(y + new_height) - height} pixels beyond height of the image (#{height})\")\nend\nnew_size = new_width * new_height\nheight_offset = y * width\neach_channel do |channel, channel_type|\n resized_channel = Array.new(new_size) do\n 0_u8\n end\n new_height.times do |new_y|\n orig_index = (height_offset + (new_y * width)) + x\n resized_channel[new_y * new_width, new_width] = channel[orig_index, new_width]\n end\n self[channel_type] = resized_channel\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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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":15,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L15"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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\"))\n```\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","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":56,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L56"},"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":52,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L52"},"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!(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":61,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L61"},"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_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":20,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L20"},"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":16,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L16"},"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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L28"},"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} pixels beyond width of the image (#{width})\")\nend\nif (y + box_height) > height\n raise(\"Box dimensions extend #{(y + box_height) - height} pixels beyond height of the image (#{height})\")\nend\nx_i = x.to_i\ny_i = y.to_i\neach_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, 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":24,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/draw.cr#L24"},"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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/gaussian_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L19"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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":93,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L93"},"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":97,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L97"},"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":101,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L101"},"def":{"name":"histogram_equalize!","return_type":"self","visibility":"Public","body":"each_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":"cr-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":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L21"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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":22,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L22"},"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":54,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L54"},"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":"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":28,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L28"},"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":64,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L64"},"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":"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":45,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/histogram.cr#L45"},"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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L14"},"def":{"name":"horizontal_blur","args":[{"name":"value","external_name":"value","restriction":"Int32"}],"return_type":"self","visibility":"Public","body":"clone.horizontal_blur!(value)"}},{"html_id":"horizontal_blur!(value:Int32):self-instance-method","name":"horizontal_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/horizontal_blur.cr","line_number":18,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/horizontal_blur.cr#L18"},"def":{"name":"horizontal_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_channel do |channel|\n @height.times do |y|\n c_index : Int32 = y * @width\n l_index : Int32 = c_index\n r_index : Int32 = c_index + value\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch((c_index + @width) - 1)).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n c_index = c_index + 1\n end\n ((value + 1)..((@width - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + 1\n l_index = l_index + 1\n c_index = c_index + 1\n end\n ((@width - value)..(@width - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + 1\n c_index = c_index + 1\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/mask_apply.cr#L27"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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 |x, y, pixel, channel_type|\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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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:Int32,Int32,UInt8,ChannelType->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 : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":36,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"(Int32, Int32, UInt8, ChannelType -> 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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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:Int32,Int32,UInt8,ChannelType->UInt8|Nil):self-instance-method","name":"apply!","abstract":false,"args":[{"name":"mask","external_name":"mask","restriction":"Mask"}],"args_string":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","args_html":"(mask : Mask, &block : Int32, Int32, UInt8, ChannelType -> UInt8 | Nil) : self","location":{"filename":"src/cr-image/operation/mask_apply.cr","line_number":55,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"(Int32, Int32, UInt8, ChannelType -> 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(i % width, i // width, pixel, channel_type)) || 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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/operation/vertical_blur.cr#L13"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"cr-image/CrImage/GrayscaleImage","kind":"class","full_name":"CrImage::GrayscaleImage","name":"GrayscaleImage"},{"html_id":"cr-image/CrImage/RGBAImage","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage"}],"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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_channel do |channel|\n @width.times do |x|\n c_index : Int32 = x\n l_index : Int32 = c_index\n r_index : Int32 = c_index + (value * @width)\n f_value : Int32 = (channel.unsafe_fetch(c_index)).to_i\n l_value : Int32 = (channel.unsafe_fetch(c_index + (@width * (@height - 1)))).to_i\n c_value : Int32 = (value + 1) * f_value\n (0..(value - 1)).each do\n c_value = c_value + (channel.unsafe_fetch(c_index))\n end\n (0..value).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - f_value)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((value + 1)..((@height - value) - 1)).each do\n c_value = c_value + ((channel.unsafe_fetch(r_index)).to_i - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n r_index = r_index + @width\n c_index = c_index + @width\n end\n ((@height - value)..(@height - 1)).each do\n c_value = c_value + (l_value - (channel.unsafe_fetch(l_index)).to_i)\n buffer.unsafe_put(c_index, ((c_value * multiplier).clamp(0, 255)).to_u8)\n l_index = l_index + @width\n c_index = c_index + @width\n end\n end\n (channel.@buffer).copy_from(buffer.to_unsafe, buffer.size)\nend\nself\n"}}]}]},{"html_id":"cr-image/CrImage/Region","path":"CrImage/Region.html","kind":"struct","full_name":"CrImage::Region","name":"Region","abstract":false,"superclass":{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"cr-image/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"cr-image/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/region.cr#L5"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"cr-image/CrImage/RGBAImage","path":"CrImage/RGBAImage.html","kind":"class","full_name":"CrImage::RGBAImage","name":"RGBAImage","abstract":false,"superclass":{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},"ancestors":[{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Image","kind":"class","full_name":"CrImage::Image","name":"Image"},{"html_id":"cr-image/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"cr-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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L2"}],"repository_name":"cr-image","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"cr-image/CrImage/Format/PPM","kind":"module","full_name":"CrImage::Format::PPM","name":"PPM"},{"html_id":"cr-image/CrImage/Format/Save","kind":"module","full_name":"CrImage::Format::Save","name":"Save"},{"html_id":"cr-image/CrImage/Operation/BilinearResize","kind":"module","full_name":"CrImage::Operation::BilinearResize","name":"BilinearResize"},{"html_id":"cr-image/CrImage/Operation/BoxBlur","kind":"module","full_name":"CrImage::Operation::BoxBlur","name":"BoxBlur"},{"html_id":"cr-image/CrImage/Operation/Brightness","kind":"module","full_name":"CrImage::Operation::Brightness","name":"Brightness"},{"html_id":"cr-image/CrImage/Operation/ChannelSwap","kind":"module","full_name":"CrImage::Operation::ChannelSwap","name":"ChannelSwap"},{"html_id":"cr-image/CrImage/Operation/Contrast","kind":"module","full_name":"CrImage::Operation::Contrast","name":"Contrast"},{"html_id":"cr-image/CrImage/Operation/Crop","kind":"module","full_name":"CrImage::Operation::Crop","name":"Crop"},{"html_id":"cr-image/CrImage/Operation/Draw","kind":"module","full_name":"CrImage::Operation::Draw","name":"Draw"},{"html_id":"cr-image/CrImage/Operation/GaussianBlur","kind":"module","full_name":"CrImage::Operation::GaussianBlur","name":"GaussianBlur"},{"html_id":"cr-image/CrImage/Operation/HistogramEqualize","kind":"module","full_name":"CrImage::Operation::HistogramEqualize","name":"HistogramEqualize"},{"html_id":"cr-image/CrImage/Operation/HorizontalBlur","kind":"module","full_name":"CrImage::Operation::HorizontalBlur","name":"HorizontalBlur"},{"html_id":"cr-image/CrImage/Operation/MaskApply","kind":"module","full_name":"CrImage::Operation::MaskApply","name":"MaskApply"},{"html_id":"cr-image/CrImage/Operation/VerticalBlur","kind":"module","full_name":"CrImage::Operation::VerticalBlur","name":"VerticalBlur"}],"extended_modules":[{"html_id":"cr-image/CrImage/Format/Open","kind":"module","full_name":"CrImage::Format::Open","name":"Open"}],"namespace":{"html_id":"cr-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_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 0_u8\n end\n green = Array.new(width * height) do\n 0_u8\n end\n blue = Array.new(width * height) do\n 0_u8\n end\n alpha = Array.new(width * height) do\n 255_u8\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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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"}}],"instance_methods":[{"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":35,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L35"},"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":46,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L46"},"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":14,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L14"},"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`, `ChannelType::Blue`, and `ChannelType::Alpha` channels.","summary":"

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

","abstract":false,"location":{"filename":"src/cr-image/rgba_image.cr","line_number":26,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L26"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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":74,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L74"},"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":63,"url":"https://github.com/Vici37/cr-image/blob/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L63"},"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":"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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/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/058a55cab939a7442a43c0b19c5a129e0ed5c02a/src/cr-image/rgba_image.cr#L7"},"def":{"name":"width=","args":[{"name":"width","external_name":"width","restriction":"Int32"}],"visibility":"Public","body":"@width = width"}}]}]}]}}) \ No newline at end of file