How to insert a disc and centered around the dot?

Hi,
I have A = zeros(100,100) materix which I added a while pixel (dots) in this zeros materix randomly. I have also another disc materix as follows
disk = strel('disk', 10);
D = disk.Neighborhood;
what I want to do is insert the disc and centered around the pixel ( white pixel)

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Feb. 2020
A(appropriate_row:appropriate_row+99, appropriate_column:appropriate_column+99) = ...
A(appropriate_row:appropriate_row+99, appropriate_column:appropriate_column+99) | D;

3 Kommentare

Sara
Sara am 10 Feb. 2020
Thank you for your reply,
it shows erros
A(rmax:rmax+99, cmax:cmax+99) = A(rmax:rmax+99, cmax:cmax+99)| D
Index in position 1 exceeds array bounds (must not exceed 100).
Here is the mterixs that I used in the code:
A =zeros(100,100);
random_row = round(rand*100)
random_col = round(rand*100)
A (random_col, random_row)=1
disk = strel('disk', 10);
D = disk.Neighborhood;
but does shwo erros when I applied your comments.
The +99 should be +9
Protection needs to be added for the case that the location is near an edge.
Sara
Sara am 10 Feb. 2020
Thank you for your reply. I did fix this as you says. it should be less than the disc raduis which is 10 in my case.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 10 Feb. 2020

Kommentiert:

am 10 Feb. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by