c++ - Change pixels between similar pixels on image -


i want average pixel color between 2 similar pixels. white pixels between black pixels should become black , vice versa. rule must apply in directions. complete example of should happen:

horizontal: □■□ -> □□□  vertical: □   ->  □ ■   ->  □ □   ->  □  ■□■ -> ■■■   ■   ->  ■ □   ->  ■ ■   ->  ■   □■□  ->   □□□   ->   □□□ ■■■  ->   ■■■   ->   ■□■ ■□■  ->   ■□■   ->   ■□■ 

can opencv this? can make algorighm this? tried:

while(i<image->width){     while(j<image->height){         if(pixel[i,j-1] == pixel[i,j+1]){             pixel[i,j] = pixel[i,j-1];         }else if(pixel[i-1,j] == pixel[i+1,j]){             pixel[i,j] = pixel[i-1,j];         }         j++;     }     i++; } 

you didn't access image pixels correctly.

for gray-scale image (in example, mat pixel), access pixel, should use:

pixel.at<uchar>(j, i) = ...; 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -