This article presents two optimized implementations of the PCA algorithm, primarily targeted on spectral image analysis in real time. One of them utilizes the SSE instruction set of contemporary CPUs, the other one runs on graphics processors (GPUs), using the CUDA environment. The implementations are evaluated and compared with a multithreaded C implementation compiled by an optimizing compiler and the results show speed-ups of around 10x which allows for using PCA on RGB and spectral images in real time. The discussed implementations are made available in a dynamically linked library, including a MATLAB plug-in interface so that they can be used by the professional public.