算法设计:用于最突出的颜色的图像量化 [英] Algorithm design: Image quantization for most prominent colors

查看:200
本文介绍了算法设计:用于最突出的颜色的图像量化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在开发一种方法来从图像中提取人类感觉到的主色



照片: https://500px.com/照片/ 63897015 / look-out-for-her-kittens-by-daniel-paulsson



大多数人会认为天蓝色的眼睛。然而,使用标准量化,当你降低到16种颜色以下时,蓝色完全消失。

项目详细信息:I' m建立一个Rails应用程序,将接受上传的照片或特定的颜色,并将返回一堆其他照片具有类似的主流颜色。该工具将被设计师用于查找符合其预先存在的配色方案的股票摄影。



当前研究:我已经花了最后24小时阅读所有这些东西。在我尝试的所有服务中,TinEye是唯一一个正确的服务,但他们是封闭的源。我不能提供超过1个链接,但您可以通过googleTinEye Color找到它。



使用的工具:我使用ImageMagick进行图片转换和直方图生成。



所需结果:当给定该照片时,我想创建一个调色板

当前方法:我现在的做法是我减少它到32或64种颜色,并寻找饱和度/色调离群值。如果标准偏差很低,离群点距离很远,我将它添加到调色板。

我的问题:我的问题是我的问题是,我的问题是与ImageMagick的量化算法。我不想取颜色的平均值,我想按照颜色分组,并取中值,偏好饱和颜色。当我把猫图片缩小到32色,眼睛变成了一个不饱和的灰色。



所以我问你们,如果你知道任何算法或颜色原理这将让我找到从图像中脱颖而出的颜色,而不会将它们模糊在一起。



在更一般的意义上,TinEye做了一个完美的工作,

解决方案

你说,'显性'颜色是

你还说,你想要的结果是,饱和的天蓝色是一个

您提取的调色板中的5-6种颜色。



您最终想要的是图片中实际的颜色,



要开始处理此任务,我首先尝试获取的颜色定义>



但这里我已经坚持:穿孔的天蓝已经是至少20种不同色调的组合的蓝色!看到这里,缩放级别为1000%的裁剪猫眼图片:





那么你想要哪一个?那么,如果最终匹配的蓝色是最终匹配的结果是 模糊平均值 即使一次也会出现在原始图片中!!






更新



这是我的第一枪。



1。使用 -posterize 8 减少颜色



  convert 2048.jpg -posterize 8 posterized-8.png 

这是猫的眼睛,当海报化和缩放1000%





2。创建描述后化后12种最常用颜色的文本直方图



  convert \ 
posterized-8。 png \
-format%c \
-colorspace lab \
-colors 12 \
histogram:info: - | sort -n -r

850708:(172,171,171)#ACABAB srgb(172,171,171)
370610:(219,219,226)#DBDBE2 srgb(219,219,226)
262870:(218,201,183)#DAC9B7 srgb(218,201,183)
162588:(182,182,219)#B6B6DB srgb(182,182,219)
161739:(182,219,219)#B6DBDB srgb(182,219,219)
115671:(92,87,87)#5C5757 srgb (92,87,87)
102337:(146,109,109)#926D6D srgb(146,109,109)
86318:(67,46,46)#432E2E srgb(67,46,46)
82882 :(22,20,21)#161415 srgb(22,20,21)
66221:(109,139,154)#6D8B9A srgb(109,139,154)
58403:(146,146,109)#92926D srgb(146,146,109)
38949:(97,109,146)#616D92 srgb(97,109,146)



3。使用12种最常用的颜色创建显示调色板的补丁程序:



  convert \ 
-size 100x100 \\ \\
xc:srgb(172,171,171)\
xc:srgb(219,219,226)\
xc:srgb(134,119,120)\
xc: srgb(182,182,219)\
xc:srgb(182,219,219)\
xc:srgb(92,87,87)\
xc:srgb(146,109,109) \
xc:srgb(67,46,46)\
xc:srgb(22,20,21)\
xc:srgb(109,139,154) \
xc:srgb(146,146,109)\
xc:srgb(97,109,146)\
+ append \
palette.png

这是调色板的样子(它错过了眼睛中非常亮的部位的颜色):




So I'm working on a way to extract dominant colors as perceived by humans from an image.

As an example, here's a photo: https://500px.com/photo/63897015/looking-out-for-her-kittens-by-daniel-paulsson

