Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pablo1n7/imageform

Small Lib for basic Image processing.
https://github.com/pablo1n7/imageform

image-processing pharo pharo-smalltalk

Last synced: 8 days ago
JSON representation

Small Lib for basic Image processing.

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/pablo1n7/ImageForm.svg?branch=master)](https://travis-ci.org/pablo1n7/ImageForm)

# ImageForm

Small Lib for basic Image processing. Programmed in Pharo for Pharo :)

# Install

```smalltalk
Metacello new
baseline: #ImageForm;
repository: 'github://pablo1n7/ImageForm/src';
load.
```

# Basic Operations

## Open an Image.

```smalltalk
anImage := ImageForm open: '/Users/sdas/Documents/pwq7S.jpg'.
```



## Show Image.
```smalltalk
anImage show: 'Eileen Collins'.
```
![](https://raw.githubusercontent.com/pablo1n7/ImageForm/master/examples/show.jpg)

## Save Image.
```smalltalk
aScaledImage save:'/Users/pablo/Documents/Pharo/pwq7S_scaled.jpg'.
aScaledImage save:'/Users/pablo/Documents/Pharo/pwq7S_scaled.png'.
```

# Color Operations

## Transform to Gray Scale.
```smalltalk
aGrayImage := anImage asGrayScale
```
or

```smalltalk
aGrayImage := ImageFormGrayScale open: '/Users/sdas/Documents/pwq7S.jpg'.
```



## Lighter Image.
```smalltalk
aLighterImage := anImageForm lighter:0.25.
```



## Darker Image.
```smalltalk
aDarkerImage := anImageForm darker:0.25.
```



## Negated Image.
```smalltalk
aNegatedImage := anImage negated .
```



# Image Transformations.

## Flip Image.
```smalltalk
aFlippedImage := anImage flipHorizontally.
```



```smalltalk
aFlippedImage := anImage flipVertically.
```



## Rotate Image.
```smalltalk
aRotatedImage := anImage rotateBy: 45.
```



```smalltalk
aRotatedImage := anImage rotateBy: #left centerAt: 0@0.
```



## Scale Image.
```smalltalk
aScaledImage := anImageA scaled: 100 height: 100.
```



## Crop Image.
```smalltalk
aCroppedImage := anImageForm crop: 0@0 h: 300 w: 500.
```



# Basic Arithmetics.
```smalltalk
anImageA := ImageForm open: '/Users/sdas/Documents/pwq7S.jpg'.
anImageB := ImageForm open: '/Users/sdas/Documents/pharo.png'.

aSubResult := anImageB - anImageA.
```



```smalltalk
aSumResult := anImageB + anImageA.
```



# Advanced Operations
## Operations with kernels (3x3 and 5x5)

```smalltalk
anImage := ImageForm open: '/Users/pablo/Documents/pharo/pharo.png'.
aGaussianKernel := {{ 1/256. 4/256. 6/256. 4/256. 1/256. }.
{ 4/256. 16/256. 24/256. 16/256. 4/256.}.
{ 6/256. 24/256. 36/256. 24/256. 6/256. }.
{ 4/256. 16/256. 24/256. 16/256. 4/256. }.
{ 1/256. 4/256. 6/256. 4/256. 1/256. }.}.
aResult := anImage applyKernel: aGaussianKernel flattened .
```



```smalltalk
anImage := ImageForm open: '/Users/pablo/Documents/pharo/pharo.png'.
aGrayImage := anImage asGrayScale.
aSobelKernel := {{-0.1. -0.1. -0.1}.
{ -0.1. 0.80. -0.1}.
{-0.1. -0.1. -0.1}}.
aResult := aGrayImage applyKernel: aSobelKernel flattened .
```



# Gray Scale Operations

```smalltalk
anImage := ImageForm open: '/Users/pablo/Documents/pharo/icon.png'.
aGrayImage := anImage asGrayScale.
```

## Transform to Binary Image.

```smalltalk
aBinaryImage := aGrayImage asBinaryImage: 0.1.
```



## Erosion.

```smalltalk
anErosionImage := aBinaryImage erosion: ImageFormGrayScale squareKernel3x3 iterations: 6.
```



## Dilation.

```smalltalk
anDilationImage := aBinaryImage dilation: ImageFormGrayScale squareKernel3x3 iterations: 6.
```