How to select a pixel and get its surrounding eight neighbors using nearest neighbor?
2 ビュー (過去 30 日間)
古いコメントを表示
How to select a pixel and get its surrounding eight neighbors using nearest neighbor?
The input image is as follows:

0 件のコメント
回答 (1 件)
Image Analyst
2016 年 4 月 27 日
use ginput to get the coordinate:
[x, y] = ginput(1);
row = round(y);
col = round(x);
neighbors = [grayImage(row-1, col-1);...
grayImage(row-1, col-1);...
grayImage(row-1, col);...
grayImage(row-1, col+1);...
grayImage(row, col-1);...
grayImage(row, col+1);...
grayImage(row+1, col-1);...
grayImage(row+1, col);...
grayImage(row+1, col+1)];
You can put them in whatever order you find convenient.
2 件のコメント
Image Analyst
2016 年 4 月 29 日
編集済み: Image Analyst
2016 年 4 月 29 日
I have no idea. Evidently you've read some paper that says you're supposed to get "votes" from neighboring pixels, but we have no knowledge of that paper obviously, or how it determines "votes". You don't even have a classified image at this point - it's just a simple gray scale image, not one with "classes" where each pixel is classified into one class like "road", "house", "ground", "vehicle", "water", or whatever.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!