HOW CAN I CREATE A 3X3 PATCH IN AN IMAGE AND ALSO TAKE THE CENTRE PIXEL FROM ITS EIGHT NEIGHBORHOOD

3 次查看(过去 30 天)
Hello,
I need help to create a 3x3 patch of my image and also take the pixel at the centre of its neighborhood.
Many thanks
Longman

回答(1 个)

Afiq Azaibi
Afiq Azaibi 2017-3-23
An image functions as a 3 dimensional matrix and in order to index a 3x3 matrix out of an image, you can do the following:
im = imread('peppers.png');
patch = im(1:3,1:3,1:3); %indexes first three rows with first three columns and all three RGB values
center = patch(2,2,:); %this returns the center of each layer.
imshow(patch,'InitialMagnification','fit'); %shows the 9 pixels magnified
If you can describe what you mean by "3x3 patch" regarding an image in more detail, it could help me provide some more relevant code for your use case.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by