当前位置:  开发笔记 > 编程语言 > 正文

使用BOOST :: GIL将CYMK图像转换为RGB

如何解决《使用BOOST::GIL将CYMK图像转换为RGB》经验,为你挑选了1个好方法。

我正在尝试使用boost通用图像库将CYMK图像转换为RGB.

以下代码无法编译

// read cmyk image file
cmyk8_image_t img;
jpeg_read_image( "1502-T2-C-PER.jpg", img );

// convert to rgb
rgb8_image_t rgb( img.dimensions() );
copy_pixels(
    color_converted_view(view(img)),
    view(rgb));

有人知道怎么修这个东西吗?

我已将此代码基于教程代码

void x_luminosity_gradient(const rgb32fc_view_t& src, const gray8s_view_t& dst) {
    gray8_image_t ccv_image(src.dimensions());
    copy_pixels(color_converted_view(src), view(ccv_image));

这是编译器输出:

1>c:\program files\boost\boost_1_35_0\boost\gil\step_iterator.hpp(164) : error C2664: 'boost::gil::detail::step_iterator_adaptor::step_iterator_adaptor(const Iterator &,SFn)' : cannot convert parameter 1 from 'const boost::gil::dereference_iterator_adaptor' to 'const boost::gil::rgb8_ptr_t &'
1>        with
1>        [
1>            Derived=boost::gil::memory_based_step_iterator,
1>            Iterator=boost::gil::rgb8_ptr_t ,
1>            SFn=boost::gil::memunit_step_fn
1>        ]
1>        and
1>        [
1>            Iterator=boost::gil::cmyk8_ptr_t ,
1>            DFn=boost::gil::color_convert_deref_fn ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>
1>        ]
1>        Reason: cannot convert from 'const boost::gil::dereference_iterator_adaptor' to 'const boost::gil::rgb8_ptr_t '
1>        with
1>        [
1>            Iterator=boost::gil::cmyk8_ptr_t ,
1>            DFn=boost::gil::color_convert_deref_fn ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>
1>        ]
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>        c:\program files\boost\boost_1_35_0\boost\gil\locator.hpp(271) : see reference to function template instantiation 'boost::gil::memory_based_step_iterator::memory_based_step_iterator,DFn>>(const boost::gil::memory_based_step_iterator,DFn>> &)' being compiled
1>        with
1>        [
1>            Iterator=boost::gil::rgb8_ptr_t,
1>            ChannelValue=boost::gil::bits8,
1>            Layout=boost::gil::cmyk_layout_t,
1>            DFn=boost::gil::color_convert_deref_fn ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>
1>        ]
1>        c:\program files\boost\boost_1_35_0\boost\gil\image_view.hpp(101) : see reference to function template instantiation 'boost::gil::memory_based_2d_locator::memory_based_2d_locator>(const boost::gil::memory_based_2d_locator> &)' being compiled
1>        with
1>        [
1>            StepIterator=boost::gil::memory_based_step_iterator,
1>            Iterator=boost::gil::dereference_iterator_adaptor ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>>
1>        ]
1>        c:\documents and settings\james\my documents\code\animag\test\test.cpp(17) : see reference to function template instantiation 'boost::gil::image_view::image_view(const View &)' being compiled
1>        with
1>        [
1>            Loc=boost::gil::rgb8_loc_t,
1>            SrcView=boost::gil::image_view ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>>>>>,
1>            View=boost::gil::image_view ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>>>>>
1>        ]
1>        c:\documents and settings\james\my documents\code\animag\test\test.cpp(48) : see reference to function template instantiation 'void processRGB>(SrcView &)' being compiled
1>        with
1>        [
1>            Loc=boost::gil::memory_based_2d_locator ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>>>>,
1>            SrcView=boost::gil::image_view ,boost::gil::rgb8_view_t,boost::gil::default_color_converter>>>>>
1>        ]
1>c:\program files\boost\boost_1_35_0\boost\gil\pixel.hpp(146) : error C2440: '=' : cannot convert from 'const boost::gil::image' to 'boost::gil::bits8'
1>        with
1>        [
1>            Pixel=boost::gil::rgb8_pixel_t,
1>            IsPlanar=false,
1>            Alloc=std::allocator
1>        ]
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>        c:\program files\boost\boost_1_35_0\boost\gil\pixel.hpp(128) : see reference to function template instantiation 'void boost::gil::pixel::assign

(const Channel &,boost::mpl::false_)' being compiled 1> with 1> [ 1> ChannelValue=boost::gil::bits8, 1> Layout=boost::gil::rgb_layout_t, 1> P=boost::gil::image>, 1> Channel=boost::gil::image> 1> ] 1> c:\program files\boost\boost_1_35_0\boost\gil\algorithm.hpp(236) : see reference to function template instantiation 'boost::gil::pixel &boost::gil::pixel::operator =>(const P &)' being compiled 1> with 1> [ 1> ChannelValue=boost::gil::bits8, 1> Layout=boost::gil::rgb_layout_t, 1> Pixel=boost::gil::rgb8_pixel_t, 1> IsPlanar=false, 1> Alloc=std::allocator, 1> P=boost::gil::image> 1> ] 1> c:\program files\boost\boost_1_35_0\boost\gil\algorithm.hpp(231) : while compiling class template member function 'void boost::gil::detail::copier_n::operator ()(boost::gil::iterator_from_2d,__w64 int,boost::gil::iterator_from_2d) const' 1> with 1> [ 1> I=boost::gil::iterator_from_2d ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>>, 1> O=boost::gil::iterator_from_2d, 1> Loc2=boost::gil::memory_based_2d_locator ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>, 1> Loc=boost::gil::rgb8_loc_t 1> ] 1> c:\program files\boost\boost_1_35_0\boost\gil\algorithm.hpp(266) : see reference to class template instantiation 'boost::gil::detail::copier_n' being compiled 1> with 1> [ 1> I=boost::gil::iterator_from_2d ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>>, 1> O=boost::gil::iterator_from_2d 1> ] 1> c:\program files\boost\boost_1_35_0\boost\gil\algorithm.hpp(292) : see reference to function template instantiation 'DstIterator boost::gil::detail::copy_with_2d_iterators,boost::gil::iterator_from_2d>(SrcIterator,SrcIterator,DstIterator)' being compiled 1> with 1> [ 1> DstIterator=boost::gil::iterator_from_2d, 1> Loc2=boost::gil::memory_based_2d_locator ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>, 1> Loc=boost::gil::rgb8_loc_t, 1> SrcIterator=boost::gil::iterator_from_2d ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>> 1> ] 1> c:\documents and settings\james\my documents\code\animag\test\test.cpp(44) : see reference to function template instantiation 'void boost::gil::copy_pixels,boost::gil::image_view>(const View1 &,const View2 &)' being compiled 1> with 1> [ 1> Loc=boost::gil::memory_based_2d_locator ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>, 1> View1=boost::gil::image_view ,boost::gil::rgb8_image_t,boost::gil::default_color_converter>>>>>, 1> View2=boost::gil::image_view 1> ]

ravenspoint.. 7

发现了问题

// read cmyk image file
cmyk8_image_t img;
jpeg_read_image( "1502-T2-C-PER.jpg", img );

//// convert to rgb
rgb8_image_t rgb( img.dimensions() );
copy_pixels(
    color_converted_view(view(img)),
    view(rgb));

诀窍是rgb8_pixel_t在调用color_converted_view时使用



1> ravenspoint..:

发现了问题

// read cmyk image file
cmyk8_image_t img;
jpeg_read_image( "1502-T2-C-PER.jpg", img );

//// convert to rgb
rgb8_image_t rgb( img.dimensions() );
copy_pixels(
    color_converted_view(view(img)),
    view(rgb));

诀窍是rgb8_pixel_t在调用color_converted_view时使用

推荐阅读
135369一生真爱_890
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有