ねこりべ
Last version:
DOWNLOAD (attachment .lua):
NekoLib is a (right now) simple library written in pure LÖVE for image manipulation.
It is system independent, and easy to use.
You may use it within your programs without having to adapt it to the library.
You only need to do require "neko" to have access to all lib functionalities.
1.- What NekoLib does exactly?
What NekoLib do is to process any image and return the processed result.
Because NekoLib was done having into account multiple and consecutive filters applies, you may pass to the filters a path to an image or a variable with ImageData data.
This way, you can process multiple times any ImageData without having to save and load the image.
Some sample images:
Original image:
http://holaandroid.com/wp-content/uploa ... rvalds.jpg
Sepia image for all image size: Image with green colors removed Face green colors values replaced with blues values and contrast increased: Face noisificated with RGB noise and then colors inverted:
2.- How can I apply a filter to an image with NekoLib?
It's so simple that even a 2-yo kid would be able to do that!!!
- The first thing to do is to download NekoLib (see attachment below) and save the file to your project folder.
- Next, in your main.lua file add a line in the top like require "neko".
- Finally, you can summon any filter from anywhere in your code. All filters will require you to specify the image to be modified, the X and Y position of the image to start the filtering and the width and height of the part of the image to be filtered.
For example, I have an image that is 600x600, but I can tell NekoLib to only modify an area of 200x200 where the top-left corner in in x=75, y=400
With a real example:
myImage = neko.grayscale("someImage.png", 100, 100, 400, 250) <<== This will convert to grayscale a zone in the image from (100,100) to (500,350)
myImage = neko.sepia("someImage.png", 0, 0, 600, 600) <<== If the original image was 600x600, then this will convert to sepia color all image.
But some other more complex filters will require more arguments, so you should read the API reference to know all this info.
Also, we said that NekoLib was created to allow batch image processing, so you can apply multiple and consecutive filters to the same image without having to save it to hard dist and load again.
When you apply a filter to an image, NekoLib will return always an ImageData value, which is the modified image, so you can do:
myImage = neko.invert("someImage.png", 0, 0, 600, 600)
myImage = neko.sepia(myImage, 0, 0, 600, 600)
So you will have into myImage a color-inverted and sepia-recolored image, instead of the original one.
One important thing to remember is: images start at (0, 0) and end at image_width - 1 and imageHeight - 1!!!!!
3.- List of filters and brief description:
This is the place you should come to review all filters provided by NekoLib.
neko.sepia( <imagePath>, <x>, <y>, <w>, <h> )
Converts the image to sepia colors
neko.invert( <imagePath>, <x>, <y>, <w>, <h> )
Inverts the colors in the image
neko.grayscale( <imagePath>, <x>, <y>, <w>, <h>, [<mode>: "max"|"min"] )
Turns the image to gray scale colors, using mid colors (default), max values or min values.
neko.remove( <imagePath>, <x>, <y>, <w>, <h>, <color>: "r"|"g"|"b" )
Removes <color> from the image in the RGB values, making it zero.
neko.bright( <imagePath>, <x>, <y>, <w>, <h>, [<amount>] )
Set the <brightness> level to the image to the specified <amount>
neko.alpha( <imagePath>, <x>, <y>, <w>, <h>, [<amount>:(0..255)] )
Sets the <alpha> value to the image to the specified <amount>
neko.contrast( <imagePath>, <x>, <y>, <w>, <h>, [<amount>:(-255..255)] )
Changes image <contrast> to the specified <amount>
neko.sink( <imagePath>, <x>, <y>, <w>, <h>, [<amount>:(0..255)], [<threshold>:(0..255)] )
Reduces by the specified <amount> the colors that are at or below the specified <threshold>
neko.replace( <imagePath>, <x>, <y>, <w>, <h>, <target>:"r"|"g"|"b", <color>:"r"|"g"|"b" )
Replaces <target> color value in the RGB value with <color> color value in the RGB color value.
Ex: neko.replace("image.png", 0, 0, 100, 100, "r", "g") <= replaces red value with the value in green
neko.noise( <imagePath>, <x>, <y>, <w>, <h>, [<threshold>:(0, 100)], [<noRGB>:true|false] )
Generates random RGB noise with a chance of <threshold>. Setting <noRGB> to true will generate gray scale noise instead.
neko.colorToAlpha( <imagePath>, <x>, <y>, <w>, <h>, [<color>:"r"|"g"|"b"], [<alpha>:(0..255)] )
Sets the <alpha> value to the specified, for the <color>, when this <color> value is higher that any other in the RGB color value.