Skip to content

Commit

Permalink
Added ImageCompression parameter to ImagePyramid::create. Bumped vers…
Browse files Browse the repository at this point in the history
…ion to 4.7.2
  • Loading branch information
smistad committed Oct 27, 2023
1 parent 7f20e79 commit b044db5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(FAST)

set(VERSION_MAJOR 4)
set(VERSION_MINOR 7)
set(VERSION_PATCH 1)
set(VERSION_PATCH 2)
set(VERSION_SO 4) # SO version, should be incremented by 1 every time the existing API changes
set(FAST_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

Expand Down
15 changes: 10 additions & 5 deletions source/FAST/Data/ImagePyramid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace fast {

int ImagePyramid::m_counter = 0;

ImagePyramid::ImagePyramid(int width, int height, int channels, int patchWidth, int patchHeight) {
ImagePyramid::ImagePyramid(int width, int height, int channels, int patchWidth, int patchHeight, ImageCompression compression) {
if(channels <= 0 || channels > 4)
throw Exception("Nr of channels must be between 1 and 4");

Expand Down Expand Up @@ -62,14 +62,19 @@ ImagePyramid::ImagePyramid(int width, int height, int channels, int patchWidth,
auto tiff = m_tiffHandle;
m_counter += 1;

ImageCompression compression = ImageCompression::LZW;

uint photometric = PHOTOMETRIC_RGB;
uint photometric;
uint bitsPerSample = 8;
uint samplesPerPixel = 3; // RGBA image pyramid is converted to RGB with getPatchAsImage
uint samplesPerPixel;
if(channels == 1) {
photometric = PHOTOMETRIC_MINISBLACK; // Photometric mask causes crash..
samplesPerPixel = 1;
if(compression == ImageCompression::UNSPECIFIED)
compression = ImageCompression::LZW;
} else {
if(compression == ImageCompression::UNSPECIFIED)
compression = ImageCompression::JPEG;
photometric = PHOTOMETRIC_RGB;
samplesPerPixel = 3; // RGBA image pyramid is converted to RGB with getPatchAsImage
}

while(true) {
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Data/ImagePyramid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Image;
class FAST_EXPORT ImagePyramid : public SpatialDataObject {
FAST_DATA_OBJECT(ImagePyramid)
public:
FAST_CONSTRUCTOR(ImagePyramid, int, width,, int, height,, int, channels,, int, patchWidth, = 256, int, patchHeight, = 256);
FAST_CONSTRUCTOR(ImagePyramid, int, width,, int, height,, int, channels,, int, patchWidth, = 256, int, patchHeight, = 256, ImageCompression, compression, = ImageCompression::UNSPECIFIED);
FAST_CONSTRUCTOR(ImagePyramid, openslide_t*, fileHandle,, std::vector<ImagePyramidLevel>, levels,);
FAST_CONSTRUCTOR(ImagePyramid, std::ifstream*, stream,, std::vector<vsi_tile_header>, tileHeaders,, std::vector<ImagePyramidLevel>, levels,, ImageCompression, compressionFormat,);
FAST_CONSTRUCTOR(ImagePyramid, TIFF*, fileHandle,, std::vector<ImagePyramidLevel>, levels,, int, channels,,bool, isOMETIFF, = false);
Expand Down
3 changes: 3 additions & 0 deletions source/FAST/Importers/TIFFImagePyramidImporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace fast {
* For instance if exported using the TIFFImagePyramidExporter.
* This exporter uses libtiff.
*
* Outputs:
* - 0: ImagePyramid
*
* @sa WholeSlideImageImporter TIFFImagePyramidExporter
* @ingroup importers
*/
Expand Down

0 comments on commit b044db5

Please sign in to comment.