Yet another thing you should choose when implementing an object factory is the actual type it should return. Let's discuss the various approaches.
In the case of Pixel, which is a value type and not a polymorphic one, the simplest approach works the best – we simply return by value. If you produce a polymorphic type, return it by a smart pointer (never use a naked pointer for this as this will yield memory leaks at some point). If the caller should own the created object, usually returning it in unique_ptr to the base class is the best approach. In the not-so-common cases where your factory and the caller must both own the object, use shared_ptr or another reference-counted alternative. Sometimes it's enough that the factory keeps track of the object but doesn't store it. In such cases, store weak_ptr inside the factory and return shared_ptr outside.
Some C++ programmers would argue that you should return specific types using...