以编程方式查找相似的颜色 [英] finding similar colors programmatically

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

问题描述

我在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.

我该怎么做。当我从缓冲的Image像素中获取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.

推荐答案

首先,你是如何获得整数值的?

First, how are you getting the integer value?

获得RGB值后,你可以尝试

Once you get the RGB values, you could try

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

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

这将为您提供距离两个点的3D空间距离,每个点由(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天全站免登陆