How to Remove Double Lines Detected Along the Edges by Edge Detector? I'm trying to take real time input for hand gestures with web cam, then processing the images to feed them to a neural network. I wrote this processing function to make the hand features look prominent:
def image_processing(image, count):
    roi = image[42:338, 2:298] 
    cv2.imwrite('a/'+str(count)+'.png', roi)
               
    img = cv2.imread('a/'+str(count)+'.png')
   
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    blur = cv2.GaussianBlur(gray,(5,5),2)

    th3 = cv2.adaptiveThreshold(blur,10,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,11,2)
    ret, res = cv2.threshold(th3, 225, 255, cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) 
    res = cv2.Canny(res,100,200) 
    cv2.imshow(&quot;Canny&quot;, res)
    cv2.imwrite('a/'+str(count)+'.png', res)

--Edit--
The input and the output images are as follows :
 
It's obvious that double lines, instead of one, are detected along the edges. I want to make them single. If I apply just Canny edge detection algo, then the edges are not very prominent.
I ran the following code:
clear();
close('all');
mI = im2double(imread('bCfdb.png')); %&lt;! Loading the image
vBlurStd = [0, 0.1, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];

mII = sum(cat(3, 0.299, 0.587, 0.114) .* mI, 3); %&lt;! Y (Luminosity like channel)

hFigure = figure('Position', [100, 100, 1200, 900]);
hTiledChartLayout = tiledlayout(3, 3);

kk = 0;
for ii = 1:3
    for jj = 1:3
        kk = kk + 1;
        if(kk == 1)
            mE = edge(mII, 'canny');
        else
            mE = edge(imgaussfilt(mII, vBlurStd(kk)), 'canny');
        end
        nexttile();
        imshow(mE);
    end
end

set(hTiledChartLayout, 'TileSpacing', 'tight', 'Padding', 'tight');


This is the result:

What Does the Script?

We set an array of different blur radius to evaluate the algorithm at - vBlurStd.
We load the image and convert it into Double in the range [0, 1] - mI = im2double(imread('bCfdb.png'));
We extract the Y channel from the YCbCr color model - mII = sum(cat(3, 0.299, 0.587, 0.114) .* mI, 3);.
The algorithm is basically blurring the image with Gaussian Blur and then applying Canny Edge Detector - edge(imgaussfilt(mII, vBlurStd(kk)), 'canny');.

The images are left to right, top down by their blur radius.