ok,

- Images and process status

[source image, RGB image]

[After pre-processing_Left image of source]

[After pre-processing_Right image of source]

[After Canny Edge Detection_Left image of source]

[After Canny Edge Detection_Right image of source]

[Result of contourshape. As you can see Left is ok, but Right is strange]

Left side similar values

similar value: [0]index, value : [3.257]

similar value: [1]index, value : [2.248]

similar value: [2]index, value : [2.748]

similar value: [3]index, value : [4.316]

similar value: [4]index, value : [2.605]

similar value: [5]index, value : [2.639]

Right side similar values

similar value_right: [0]index, value : [2.121]

similar value_right: [1]index, value : [2.433]

similar value_right: [2]index, value : [2.675]

similar value_right: [3]index, value : [2.451]

similar value_right: [4]index, value : [inf]

similar value_right: [5]index, value : [inf]

similar value_right: [6]index, value : [inf]

similar value_right: [7]index, value : [2.299]

similar value_right: [8]index, value : [2.367]

similar value_right: [9]index, value : [2.878]

similar value_right: [10]index, value : [2.501]

similar value_right: [11]index, value : [4.29]

similar value_right: [12]index, value : [2.835]

similar value_right: [13]index, value : [2.917]

similar value_right: [14]index, value : [3.71]

similar value_right: [15]index, value : [4.134]

similar value_right: [16]index, value : [4.496]

source code

//Data Initialize

if(!g_InImg1_ROI.empty()){ g_InImg1_ROI.zeros(g_InImg1_ROI.rows, g_InImg1_ROI.cols, CV_8UC3);}

if(!g_InImg2_ROI.empty()){ g_InImg2_ROI.zeros(g_InImg2_ROI.rows, g_InImg2_ROI.cols, CV_8UC3);}

```
if(!L_hist_mat.empty()){ L_hist_mat.zeros(L_hist_mat.rows, L_hist_mat.cols, CV_8UC3);}
if(!R_hist_mat.empty()){ R_hist_mat.zeros(R_hist_mat.rows, R_hist_mat.cols, CV_8UC3);}
//ROI Setting
cv::Mat ROI_L_g_InImg1 = g_InImg1(cv::Rect(0,0,1080,660)); //Left
cv::Mat ROI_R_g_InImg1 = g_InImg2(cv::Rect(200,0,1080,660)); //Right
g_InImg1_ROI = ROI_L_g_InImg1.clone();//Left
g_InImg2_ROI = ROI_R_g_InImg1.clone();//Right
//output for result
//Left
Mat outimg = ROI_L_g_InImg1.clone();
g_Left_result=outimg.clone();
//Right
Mat outimg2 = ROI_R_g_InImg1.clone();
g_Right_result=outimg2.clone();
//Remove noise
//Left
Mat median_result;
cv::medianBlur(ROI_L_g_InImg1,median_result,17);
cv::GaussianBlur(median_result,median_result,Size(5,5),0,0);
//Right
Mat median_result2;
cv::medianBlur(ROI_R_g_InImg1,median_result2,17);
cv::GaussianBlur(median_result2,median_result2,Size(5,5),0,0);
//shape match mat
Mat shape_mat_left, shape_mat_right;
shape_mat_left = median_result.clone();
shape_mat_right = median_result2.clone();
cv::cvtColor(shape_mat_left,shape_mat_left,CV_BGR2GRAY);
cv::cvtColor(shape_mat_right,shape_mat_right,CV_BGR2GRAY);
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE();
clahe->setClipLimit(2);
clahe->setTilesGridSize(Size(8,8));
clahe->apply(shape_mat_left, shape_mat_left);
clahe->apply(shape_mat_right, shape_mat_right);
//cv::threshold(shape_mat_left,shape_mat_left,0,255,THRESH_OTSU);
//cv::threshold(shape_mat_right,shape_mat_right,0,255,THRESH_OTSU);
cv::imshow("shape_mat_left",shape_mat_left);
cv::imshow("shape_mat_right",shape_mat_right);
Mat Edge_Left, Edge_Right;
Mat LX, LY, RX, RY;
Canny_Ben(shape_mat_left,Edge_Left,70,130,3,0,LX,LY); //Get Edge
Canny_Ben(shape_mat_right,Edge_Right,70,130,3,0,RX,RY); //Get Edge
cv::imshow("Left",Edge_Left);
cv::imshow("Right",Edge_Right);
cv::findContours(Edge_Left, contours, RETR_EXTERNAL, CHAIN_APPROX_NONE);
cv::findContours(Edge_Right, contours2, RETR_EXTERNAL, CHAIN_APPROX_NONE);
cont_simlar.push_back(make_pair(std::round(cv::matchShapes(g_contour_left_save,contours[i],CONTOURS_MATCH_I3,0) * 1000)/1000,i));
```

cont_simlar2.push_back(make_pair(std::round(cv::matchShapes(g_contour_right_save,contours2[i],CONTOURS_MATCH_I3,0)*1000)/1000,i));