2010-12-04 6 views
1

gil::color_converted_view에 쓰는 것이 기본보기의 데이터에 영향을 미치지 않는다는 것을 깨달았습니다. 그것이 맞는지 궁금하네요?boost :: gil :: color_converted_view with boost :: gil :: for_each_pixel

예를 들어, 적색 채널의 값을 받아 파란색 채널의 값을 절반으로 설정하는 프로그램을 작성한다고 가정 해 봅시다. SrcView 실제로 gil::rgb8_view_t

template <typename SrcView> 
void half_red_to_blue(SrcView & view) 
{ 
    // Since SrcView might be RGB or BGR or some other types, 
    // I decided to use a color_converted_view to ensure that I'm 
    // accessing the correct channels 
    typedef gil::color_converted_view_type<SrcView, gil::rgb8_pixel_t>::type MyView; 
    MyView my_view = gil::color_converted_view<gil::rgb8_pixel_t>(view): 
    struct my_lambda 
    { 
     void operator()(gil::rgb8_pixel_t & p) 
     { 
      p[2] = p[0]/2; 
     } 
    }; 
    gil::for_each_pixel(my_view, my_lambda()); 
} 

그러나에만 작동 : 여기 내 시도가 실패한입니다. 전화하면 (예 : half_red_to_blue<gil::bgr8_view_t>(view),보기가 전혀 변경되지 않습니다! 디버거에서 약간 검사를하고 쓰기 작업이 원본 픽셀 대신 프록시 위치에 쓰는 것 같습니다.

아이디어가 있으십니까? 미리 감사드립니다!

답변

0

이것은 픽셀의 색상 구성 요소가 픽셀에 액세스 할 때만 터치되기 때문에 Boost.GIL에서 유효한 동작입니다. my_lambda :: operator()를 수정하여 get_color를 사용하여 색상 구성 요소 액세스를 트리거 할 수 있습니다.

관련 문제