Outliers of small dataset I have a python function that takes a list of smaller images boxes (represented as float arrays) and the whole image img in as a parameter and finds outliers. The outliers will either be significantly brighter or darker than the other images in the list, but darker is the more common case.
def find_outliers(boxes, img):
    means = [np.mean(box['src']) for box in boxes]
    asc = sorted(means)
    q1, q3 = np.percentile(asc, [25,75])
    iqr = q3 - q1
    lower = q1 - (1.5 * iqr)
    upper =  q3 + (1.5 * iqr)

    # print('thresholds:', lower, upper)
    return list(filter(lambda x: np.mean(x['src']) < lower or np.mean(x['src']) > upper, boxes))

This method allows me to create thresholds based on the image, instead of coming up with hard values, which is ideal in my situation. There are 3 problems I need to address if I continue this approach.


*

*Sometimes the brighter/darker images outnumber the normal images. These images have extreme values which biases my outlier method into thinking they are normal.

*Sometimes the number of boxes is very small (3 or 4). This makes it hard for this method to find a lower and upper bound.

*The lower and upper bounds can be negative, but all of my values will be greater than or equal to 0


Is there a statistical approach that is better suited for this type of problem? 
Note: I also have tried the standard deviation outlier approach but this one isn't suitable in this scenario.
 A: You seem to have two conflicting criteria in mind for what it means to be a light or dark outlier: (a) 'light' or 'dark' compared with the current group, (b) 'light' or 'dark' according to a personal judgment of what those words mean.
For example, in your first item: Lots of dark images in a group set a standard
for 'dark' that is too low for your personal judgment. And in your second
item: there are not enough images in the group to set reasonable standards for the group.
To an extent, you might be able to have it both ways. Perhaps look at many
groups merged together and see what boundaries for 'dark' and 'light' the boxplot method sets. You might change the factor 1.5 in 1.5*iqr to be larger
or smaller so that the boxplot boundaries for the many groups taken together
don't offend your personal judgment. There is no reason the multiplier for
'light' on the high side or for 'dark' on the low side need to be the same.
For example, you might find it is good to use 1.2 on the low side and 2.0 on the high side.
Then look at some smaller groups using the new factors to see if you think the revised outlier rules are working well. Finally, decide on some arbitrary override (postive) bound to use in case the revised boxplot lower bound is negative for a particular group.
As for item 1, it may make sense to judge 'light' and 'dark' in the context of a particular group---especially if individual images will usually be displayed along with other images in their own group. 
In this regard, it may be worthwhile looking at boxplot outliers (1.5IQR rule)
for 20 groups all from the same normal distribution. Notice that what are judged high or low outliers can differ greatly from one group to another.

Some groups happen to declare anything above 90 as 'bright' while others find
no bright items in a group that has images as high as 100. In one group, 40 was declared dark, in others, 30 isn't considered dark. Each group has 70 images
and altogether there are 1400--all from the same population distribution.
Everything considered together, maybe it would be a good idea to declare 100 as the upper boundary and 40 as the lower. Very roughly, those are the values that cut off about the lowest 2% and highest 2% of the observations.
I haven't seen any of your images. I'm not trying to persuade you to use any
one particular method or criterion. Just trying to get you to think of alternatives that might work.
