본문 바로가기

Programming/OpenCV

[OpenCV] 두 이미지의 차영상 만들기

# 이미지의 차(뺄셈) 이용

이미지(x,y) - 이미지(x,y) = 결과이미지(x,y)

 

@ OpenCV를 이용한 활용

 

 //차영상 만들기

for(int _height = 0 ;_height < src_image1->height ; _height++)
{
    for(int _width = 0; _width < src_image1->width ; _width++)
   {
       int differ_value;
       differ_value = gray_image1->imageData[_height * gray_image1->width +  _width] - 
                         gray_image2->imageData[_height * gray_image2->width +  _width];
       differ_value = abs(differ_value);
    
       if(differ_value >= 10)
       {
           result_image->imageData[_height * gray_image1->width +  _width] = 255;
       }
       else
       {
           result_image->imageData[_height * gray_image1->width +  _width] = 0;
       }

   }

}

반응형