程序化地找到相似的颜色 [英] finding similar colors programatically

查看:226
本文介绍了程序化地找到相似的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个缓冲的图像在java和我想记录每个像素是如何相似的另一个基于颜色值。因此具有相似颜色的像素将具有较高的相似性值。例如红色和粉红色将具有相似性值1000,但红色和蓝色将具有类似于300或更小的值。

I have a buffered image in java and I want to record how similar each pixel is to another based on the color value. so the pixels with 'similar' colors will have a higher similarity value. for example red and pink will have a similarity value 1000 but red and blue will have something like 300 or less.

我如何做到这一点。当我从缓冲的图像像素获取RGB它返回一个负整数我不知道如何实现这一点。

how can I do this. when I get the RGB from a buffered Image pixel it returns a negative integer I am not sure how to implement this with that.

推荐答案

一旦你得到了RGB值,你可以尝试

Once you get the RGB values, you could try

>((r2-r1) 2 +(g2-g1) +(b2-b1) 2

((r2 - r1)2 + (g2 - g1)2 + (b2 - b1)2)1/2

这将给出三维空间距离两个点的距离,每个点由(r1,g1,b1)和(r2,g2,b2 )。

This would give you the distance in 3D space from the two points, each designated by (r1,g1,b1) and (r2,g2,b2).

或者有更复杂的方法使用颜色的HSV值。

Or there are more sophisticated ways using the HSV value of the color.

这篇关于程序化地找到相似的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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