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
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!