How DSPX relates to PixInsight – Image Class
How DSPX relates to PixInsight:
Image Class
Comparison between PCL 2.9.3 and DSPX’s own sources.
The image class is the base of an image-processing program. In DSPX, more than 450 source files use it, in every process, file reader and writer, preview, history step and GPU stage. How an image is stored, owned, copied and typed decides how each of those is written, so these choices reach into most of what the program does internally, and a different choice here changes the design of a great deal elsewhere.
For DSXP we chose a lightweight design, optimized to address what we needed it to do, and nothing more. PCL is a vast, much more complete library. DSPX a much lighter one.
| PixInsight (PCL 2.9.3) | DSPX | |
|---|---|---|
| Core class | GenericImage<P>, P a pixel-traits class |
Image<T>, T the sample type |
| Sample types | UInt8, UInt16, UInt32, Float, Double, Complex, DComplex (traits for UInt20/UInt24 too) |
uint8, uint16, uint32, float, double. No complex image type |
| Storage | Planar, a pointer array per channel, 32-byte alignment assumed | Planar, one contiguous std::vector, no padding |
| Ownership | Reference-counted shared pixel data: IsShared, EnsureUnique, Attach; can live in host shared memory |
Image<T> owns and copies pixels. ImageRef<T> is a non-owning view |
| Run-time type | ImageVariant (all seven types, many operations built in) |
AnyImage and AnyImageRef, with Visit() over five types |
| Channels | Gray/RGB nominal plus alpha | The same: 1 or 3 nominal, extras are alpha |
| Color | The image carries its color space (gray, RGB, HSV, HSI, CIE XYZ/Lab/Lch) and RGB working space | The image carries only a channel count. Conversions are free functions (DSCImageColor.h) |
| Selection | On the image: rectangle, channel range, point, clip range, a stack of stored selections | None on the image. Rect is passed per call. The Document class handles selections |
| Iteration | Sample, pixel, ROI and filtered iterators | Raw ScanLine and pointer loops |
| Extras on the image | Status monitor, parallel-process settings, geometry and interpolation helpers | None. ScopedMaxThreads is separate |
| Document level | ImageWindow and View belong to the host |
The Document class holds image, metadata, stretch, history, selection and layers |
Pros of DSPX’s design
- Small and plain: the image types are 394 lines of code, in one header (
DSCImage.h, plain C++17). PCL’s counterpart is 15,999 lines of code in four headers (Image.h9,472,PixelTraits.h3,220,ImageVariant.h2,816,AbstractImage.h491). Those also hold what DSPX leaves out: iterators, built-in operations, selections and complex images. Counted without comments, blank lines and preprocessor lines. - No host dependency: it runs standalone, outside PixInsight.
- Zero-copy loans:
ImageReflets a host lend pixels without copying. - Fits the SIMD and GPU kernels: one contiguous block per image with no padding.
Cons
- No complex images: the FFT code keeps its own complex arrays, so there is no image-level frequency-domain type.
- No copy-on-write: copies are real copies, so certain mechanisms cost memory.
- Limited sample types:
AnyImagecovers five types andImageRefhas no const variant.