首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检查两幅不同图像的像素重叠

检查两幅不同图像的像素重叠
EN

Stack Overflow用户
提问于 2017-05-26 06:29:31
回答 1查看 2.2K关注 0票数 1

我有一张红色和蓝色的彩色图片。我把蓝色和红色的信号砂从它们中分离出来:第一图像和第二图像。

现在,我想看看第二幅图像中的白点是否重叠在第一幅图像上的线条上。

我的做法如下:

  1. 首先检测第二幅图像中白点的中心坐标。避开白色的大簇。我只关心在第一张图像中的线条附近的白点。
  2. 然后使用下面的MATLAB代码来查看白点是否位于第一幅图像上的光滑线条的顶部。

代码由@rayryeng提供

代码语言:javascript
复制
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

,我被卡住了:,在第二张图像中,我很难检测到白点的中心点。尤其是因为我想避免白点的聚集。我只想在第一张图像中,在相同的线附近探测到这些斑点。

我愿意尝试任何有良好图像分析库的语言。我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2017-05-27 11:17:31

这似乎很管用:

代码语言:javascript
复制
pos = rp.WeightedCentroid; %all positions
for ct = size(pos,1):-1:1  %check them backwards
d = sum((pos-pos(ct,:)).^2); %distance to all other points (kd-trees could be used for speedup)
if min(d)<50^2,pos(ct,:)=[];end  %remove if any point is too close

结束

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44195033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档