Skip to content Skip to sidebar Skip to footer

Converting C++ Opencv To Python

I am trying to remove horizontal and vertical lines from my images that look like this: While googling I found a solution that I believe might work: Extract horizontal and vertica

Solution 1:

Looks like that you have the problem because of tilde operator that applies bitwise NOT operation to all pixels in the image. Look at this three lines of C++ code:

cv::Mat img = imread("smiley.png", IMREAD_GRAYSCALE);
imshow("Image0", img);
imshow("Image1", ~img); // tilde

These are the images you get:

enter image description hereenter image description here

Quick solution: if you want to apply thresholding correctly then either

  • apply bitwise negation to the input array, or
  • use 'THRESH_BINARY_INV' instead of 'THRESH_BINARY'

Post a Comment for "Converting C++ Opencv To Python"