# How to reduce an unknown size data into a fixed size data? Please read details

Example:
Given n number of images marked 1 to n where n is unknown, I can calculate a property of every image which is a scalar quantity. Now I have to represent this property of all images in a fixed size vector (say 5 or 10).

One naive approach can be this vector- [avg max min std_deviation]
And I also want to include the effect of relative positions of those images.

• Please expand on the last sentence. Are the images embedded on a background, which you want to ignore?
– Emre
Sep 6, 2017 at 17:22

My approach would be using the Moments.
Using moments is a cool way trowing any arbitrary set of points into space, and it is used for both probability and mass calculations.
Since you have not stated what are you going to do with this vector representation I guess that a generalized "shape" like representation might work for you.

If you are using Python, then this can help.

It looks like you're looking for a smart aggregation function, which aggregate n folded rows instead of the usual 1 (out of the many falling to the group-by criteria).

Some of the aggregation function you suggested like min and max can be adjusted as the n-smallest or the n-biggest values. Alternatively, the min/max n-values can be a skip list of the sorted value (ascending for min, descending for max), choosing every n/5-th item value

In a wider approach, we can borrow the concept from time-series, where at each time interval a set of parameters are sampled. Instead of the built in time-stamp buckets (say every 1 sec, 10 min, etc..) you can use your images index, thus preserving the order.

As with time-series, that can be farther more reduced into smaller time-series (say from a 1 sec interval into 1 day interval), write a custom group-by function that "folds" every n/5 image-rows into 1 row (so that it'll leave you with 5) and apply your min/max/custom aggregation function on every n/5 values of your magic-image-property