F#之旅7 - 图片处理入门
首先,隆重介绍今天的主角:ImageProcessor(http://imageprocessor.org/)。虽然我并没有在实际工作中用到这个库,但是它干净利索的使用方式打动了我,很久以前就存了下来。这个库的开发语言是C#,nuget有下载,提供了一系列可以链式调用的方法来处理图片。关键的一点,它是开源的,代码很清晰,有什么bug和不爽可以自己想怎么改就怎么改。
接下来,需要一提的是,我对图片处理一窍不通。所以,这篇文章是我入门图片处理的记录。当然,矩形圆形直线、RGB这类基础,就不特别提了。
一、图片格式
ImageProcessor内置支持的图片格式,自然也是常见常用的图片格式。包括:
1、bmp:Bitmap,位图,采用位映射存储格式,除了图像深度可选以外,不采用其他任何压缩。
2、gif:Graphics Interchange Format,分为静态GIF和动画GIF,是一种压缩位图格式。
3、jpg(jpeg):Joint Photographic Experts GROUP,可以选择压缩级别。
4、png:Portable Network Graphic Format,其设计目的是试图替代GIF和TIFF文件格式,同时增加一些GIF文件格式所不具备的特性。
5、tif(tiff):Tag Image File Format,是一种灵活的位图格式,主要用来存储包括照片和艺术图在内的图像。
二、图片处理
Alpha 透明度
Changes the opacity of the current image.
Alpha(int percentage) [0,100]
AutoRotate 自转
Performs auto-rotation to ensure that EXIF defined rotation is reflected in the final image.
AutoRotate()
BackgroundColor 背景色
Changes the background color of the current image.
BackgroundColor(Color color)
Brightness 亮度
Changes the brightness of the current image.
Brightness(int percentage) [-100,100]
Constrain 约束
Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio. Produces the same output as the Resize method using ResizeMode.Max
Constrain(Size size)
Contrast 对比度
Changes the contrast of the current image.
Contrast(int percentage) [-100,100]
Crop 裁剪
Crops the current image to the given location and size.
Crop(Rectangle rectangle)
Crop(CropLayer cropLayer)
DetectEdges 边缘检测
Detects the edges in the current image using various one and two dimensional algorithms. If the greyscale parameter is set to false the detected edges will maintain the pixel colors of the originl image.
DetectEdges(IEdgeFilter filter, bool greyscale = true)
IEdgeFilter = KayyaliEdgeFilter、KirschEdgeFilter、Laplacian3X3EdgeFilter、PrewittEdgeFilter...
EntropyCrop 熵裁剪(根据信息量的阈值来裁剪)
Crops an image to the area of greatest entropy. This method works best with images containing large areas of a single color or similar colors around the edges.
EntropyCrop(byte threshold = 128)
Filter 滤镜
Applies a filter to the current image. Use the MatrixFilters class to assign the correct filter
Filter(IMatrixFilter matrixFilter)
IMatrixFilter = BlackWhite、Gotham、Lomograph、Polaroid...
Flip 翻转
Flips the current image either horizontally or vertically.
Flip(bool flipVertically)
Format 格式
Sets the output format of the current image to the matching
Format(ISupportedImageFormat format)
ISupportedImageFormat = BitmapFormat、JpegFormat、GifFormat...
GaussianBlur 高斯模糊
Uses a Gaussian kernel to blur the current image.
GaussianBlur(int size)
GaussianBlur(GaussianLayer gaussianLayer)
GaussianSharpen 高斯锐化
Uses a Gaussian kernel to sharpen the current image.
GaussianSharpen(int size)
GaussianSharpen(GaussianLayer gaussianLayer)
Hue 色调
Alters the hue of the current image changing the overall color.
Hue(int degrees, bool rotate = false)
Mask 遮盖
Applies the given image mask to the current image. Any area containing transparency withing the mask will be removed from the original image. If the mask is larger than the image it will be resized to match the images dimensions.
Mask(Image imageMask, Point? point = null)
Overlay 覆盖
Adds a image overlay to the current image. If the overlay is larger than the image it will be resized to match the images dimensions.
Overlay(ImageLayer imageLayer)
Pixelate 像素化(马赛克)
Pixelates an image with the given size.
Pixelate(int pixelSize, Rectangle? rectangle = null)
Quality 图片质量
Alters the output quality of the current image. This method will only effect the output quality of jpeg images.
Quality(int percentage) [0,100]
ReplaceColor 替换颜色
Replaces a color within the current image.
ReplaceColor(Color target, Color replacement, int fuzziness = 0)
Resize 改变大小
Resizes the current image to the given dimensions. If EXIF metadata is to be preserved the information contained within will also be updated to match.
Resize(Size size)
Resize(ResizeLayer resizeLayer)
Resolution 分辨率
Changes the horizontal and vertical resolution of the image. If EXIF metadata is to be preserved the information contained within will also be updated to match.
Resolution(int w, int h)
Rotate 旋转
Rotates the current image by the given angle without clipping.
Rotate(int degrees)
RoundedCorners 圆整圆角
Adds rounded corners to the current image.
RoundedCorners(int radius)
RoundedCorners(RoundedCornerLayer roundedCornersLayer)
Saturation 饱和度
Changes the saturation of the current image.
Saturation(int percentage)
Tint 色度
Tints the current image with the given color
Tint(Color color)
Vignette 晕影
Adds a vignette image effect to the current image.
Vignette(Color color)
Watermark 水印
Adds a text based watermark to the current image.
Watermark (TextLayer textLayer)
三、尝试
最后,来试一下效果吧。


F#之旅7 - 图片处理入门的更多相关文章
- F#之旅8 - 图片处理应用之动画二维码
首先,先介绍下什么是动画二维码.前些天在网上闲逛,突然看到一个开源项目,发现一种二维码的新玩法.https://github.com/sylnsfar/qrcode/blob/master/READM ...
- F# 之旅(上)
写在前面的话 解答一下在上一篇文章<在Visual Studio中入门F#>中有人的提问, 1. 问:是准备写 F# 系列吗? 答:当然不是,本人也是刚刚学习 F#,只是翻译微软官方 ...
- F# 之旅(下)
写在前面的话 学习 F# 一定要去体会函数式编程的特点,推荐一下阮一峰的日志<函数式编程入门教程>. 在这篇文章中 递归函数 记录和可区分联合类型 模式匹配 可选类型 度量单位 类和接口 ...
- F#之旅4 - 小实践之快排
参考文章:https://swlaschin.gitbooks.io/fsharpforfunandprofit/content/posts/fvsc-quicksort.html F#之旅4 - 小 ...
- F#之旅0 - 开端
F#之旅0 - 开端 UWP的学习告一段落,CozyRSS的UWP版本并没有做.UWP跟wpf开发几乎一模一样,然后又引入了很多针对移动设备的东西,这部分有点像android.没啥太大的意思,不难,估 ...
- Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子
Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子 第一个例子都是比较简单的博客园登录界面,就像学习编程语言时候都是从Hello,World!开始. 1 ...
- 一条数据的HBase之旅,简明HBase入门教程-Write全流程
如果将上篇内容理解为一个冗长的"铺垫",那么,从本文开始,剧情才开始正式展开.本文基于提供的样例数据,介绍了写数据的接口,RowKey定义,数据在客户端的组装,数据路由,打包分发, ...
- 一条数据的HBase之旅,简明HBase入门教程-开篇
常见的HBase新手问题: 什么样的数据适合用HBase来存储? 既然HBase也是一个数据库,能否用它将现有系统中昂贵的Oracle替换掉? 存放于HBase中的数据记录,为何不直接存放于HDFS之 ...
- F#之旅6 - 简单AV推荐系统
上回说到用F#来写爬虫,这只是F#学习第一阶段的第一步.最开始,就对第一阶段做了这样的安排: 1.爬虫爬取AV数据 2.数据处理和挖掘 3.数据可视化(使用ECharts) 4.推荐系统 第一步很快就 ...
随机推荐
- 怎么把本地项目和远程git仓库相连通
1. 打开在你的项目文件夹,输入下面的命令 git init 输完上面的命令,文件夹中会出现一个.git文件夹,如下图所示,其他的的文件也会出现蓝色小问号的标志 2. 添加所有文件 git add . ...
- SQL2008 无日志附加MDF文件
SQL数据在附加的时候..有时会因为日志文件过大..或者一些其他问题造成附加失败.. 笔者遇到的问题是数据库主文件(*.mdf)超过25G..日志文件超过200G..附加的耗时简直日了狗了..最后超时 ...
- js控制只能输入数字和控制小数的位数
<input class="form130" style="width: 80px;" maxlength="10" id=" ...
- 消除类游戏(js版)
最近一直在玩一款消灭星星的消除类游戏,周末无聊就用js也写了一遍,感觉玩比写还困难一直玩不到10000分.废话不多说直接上源码. 效果图(ps 页面有点难看木有美工) 代码总共456行,未经过严格测试 ...
- [译]你应该知道的4种JavaScript设计模式
这里介绍下面这4种设计模式 Module Prototype Observer Singleton 每种模式有许多属性构成,在这我只强调一下几点: 1 Context: 在何种情况使用哪种模式? 2 ...
- 虚函数的使用 以及虚函数与重载的关系, 空虚函数的作用,纯虚函数->抽象类,基类虚析构函数使释放对象更彻底
为了访问公有派生类的特定成员,可以通过讲基类指针显示转换为派生类指针. 也可以将基类的非静态成员函数定义为虚函数(在函数前加上virtual) #include<iostream> usi ...
- synchronized使用说明
好久没有更新博客了,今天试着用简单的语言把synchronized的使用说清楚. synchronized是什么? synchronized是用来保证在多线程环境下代码同步执行的可重入的互斥锁.所谓互 ...
- SQL Server 积累
2016-11-24 sql语句修改某表某字段的数据类型和字段长度: 问题是在修改老功能中暴露出来的,我修改了图片上传功能,结果报图片路径超出数据库字段规定长度,我检查数据库后发现之前设计数据库的人将 ...
- From 202.97.60.193 icmp_seq=48 Time to live exceeded
从浙江某电信ip的服务器上 ping 大陆外某个外网地址不通,报如下信息: From 202.97.60.193 icmp_seq=48 Time to live exceeded google,百度 ...
- appium java 环境搭建
appium是一款open source 移动自动化测试框架,既支持Android 也支持IOS. appium 基于webdriver协议执行测试脚本. 今天,如炒剩饭,介绍一下搭建appium A ...