使用GD Library使图像灰度 [英] Making an Image Greyscale with GD Library

查看:67
本文介绍了使用GD Library使图像灰度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是创建一个小应用程序,您可以在其中上传图片,该应用程序会将其转变为ASCII艺术.我确定这些已经存在,但我想证明自己可以做到.

My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself.

这将涉及拍摄图像,将其设置为灰度,然后根据图像的暗淡程度和字符的饱满程度将每个像素与一个字符进行匹配.

This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture is and how full the character is.

所以我的问题是,使用GD库(或者我认为必要时可以使用其他方法)如何使图像黑白化?

So my question is, Using the GD Library (or i guess some other means if necessary) how do I make an image black and white?

推荐答案

将RGB转换为灰度的常用公式是:

A common formula to convert RGB to greyscale is:

Gray scale intensity = 0.30R + 0.59G + 0.11B

这篇关于使用GD Library使图像灰度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