I have a centroid plotted on a blank image using the command img(a(2),a(1))=1;
I would like to create a 3*3 matrix of ones around this pixel as centroid.
Can someone tell me how i can achieve this.
Thankyou

 Akzeptierte Antwort

Jos (10584)
Jos (10584) am 7 Jul. 2014

0 Stimmen

One solution:
img = zeros(6,7)
a = [4 3]
img(a(2),a(1)) = 1
B = [1 1 1 ; 1 0 1 ; 1 1 1];
img2 = conv2(img, B ,'same')

Weitere Antworten (1)

Mahendra Amrao
Mahendra Amrao am 8 Sep. 2020

0 Stimmen

img = zeros(6,7)
a = [4 3]
img(a(2),a(1)) = 1
B = [1 1 1 ; 1 0 1 ; 1 1 1];
img2 = conv2(img, B ,'same')

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by