数据库设计在MySQL中存储图像颜色模式,用于按颜色搜索图像

Min*_*ion 5 php mysql search database-design

我正在使用PHP和MySQL构建一个图像厨房,我希望通过它的颜色实现图像搜索.通过跟随Imagick :: getImageHistogram,我从图像中获得了最多呈现的颜色.

<?php
$image = new Imagick("thing.png");
$pixels=$image->getImageHistogram();
foreach($pixels as $p){
 $colors = $p->getColor();
 foreach($colors as $c){
        print( "$c\t" );
 }
 print( "\t:\t" . $p->getColorCount() . "\n" );
}
?>

This will print out something like:

Red    Green    Blue       Alpha    :    No of times appeared
252    250      252        1        :       125
194    156      182        1        :       126
109    18       79         1        :       11440
2      117      162        1        :       12761
255    255      255        1        :       40769
Run Code Online (Sandbox Code Playgroud)

Although I am done with getting the colors, I am stuck with designing the database to store the color information along with image path in the database.

My question is how to design a database (table structure) to store this kind of data where search can query can be applied in an effective manner.

Update:

Secondly how can I get the images with a matching color. Let's say user is searching for a color #ff0000, then how can I get all the nearest matched images from the database.

Thank You

Gra*_*avy 0

为什么不创建一个包含以下字段的数据库表:

图片表

id
name
red
green
blue
alpha
Run Code Online (Sandbox Code Playgroud)