I recommend you filter the image with a 2-D smoothing function, or kernel. The user specifies the horizontal and vertical separation of points that should be merged. The code does the rest.
First, make a sample image with two pairs of dots.
im1(37:40,60:63)=ones(4); im1(40:43,133:136)=ones(4);
im1(49:52,66:69)=ones(4); im1(46:49,121:124)=ones(4);
subplot(211), imshow(im1); title('Original')
Specify the vertical and horizontal separation of points that should be merged, in pixels. If you want to merge a pair that is oriented upper left to lower right, make h and v positive. If you want to merge a pair that is oriented lower left to upper right, make h or v negative. In this case, we want to merge the pair of dots on the left, which have separation v=12, h=6.
Compute the kernel, which will be used for filtering. The kernel long axis is three times the short axis (3:1). If you want the kernel relative dimensions to be 2:1, or 4:1, then try
Z=max(1-(Xr/(d/1.5)).^4-(Yr/(d/3)).^4,0);
or
Z=max(1-(Xr/(d/1.5)).^4-(Yr/(d/6)).^4,0);
instead of the corresponding line below. And so on.
Xr=X*cos(theta)+Y*sin(theta);
Yr=-X*sin(theta)+Y*cos(theta);
Z=max(1-(Xr/(d/1.5)).^4-(Yr/(d/4.5)).^4,0);
Filter the image using the kernel, and plot the filtered image.
subplot(212), imshow(im2); title('Filtered')
Plot the kernel function. H and V correspond to pixel values.
title(['Smoothing Filter: V=',num2str(v),', H=',num2str(h)])
colorbar; xlabel('V=vert'); ylabel('H=horiz')
Good luck with your 2D gas chromatography analysis.