TIFF
TIFF(Tag Image File Format)图像文件是图形图像处理中常用的格式之一,其图像格式很复杂,但由于它对图像信息的存放灵活多变,可以支持很多色彩系统,而且独立于操作系统,因此得到了广泛应用。在各种地理信息系统、摄影测量与遥感等应用中,要求图像具有地理编码信息,例如图像所在的坐标系、比例尺、图像上点的坐标、经纬度、长度单位及角度单位等等。
imwrite
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,
const std::vector<int>& params = std::vector<int>());
@include snippets/imgcodecs_imwrite.cpp
@param filename Name of the file.
@param img (Mat or vector of Mat) Image or Images to be saved.(单张/多张)
@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
int main()
{
std::string srExePath = ExePath();
std::size_t pos = srExePath.find_first_of("x64");
std::string srpath = ExePath().substr(0, pos);
std::vector<cv::Mat> imgs;
cv::Mat img1 = cv::imread(srpath + "image\\11.jpg", cv::IMREAD_UNCHANGED);
cv::Mat img2 = cv::imread(srpath + "image\\12.jpg", cv::IMREAD_UNCHANGED);
cv::Mat img3 = cv::imread(srpath + "image\\13.jpg", cv::IMREAD_UNCHANGED);
cv::Mat img4 = cv::imread(srpath + "image\\13.jfif", cv::IMREAD_UNCHANGED);
imgs.emplace_back(img1);
imgs.emplace_back(img2);
imgs.emplace_back(img3);
imgs.emplace_back(img4);
imwrite("result.tif", imgs);
return -1;
}
四张图片合成一张,
imreadmulti
CV_EXPORTS_W bool imreadmulti(const String& filename, CV_OUT std::vector<Mat>& mats, int flags = IMREAD_ANYCOLOR);
/** @brief Loads a multi-page image from a file.
The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
@param filename Name of file to be loaded.
@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
@param mats A vector of Mat objects holding each page, if more than one.
std::vector<cv::Mat> images;
cv::imreadmulti("result.tif", images);
cv::Mat image1(images.at(0));
cv::Mat image2(images.at(1));
cv::Mat image3(images.at(2));
cv::Mat image4(images.at(3));