HOW CAN I CREATE A 3X3 PATCH IN AN IMAGE AND ALSO TAKE THE CENTRE PIXEL FROM ITS EIGHT NEIGHBORHOOD
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Afiq Azaibi
le 23 Mar 2017
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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!