Hugin trunk 0.1
Loading...
Searching...
No Matches
cms.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
9/* This is free software; you can redistribute it and/or
10* modify it under the terms of the GNU General Public
11* License as published by the Free Software Foundation; either
12* version 2 of the License, or (at your option) any later version.
13*
14* This software is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17* Lesser General Public License for more details.
18*
19* You should have received a copy of the GNU General Public
20* License along with this software. If not, see
21* <http://www.gnu.org/licenses/>.
22*
23*/
24
25#ifndef _CMS_H
26#define _CMS_H
27
28#include "lcms2.h"
29
30namespace HuginBase
31{
32namespace Color
33{
36template<class ImageType>
37void ApplyICCProfile(ImageType& image, const vigra::ImageImportInfo::ICCProfile& iccProfile, const cmsUInt32Number imageFormat)
38{
39 // is color or grayscale image given?
40 typedef typename vigra::NumericTraits<typename ImageType::value_type>::isScalar is_scalar;
41 const bool isGrayscale(is_scalar().asBool);
42 // create input icc profile
44 if (!iccProfile.empty())
45 {
46 inputICC = cmsOpenProfileFromMem(iccProfile.data(), iccProfile.size());
47 };
48 if (inputICC != NULL)
49 {
50 // check that input profile matches image type
51 if (isGrayscale)
52 {
54 {
56 inputICC = NULL;
57 return;
58 };
59 }
60 else
61 {
63 {
65 inputICC = NULL;
66 return;
67 };
68 };
69 };
70 // if there is no icc profile in file do nothing
71 if (inputICC == NULL)
72 {
73 return;
74 };
75 // build output profile
77 if (isGrayscale)
78 {
79 // default grayscale curve with gamma of 2.2
81 if (Curve == NULL)
82 {
83 return;
84 };
87 }
88 else
89 {
90 // sRGB for color images
92 }
93 // now build transform and do actual transformation
96 if (transform)
97 {
98 cmsDoTransform(transform, image.begin(), image.begin(), image.width() * image.height());
99 }
100 else
101 {
102 std::cerr << "Creating cmsCreateTransform failed. Invalid icc profile?" << std::endl;
103 }
104 // clean up
105 cmsDeleteTransform(transform);
108};
109
110}; // namespace Color
111
112}; // namespace HuginBase
113
114#endif // _CMS_H
vigra::FRGBImage ImageType
void ApplyICCProfile(ImageType &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsUInt32Number imageFormat)
converts given image with iccProfile to sRGB/gray space, need to give pixel type in lcms2 format work...
Definition cms.h:37
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41