File: README.md

package info (click to toggle)
sight 25.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,180 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (80 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# sight::io::bitmap

A "fast" 2D image writer (`sight::io::bitmap::Writer`) and reader (`sight::io::bitmap::Reader`). The writer and the reader uses NVidia CUDA accelerated JPEG / JPEG2000 encoding library: [nvJPEG](https://developer.nvidia.com/nvjpeg), if support has been compiled in and if a suitable GPU has been found. Alternatively, `libjpeg-turbo`, `openJPEG`, `libtiff` or `libPNG` can be used as CPU fallback. The performance should be better than VTK or even OpenCV because of direct API calls and avoided unneeded buffer copy.

The image pixel format supported depends of the codec. For instance, while TIFF or PNG supports almost everything from float gray scales images to 32 bits RGBA images, JPEG2000 supports only unsigned 8 bits and 16 bits RGB or gray scale images and JPEG only unsigned 8 bits.

To sum up:
- `libJPEG`: supports unsigned 8 bits RGB, RGBA, BGR, BGRA or GRAYSCALE images.
- `libPNG`: supports unsigned 8, 16 bits RGB, RGBA, BGR, BGRA or GRAYSCALE images.
- `libTIFF`: supports unsigned, signed, float, 8 or 16 bits RGB, RGBA, BGR, BGRA or GRAYSCALE images.
  > Note: libTIFF signed and float image can be written and read back, but are rare and most third party software won't read them.
- `openJPEG`: supports unsigned, signed 8, 16 bits RGB, RGBA or GRAYSCALE images.
- `nvJPEG`: supports unsigned 8 bits RGB, BGR images.
- `nvjpeg2k`: supports unsigned 8, 16 bits RGB, BGR or GRAYSCALE images.

`detail` contains the real implementation with direct calls to image libraries.

## Classes

### Writer

- **writer**: writes a 2D image to a file or a stream in the selected format (.jpg, .tiff, .png, j2k).

### Reader

- **reader**: reads a 2D image to a file or a stream in the selected format (.jpg, .tiff, .png, j2k).

## How to use it

### Writing

```c++
    auto image = sight::data::image::New();
    // fill the image...
    ...

    auto writer = io::bitmap::Writer::New();

    // Configure the session writer
    writer->set_object(image);

    // Write with DEFAULT backend (tiff) and DEFAULT mode (fast)
    writer->setFile("image.tiff");
    sessionwriterWriter->write();

    // Write with backend "nvJPEG2000" (will except if not available) and "best" mode
    // .jp2 will be added to the "image" filename
    writer->setFile("image");
    writer->write(io::bitmap::Writer::Backend::NVJPEG2K, io::bitmap::Writer::MODE::BEST);
```

### Reading

```c++
    auto image = sight::data::image::New();
    // fill the image...
    ...

    auto reader = io::bitmap::Reader::New();

    // Configure the session writer
    reader->set_object(image);

    // Read by guessing right backend (use the extension)
    reader->setFile("image.png");
    reader->read();

    // Read with backend "nvJPEG2000" (will except if not available)
    reader->setFile("image.j2k");
    reader->read(io::bitmap::Writer::Backend::NVJPEG2K);
```

### CMake

```cmake
target_link_library(my_target <PUBLIC|PRIVATE> io_bitmap)
```