I have a color picture with red and blue colors. I separated the blue and red color signal sand created black and white images from them as such: first image and second image
Now, I want to see how if the white spots in the second image overlap on top of the squiggly lines in the first image.
My approach is the following:
- First detect the center coordinate of the white spots in the 2nd image. Avoiding the big white clusters. I only care about the white spots that are in the same vicinity of the squiggly lines in the first image.
- Then use the following MATLAB code to see if the white spot is on top of the squiggly lines from the first image.
The code is courtesy of @rayryeng
val = 0; % Value to match
count = 0
N = 50; % Radius of neighbourhood
% Generate 2D grid of coordinates
[x, y] = meshgrid(1 : size(img, 2), 1 : size(img, 1));
% For each coordinate to check...
for kk = 1 : size(coord, 1)
a = coord(kk, 1); b = coord(kk, 2); % Get the pixel locations
mask = (x - a).^2 + (y - b).^2 <= N*N; % Get a mask of valid locations
% within the neighbourhood
pix = img(mask); % Get the valid pixels
count = count + any(pix(:) == val); % Add either 0 or 1 depending if
% we have found any matching pixels
end
Where I am stuck: I'm having trouble detecting the center point of the white spots in the 2nd image. Especially because I want to avoid the clusters of white spots. I just want to detect the spots that are in the same vicinity of the squiggly lines in the first image.
I am willing to try any language that has good image analysis libraries. How do I go about this?