python对图片颜色校正,使用Python PIL更改图像色调

本文介绍了如何使用Python的PIL库调整图像的颜色,特别是改变图像的色调。通过实现RGB到HSV的转换并修改色调值,然后将HSV转换回RGB,可以实现类似于Photoshop中的“色相/饱和度”调整的效果。提供了详细的代码示例,展示了如何创建函数来根据给定的色调值(0-1或0-360度)调整图像色调。
摘要由CSDN通过智能技术生成

Using Python PIL, I'm trying to adjust the hue of a given image.

I'm not very comfortable with the jargon of graphics, so what I mean by “adjusting hue” is doing the Photoshop operation called “Hue/saturation”: this is to change the color of the image uniformly as shown below:

Original:

3ee9862bc090c8dd2fda7dfe3ed04e60.png

With hue adjusted to +180 (red):

63404839417073f10443b02167b429cd.png

With hue adjusted to -78 (green):

Mqmh1.png

FYI, Photoshop uses a scale of -180 to +180 for this hue setting (where -180 equals +180), that may represents the HSL hue scale (expressed in 0-360 degree).

What I'm looking for is a function that, given an PIL image and a float hue within [0, 1] (or int within [0, 360], it doesn't matter), returns the image with its hue shifted by hue as in the example above.

What I've done so far is ridiculous and obviously doesn't give the desired

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值