4#ifndef OPENCV_slideio_imagetools_HPP
5#define OPENCV_slideio_imagetools_HPP
7#include <opencv2/core.hpp>
8#include "slideio/imagetools/slideio_imagetools_def.hpp"
9#include "slideio/base/slideio_enums.hpp"
10#include "slideio/imagetools/encodeparameters.hpp"
13#pragma warning( push )
14#pragma warning(disable:4005)
20 class SLIDEIO_IMAGETOOLS_EXPORTS ImageTools
25 std::vector<int> chanelTypes;
29 static void readGDALImage(
const std::string& path, cv::OutputArray output);
30 static void writeRGBImage(
const std::string& path, Compression compression, cv::Mat raster);
31 static void writeTiffImage(
const std::string& path, cv::Mat raster);
32 static void readJxrImage(
const std::string& path, cv::OutputArray output);
33 static void decodeJxrBlock(
const uint8_t* data,
size_t size, cv::OutputArray output);
34 static void decodeJpegStream(
const uint8_t* data,
size_t size, cv::OutputArray output);
35 static void encodeJpeg(
const cv::Mat& raster, std::vector<uint8_t>& encodedStream,
const JpegEncodeParameters& params);
37 static void readJp2KFile(
const std::string& path, cv::OutputArray output);
38 static void readJp2KStremHeader(
const uint8_t* data,
size_t dataSize, ImageHeader& header);
39 static void decodeJp2KStream(
const std::vector<uint8_t>& data, cv::OutputArray output,
40 const std::vector<int>& channelIndices = std::vector<int>(),
41 bool forceYUV =
false);
42 static void decodeJp2KStream(
const uint8_t* data,
size_t dataSize, cv::OutputArray output,
43 const std::vector<int>& channelIndices = std::vector<int>(),
44 bool forceYUV =
false);
45 static int encodeJp2KStream(
const cv::Mat& mat, uint8_t* buffer,
int bufferSize,
46 const JP2KEncodeParameters& parameters);
47 static double computeSimilarity(
const cv::Mat& left,
const cv::Mat& right,
bool ignoreTypes=
false);
48 static double computeSimilarity2(
const cv::Mat& left,
const cv::Mat& right);
49 static double compareHistograms(
const cv::Mat& leftM,
const cv::Mat& rightM,
int bins);
50 static int dataTypeSize(slideio::DataType dt);
51 template <
typename Type>
52 static void convertTo32bitChannels(Type* data,
int width,
int height,
int numChannels, int32_t** channels)
54 const int pixelSize = numChannels;
55 const int stride = pixelSize * width;
58 for (
int y = 0; y < height; ++y) {
60 for (
int x = 0; x < width; ++x) {
61 for (
int channelIndex = 0; channelIndex < numChannels; ++channelIndex) {
62 int32_t* channel = channels[channelIndex];
63 channel[channelShift] =
static_cast<int32_t
>(pixel[channelIndex]);
Definition: exceptions.hpp:12