normaly when scratch exist product surface, the value of pixes are different from its background, but when background like random noise it's difficult distinguish scratch defect from background.
src img include scrach cross binaryed image
one common method seperate differen gray value is binalization, the src image and binalized img, the result is difficult to seperate scratch.
Mat img_roi = imread(str_path_read, 0);
/*fix threshold*/
int thresh_b = 170;
Mat img_roi_b;
threshold(img_roi, img_roi_b, thresh_b, 255, THRESH_BINARY_INV);