-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\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
\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
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
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

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
Read bytes from io
as PPM encoded
Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray
)
Create a GrayscaleImage with only an Array(UInt8)
(alpha channel initialized as 255
throughout)
Return the Array(UInt8)
corresponding to channel_type
Set the underlying Array(UInt8)
of channel_type
to the new channel
.
Return #alpha
channel
Return the "#blue
" channel (returns #gray
)
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.
Return the "#green
" channel (returns #gray
)
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

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


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


Construct a Mask
from this GrayscaleImage
using the passed in block to determine if a given pixel should be true or not
Return the "#red
" channel (returns #gray
)
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

Construct a simple threshold Mask
containing all pixels with a UInt8
value greater than #threshold
Given sample image:
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
.
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
.
Get the Array(UInt8)
corresponding to channel_type
)
Set the Array(UInt8)
corresponding to channel_type
) to channel
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
)
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
Construct a new Mask
from an integer (useful for testing or small mask construction)
Construct a new Mask
from an array of BitArray
.
Construct a new Mask
from the dimensions of passed in image
with an initial bit
Construct a new Mask
with a set width and bits from #bits
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)
Return the bit at x
and y
Return a new BitArray
corresponding to the partial row specified
Return a new BitArray
corresponding to the partial column specified
Return an Array(BitArray)
for the partial box (of partial rows and partial columns) of this mask.

Set the bit for coordinate x
and y

Set the bits for partial row xs
at column y

Set the bits for row x
and partial columns ys

Set the bits for partial rows xs
and partial columns ys
Apply this mask to the provided image with Operation::MaskApply#apply
Apply this mask to the provided image with Operation::MaskApply#apply
Return the bit at index
Create a new Mask
from this one without modifying it
Return a new Mask
that's a copy of this one with all bits inverted.


Invert all bits in this instance of Mask
.

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





Return an array of Mask
s, each one corresponding to an area of contiguous true bits (identified from flood fills).
Set the bit for coordinate x
and y
How many bits are stored in this Mask
How many bits are stored in this Mask
Convert this Mask
to a GrayscaleImage
, with false bits becoming 0, and true bits becoming 255
Module for containing individual operations for Image
classes.



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


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

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

Swaps channels of ChannelType
supported by an image


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

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


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
)
Draw a circle around the region's center (see Region#center
)



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




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
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


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




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


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
.
Return the {x, y}
tuple of the center coordinates of this Region
Crop a provided Image
with this region, using Operation::Crop#crop
Return this Region
as a #x
, #y
, #width
, and #height
tuple
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
Read bytes from io
as PPM encoded
Return the channel corresponding to channel_type
Set the corresponding channel_type
with channel
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.
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

Convert color image to GrayscaleImage
, using the NTSC formula as default values.
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

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
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
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

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
Read bytes from io
as PPM encoded
Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray
)
Create a GrayscaleImage with only an Array(UInt8)
(alpha channel initialized as 255
throughout)
Return the Array(UInt8)
corresponding to channel_type
Set the underlying Array(UInt8)
of channel_type
to the new channel
.
Return #alpha
channel
Return the "#blue
" channel (returns #gray
)
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.
Return the "#green
" channel (returns #gray
)
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

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


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


Construct a Mask
from this GrayscaleImage
using the passed in block to determine if a given pixel should be true or not
Return the "#red
" channel (returns #gray
)
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

Construct a simple threshold Mask
containing all pixels with a UInt8
value greater than #threshold
Given sample image:
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
.
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
.
Get the Array(UInt8)
corresponding to channel_type
)
Set the Array(UInt8)
corresponding to channel_type
) to channel
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
)
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
Construct a new Mask
from an integer (useful for testing or small mask construction)
Construct a new Mask
from an array of BitArray
.
Construct a new Mask
from the dimensions of passed in image
with an initial bit
Construct a new Mask
with a set width and bits from #bits
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)
Return the bit at x
and y
Return a new BitArray
corresponding to the partial row specified
Return a new BitArray
corresponding to the partial column specified
Return an Array(BitArray)
for the partial box (of partial rows and partial columns) of this mask.

Set the bit for coordinate x
and y

Set the bits for partial row xs
at column y

Set the bits for row x
and partial columns ys

Set the bits for partial rows xs
and partial columns ys
Apply this mask to the provided image with Operation::MaskApply#apply
Apply this mask to the provided image with Operation::MaskApply#apply
Return the bit at index
Create a new Mask
from this one without modifying it
Return a new Mask
that's a copy of this one with all bits inverted.


Invert all bits in this instance of Mask
.

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





Return an array of Mask
s, each one corresponding to an area of contiguous true bits (identified from flood fills).
Set the bit for coordinate x
and y
How many bits are stored in this Mask
How many bits are stored in this Mask
Convert this Mask
to a GrayscaleImage
, with false bits becoming 0, and true bits becoming 255
Module for containing individual operations for Image
classes.



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


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

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

Swaps channels of ChannelType
supported by an image


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

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


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
)
Draw a circle around the region's center (see Region#center
)



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




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
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


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




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


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
.
Return the {x, y}
tuple of the center coordinates of this Region
Crop a provided Image
with this region, using Operation::Crop#crop
Return this Region
as a #x
, #y
, #width
, and #height
tuple
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
Read bytes from io
as PPM encoded
Return the channel corresponding to channel_type
Set the corresponding channel_type
with channel
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.
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

Convert color image to GrayscaleImage
, using the NTSC formula as default values.
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

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
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
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

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
Read bytes from io
as PPM encoded
Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray
)
Create a GrayscaleImage with only an Array(UInt8)
(alpha channel initialized as 255
throughout)
Return the Array(UInt8)
corresponding to channel_type
Set the underlying Array(UInt8)
of channel_type
to the new channel
.
Return #alpha
channel
Return the "#blue
" channel (returns #gray
)
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.
Return the "#green
" channel (returns #gray
)
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

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


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


Construct a Mask
from this GrayscaleImage
using the passed in block to determine if a given pixel should be true or not
Return the "#red
" channel (returns #gray
)
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

Construct a simple threshold Mask
containing all pixels with a UInt8
value greater than #threshold
Given sample image:
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
.
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
.
Get the Array(UInt8)
corresponding to channel_type
)
Set the Array(UInt8)
corresponding to channel_type
) to channel
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
)
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
Construct a new Mask
from an integer (useful for testing or small mask construction)
Construct a new Mask
from an array of BitArray
.
Construct a new Mask
from the dimensions of passed in image
with an initial bit
Construct a new Mask
with a set width and bits from #bits
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)
Return the bit at x
and y
Return a new BitArray
corresponding to the partial row specified
Return a new BitArray
corresponding to the partial column specified
Return an Array(BitArray)
for the partial box (of partial rows and partial columns) of this mask.

Set the bit for coordinate x
and y

Set the bits for partial row xs
at column y

Set the bits for row x
and partial columns ys

Set the bits for partial rows xs
and partial columns ys
Apply this mask to the provided image with Operation::MaskApply#apply
Apply this mask to the provided image with Operation::MaskApply#apply
Return the bit at index
Create a new Mask
from this one without modifying it
Return a new Mask
that's a copy of this one with all bits inverted.


Invert all bits in this instance of Mask
.

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





Return an array of Mask
s, each one corresponding to an area of contiguous true bits (identified from flood fills).
Set the bit for coordinate x
and y
How many bits are stored in this Mask
How many bits are stored in this Mask
Convert this Mask
to a GrayscaleImage
, with false bits becoming 0, and true bits becoming 255
Module for containing individual operations for Image
classes.



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


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

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

Swaps channels of ChannelType
supported by an image


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

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


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
)
Draw a circle around the region's center (see Region#center
)



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




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
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


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




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


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
.
Return the {x, y}
tuple of the center coordinates of this Region
Crop a provided Image
with this region, using Operation::Crop#crop
Return this Region
as a #x
, #y
, #width
, and #height
tuple
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
Read bytes from io
as PPM encoded
Return the channel corresponding to channel_type
Set the corresponding channel_type
with channel
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.
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

Convert color image to GrayscaleImage
, using the NTSC formula as default values.
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

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
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
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

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
Read bytes from io
as PPM encoded
Create a GrayscaleImage from a set of color channels (delegates to RGBAImage#to_gray
)
Create a GrayscaleImage with only an Array(UInt8)
(alpha channel initialized as 255
throughout)
Return the Array(UInt8)
corresponding to channel_type
Set the underlying Array(UInt8)
of channel_type
to the new channel
.
Return #alpha
channel
Return the "#blue
" channel (returns #gray
)
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.
Return the "#green
" channel (returns #gray
)
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

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


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


Construct a Mask
from this GrayscaleImage
using the passed in block to determine if a given pixel should be true or not
Return the "#red
" channel (returns #gray
)
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

Construct a simple threshold Mask
containing all pixels with a UInt8
value greater than #threshold
Given sample image:
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
.
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
.
Get the Array(UInt8)
corresponding to channel_type
)
Set the Array(UInt8)
corresponding to channel_type
) to channel
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
)
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
Construct a new Mask
from an integer (useful for testing or small mask construction)
Construct a new Mask
from an array of BitArray
.
Construct a new Mask
from the dimensions of passed in image
with an initial bit
Construct a new Mask
with a set width and bits from #bits
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)
Return the bit at x
and y
Return a new BitArray
corresponding to the partial row specified
Return a new BitArray
corresponding to the partial column specified
Return an Array(BitArray)
for the partial box (of partial rows and partial columns) of this mask.

Set the bit for coordinate x
and y

Set the bits for partial row xs
at column y

Set the bits for row x
and partial columns ys

Set the bits for partial rows xs
and partial columns ys
Apply this mask to the provided image with Operation::MaskApply#apply
Apply this mask to the provided image with Operation::MaskApply#apply
Return the bit at index
Create a new Mask
from this one without modifying it
Return a new Mask
that's a copy of this one with all bits inverted.


Invert all bits in this instance of Mask
.

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





Return an array of Mask
s, each one corresponding to an area of contiguous true bits (identified from flood fills).
Set the bit for coordinate x
and y
How many bits are stored in this Mask
How many bits are stored in this Mask
Convert this Mask
to a GrayscaleImage
, with false bits becoming 0, and true bits becoming 255
Module for containing individual operations for Image
classes.



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


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

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

Swaps channels of ChannelType
supported by an image


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

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


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
)
Draw a circle around the region's center (see Region#center
)



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




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
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


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




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


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
.
Return the {x, y}
tuple of the center coordinates of this Region
Crop a provided Image
with this region, using Operation::Crop#crop
Return this Region
as a #x
, #y
, #width
, and #height
tuple
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
Read bytes from io
as PPM encoded
Return the channel corresponding to channel_type
Set the corresponding channel_type
with channel
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.
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

Convert color image to GrayscaleImage
, using the NTSC formula as default values.
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