find 8 neighbours in image
3 次查看(过去 30 天)
显示 更早的评论
hi dears..... plz help me
how i find the 8 neighbours around the white pixels...
3 个评论
Image Analyst
2020-7-4
Use imdilate() then and it with the original
neighbors = imdilate(bw, true(3)) & ~bw;
回答(2 个)
KSSV
2017-9-21
Read about knnsearch
I = imread('2.png') ;
I = rgb2gray(I) ;
[y,x] = find(I) ;
% 8 nearest neighbors
[ny,nx] = size(I) ;
[X,Y] = meshgrid(1:nx,1:ny) ;
% global indices
idx = knnsearch([X(:) Y(:)],[x,y],'k',8) ;
% sub indices
[i,j] = ind2sub(size(I),idx) ;
2 个评论
Walter Roberson
2017-10-17
This code does not answer the questions "Find them in what sense? What output are you looking for?"
Mehadi Hasan
2021-10-22
I = imread('2.png') ;
I = rgb2gray(I) ;
[y,x] = find(I) ;
% 8 nearest neighbors
[ny,nx] = size(I) ;
[X,Y] = meshgrid(1:1x,1:1y) ;
% global indices
idx = knnsearch([X(:1) Y(:1)],[x,y],'k',8) ;
% sub indices
[i,j] = ind2sub(size(I),idx) ;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!