This diagram (click for bigger version) shows how the web server (Apache etc), web programming code (PHP, ASP etc) and the content-based image database (isk-daemon) interacts.
It depicts the two most common processes (shown as the two vertical lanes):
This architecture assumes that the following components (brown boxes on the diagram) are already implemented by you:
The processes for indexing and querying are detailed below:
Index images into your website:
1) Site administrator submits a request to add an image. Again, this is a process that is probably already implemented as part of your content publishing system. Alternatively, images may be getting into your system from user submission forms. In this case, the server side logic for handling these submissions should be extended to also do step 2.c) below.
2) PHP class or page handles the admin user (or an end-user request from a photo submission HTML form) request and does the following:
3) An XML-RPC or SOAP call is made to isk-daemon service interface asking it to index an image. This call should supply an image ID (an integer – probably the same unique image id generated on step 2) and a file path for the image thumbnail.
4) Image thumbnail is loaded from disk. Pixel data is summarized and a very small signature is calculated
5) Visual signature is efficiently stored on main memory
6) And later persisted to disk. This has a configurable behavior: either have them saved after the Nth image is added, or saved every N minutes or have it manually saved from a service call or manual action from the isk-daemon admin interface.
7) User requests random image by clicking on a button at your Flash or HTML interface. This click translates into a remote call as follows.
8 ) XML or JSon HTTP POST is made to an image controller (some logic you have running on the HTTP server). Probably a PHP, ASP class/page or a plain servlet.
9) Your image controller makes a request to the isk-daemon service interface for random image ids for all indexed images. This request could also be made to the RDBMS holding image metadata since only random image IDs are necessary.
10) Image controller wraps image ids and thumbnail URLs into JSon or XML data which is returned to and interpreted by a Flash applet.
11) User requests images similar to one he is currently seeing in details
12) PHP code calls isk-daemon service interface asking for the most similar images by supplying an image id.
13) isk-daemon checks if this query is already cached, if not, proceeds to step 14
14) all images are scored according to their similarity to the query target image
15) PHP code receives XML-RPC results and wraps all the results image ids and thumbnail URLs into JSon or XML data to be returned to a Flash applet.
16) Flash applet shows query results.