Most humans would think the 'dominant' color is that piercing azure of the eyes. Using standard quantization, however, that blue disappears completely when you drop below 16 colors or so. The eyes only take up 0.2% of the canvas, so going for the average doesn't work at all.

Project Details: I'm building a Rails app that will accept an uploaded photo or a specific color, and will return a bunch of other photos with similar dominant colors. The tool will be used by designers to find stock photography that matches their pre-existing color scheme. There are other cool ideas I have, too, if I can get the technical bit sorted out.

Current Research: I've spent the last 24 hours reading all about this stuff. Of all the services I've tried, TinEye is the only one that does it properly, but they're closed source. I can't provide more than 1 link, but you can google 'TinEye Color' to find it.

Tools Used: I'm using ImageMagick to do the image conversion and histogram generation.

Desired Result: When given that photo, I'd like to create a palette of 5-6 colors, with that saturated azure being one of them.

Current Method: The way I'm doing it now is I reduce it to 32 or 64 colors, and look for saturation/hue outliers. If the standard deviation is low and the outlier is significantly far away, I'll add it to the palette. Then I'll further reduce the photo to 4 colors and combine them for a 5-6 color palette.

My Question: My problem is with ImageMagick's quantization algorithm. I don't want to take the average of the colors, I want to group them by like colors and take the median, favoring saturated colors. When I reduce the cat picture to 32 colors, the eyes get turned into a desaturated grey.

So I'm asking you guys if you know of any algorithm or color principle that will let me find colors that stand out from an image, without blurring them together. I want a color that is actually in the image, not the blurred mean of 4-5 colors combined.

In a more general sense, TinEye has done a perfect job, and I'd like to figure out how they've done it.

解决方案

You say, that the 'dominant' color was 'that piercing azure of the eyes'.

You also say, that you want as a result 'that saturated azure being one of' the 5-6 colors in your extracted palette.

You finally want 'a color that is actually in the image, not the blurred mean of 4-5 colors combined.'.

To start tackling this task, I've first tried to get to the exact color definition of 'that piercing azure of the eyes'.

But here I'm stuck already: that piercing azure is already a mix of at least 20 different shades of blue! See here, a picture that is a cropped cat eye, at 1000% zoom level:

So which one exactly do you want? So what if the best match for the blue you imagine in the end is a 'blurred mean' of several colors combined, and which does not appear in the original image even once?!


Update

Here is my first shot at it...

1. Use -posterize 8 to go to fewer colors

convert 2048.jpg -posterize 8 posterized-8.png

Here is the cat's eye when posterized and zoomed at 1000%:

2. Create a textual 'histogram' describing the 12 most frequently used colors after posterization

convert              \
   posterized-8.png  \
  -format %c         \
  -colorspace lab    \
  -colors 12         \
   histogram:info:-  | sort -n -r

  850708: (172,171,171) #ACABAB srgb(172,171,171)
  370610: (219,219,226) #DBDBE2 srgb(219,219,226)
  262870: (218,201,183) #DAC9B7 srgb(218,201,183)
  162588: (182,182,219) #B6B6DB srgb(182,182,219)
  161739: (182,219,219) #B6DBDB srgb(182,219,219)
  115671: ( 92, 87, 87) #5C5757 srgb(92,87,87)
  102337: (146,109,109) #926D6D srgb(146,109,109)
   86318: ( 67, 46, 46) #432E2E srgb(67,46,46)
   82882: ( 22, 20, 21) #161415 srgb(22,20,21)
   66221: (109,139,154) #6D8B9A srgb(109,139,154)
   58403: (146,146,109) #92926D srgb(146,146,109)
   38949: ( 97,109,146) #616D92 srgb(97,109,146)

3. Use the 12 most frequent colors to create a patch strip showing the palette:

convert      \
   -size 100x100 \
    xc:"srgb(172,171,171)" \
    xc:"srgb(219,219,226)" \
    xc:"srgb(134,119,120)" \
    xc:"srgb(182,182,219)" \
    xc:"srgb(182,219,219)" \
    xc:"srgb(92,87,87)" \
    xc:"srgb(146,109,109)" \
    xc:"srgb(67,46,46)" \
    xc:"srgb(22,20,21)" \
    xc:"srgb(109,139,154)" \
    xc:"srgb(146,146,109)" \
    xc:"srgb(97,109,146)" \
   +append \
    palette.png

This is how the palette looks like (it misses the colors from the very bright spot in the eye):

这篇关于算法设计:用于最突出的颜色的图像量化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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