# Trying to find the neighboring pixel outside the region boundary along the centre

1 view (last 30 days)
Warid Islam on 19 Jul 2021
I have a ROi where I want to find the pixel value of a boundary pixel and its neighboring pixel outwardly to the region boundary along the radial ray between the region centre and this boundary pixel. h.jpg explains the problem better. I want to find the pixel value of C1 and C2. h2.jpg is the image where I want to implement the above problem. The region inside the yellow boundary is my ROI. I want to find the value of a pixel on the yellow boundary and the value of the pixel outwardly to the region boundary along the radial ray between the region centre and the boundary pixel. I tried the following line of code but I think my process is wrong. Any suggestions would be appreciated.
I2=imread('h2.jpg')
[nr, nc] = size(I2);
[r, c] = find(I2);
aboves = [r - 1, c];
aboves(r == 1, :) = [];
belows = [r + 1, c];
belows(c == nr, :) = [];
lefts = [r, c - 1];
lefts(c == 1, :) = [];
rights = [r, c + 1];
rights(c == nc, :) = [];
aboveleft = [r - 1, c - 1];
aboveleft(r == 1 | c == 1, :) = [];
aboveright = [r, c + 1];
aboveright(r == 1 | c == nc, :) = [];
belowleft = [r + 1, c - 1];
belowleft(r == nr | c == 1, :) = [];
belowright = [r + 1, c + 1];
belowright(r == nr | c == nc, :) = [];
neighbors = [aboveright; lefts; belows; aboveleft; belowright; aboves; rights; belowleft];
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Categories

Find more on Image Segmentation and Analysis in Help Center and File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!