In MATLAB, after setting all the parameters appropriately, type outputImgs()
to generate training images.
Here're some parameters that you can set:
numImages
: the number of images you want to generateshowImg
: show a sample image after the data is generatedsaveImg
: save the data in image format, such as jpgsaveStruct
: save the data as feature vector, which is obtained by unrolling the image matrix. At the end of the vector, the number of object (1 element), and the coordinates of the objects (max_num_obj X 2 element) are attached.pattern
: (string) the distribution of the distortion vectoralignment
: center the object array OR left-align themmax_num_obj
: (int) the maximum number of objects in the imageobj_radius
: (int) the radius of the objectvarySize
: (bool) randomize the size of the objectframe_ver
& frame_hor: (int) vertical and horizontal length of the imageframe_boundary
: (int) distance between objects and the boundary of the image, before distortionframe_space
: (int) spacing in between each object, before distortiondistortion_x
&distortion_y
: (float) horizontal and vertical distortion- frame_rand_vecDistribution: (string) the shape of the distribution of the distortion vector
supervised
: (bool) indicate that there is a label attached at the end of the imagenumObj_sampling
: (string) the distribution of the number of objects in the image
Here're some examples for the oneObj data set (28 x 28 pixels):
To get these images, first, I place the object at the center, then translate the location of that object by a random vector. The distribution of the random vector is uniform over a disk (see the figure below). Note that when the points are uniform over a disk, the norm will not be uniform, since there are more points on the surrounding region (than the center).
Similarly, you can generate images with multiple objects, here's a demo:
The size of the object can be stochastic:
There are two distributions that you can use (for the random vector):
- Elliptical:
Note that the previous uniform-disk is just a special case of this elliptical distribution.
- Rectangular:
references:
[1] https://github.com/seann999/tensorflow_mnist_ram
[2] http://arxiv.org/abs/1406.6247
Fixate on the object with the recurrent attention mechanism.
This Git repo hosts several datasets for counting-related tasks:
[1] oneObj (demo above)
[2] oneObj_big
The objects from the "oneObj" data set were placed on a larger panel (60 x 60). The magnitude of translation was doubled. Here're some example images:
[3] multiObj
The amount of objects in each image is randomized (maxNumObj = 5). To capture the environmental regularity, smaller numbers are more likely. Here's the distribution of the random number generator that I wrote:
Here're some example images: