Skip to content

Instantly share code, notes, and snippets.

@hkhojasteh
Created January 30, 2019 05:33
Show Gist options
  • Save hkhojasteh/a88e6a14bfd2cd900a4ff85bfb304d1f to your computer and use it in GitHub Desktop.
Save hkhojasteh/a88e6a14bfd2cd900a4ff85bfb304d1f to your computer and use it in GitHub Desktop.
//Crop image and convert to gray, blur, sharpen, bitwise_not and black-white image
Mat img_gray, img_sharp, img_sharp_not, img_zeroone;
cvtColor(crop, img_gray, CV_BGR2GRAY);
blur(img_gray, img_gray, Size(4, 4));
GaussianBlur(img_gray, img_sharp, cv::Size(0, 0), 6);
addWeighted(img_gray, 1.80, img_sharp, -0.55, 0, img_sharp);
bitwise_not(img_sharp, img_sharp_not);
threshold(img_sharp_not, img_zeroone, 20, 255, THRESH_BINARY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment