# Object Retrieval in Microscopic Images of Rocks Using the Query by Sketch Method
## 3 Materials and Methods
### Retrieving Similar Distribution of Objects  
Having a database that includes thousands of images we might need to retrieve an image (and in a result, a rock or a piece of the rock mass) with a given distribution of objects (porosity). Such images could be for example those presented in Figure 5 and which are the sketches of images with the porosity created by small pores (a), the sketches of porosity created by large pores (b), sketches with porosity created by large pores next to the lack of porosity (c) or those with high porosity created by small pores next to high porosity created by large pores (d). Searching databases with the purpose of retrieving the described situations can be performed by providing a mathematical description of such structure and then searching the entire database to find an image which is the closest to this description. However, according to the authors, this task is difficult and requires engagement of a specialist that is able to prepare such mathematical description. This is why we recommend another method, which is based on Query by Sketch.  
In the case of similarity retrieval in a distribution of objects (porosity), the procedure is similar to the one described in the previous chapter (see Figure 4). It is proposed to load the images and to process them in order to detect the objects both in the database and in the search query. The parameters describing the \"arrangement\" of the objects in the image are then extracted. It is proposed to standardise these parameters in order to obtain relative values. The case of retrieving the most similar image from the entire database differs from the previously described case mainly in the preparation of the feature space. The analysis of the arrangement of objects can determine the feature space and the features dependent on:  
* the surface area (e.g., detected porosity);
* the average size of the object in the image;
* the skewness of the surface areas of individual objects--it indicates the distribution of their feature and its asymmetry on the images;  
Figure 5: An example of artificially generated sketches with different porosity distribution: porosity created by small pores (**a**), porosity created by large pores (**b**), porosity created by large pores next to the lack of porosity (**c**) porosity created by small pores next to high porosity created by large pores (**d**). Additionally, on figure (**a**) a division into main Regions of Interest (ROIs) is shown.  
* the range of features (surface area)--it is the difference between extreme objects on the image.  
It is worth noting that it is possible to calculate selected parameters for fragments (Regions of Interest) of the image. The images can be divided according to the set thresholds, for example, at half height and using the width of the image. In the opinion of the authors, the division of such an image results in four main parts that are easily interpretable by a human, which may be important from the point of view of the preparation of a sketch (Figure 5). The possibility of dividing the image into more Regions of Interest (ROIs) can also be taken into account, on an individual basis.