计算图像中区域的平均颜色 [英] Calculate the average colour of an area in an image

查看:172
本文介绍了计算图像中区域的平均颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是在图像上放置一个标题,并将文本颜色设置为与其位于顶部的背景形成对比的颜色。为此,我希望计算以下图像中红色矩形内部区域的平均颜色:

The goal is to lay a caption on top of an image and set the text colour to one that will contrast with the background it is positioned on top of. To that end, I wish to calculate the average colour of the area inside the red rectangles in the following images:

推荐答案

我会裁剪到您感兴趣的区域然后调整大小它到1像素。然后获取该像素的值。

I would crop to the area you are interested in then resize it to 1 pixel. Then get the value of that pixel.

这篇关于计算图像中区域的平均颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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