Keep changes in an array (SIMULINK)

2 views (last 30 days)
Domi
Domi on 6 May 2020
Edited: Domi on 7 May 2020
Hey guys,
I want to fill a blank image iterative with ones. Most of it is done with matlab function blocks so far..
Example of my Problem/Idea: Let's say I have a binary image:
img = false([5,6]);
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
I have a signal which changes it's values and is the middle point of a (selfmade) rect:
dot = [3,2];
img(dot(1,1)-1:dot(1,1)+1, dot(1,2)-1:dot(1,2)+1)
0 0 0 0 0 0
1 1 1 0 0 0
1 1 1 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
I want to save it up, such that in the next step the old rect stays there, when dot changes to dot = [3,5]:
img(dot(1,1)-1:dot(1,1)+1, dot(1,2)-1:dot(1,2)+1)
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 0 0
And with next iteration, when dot changes to dot = [4,5]
img(dot(1,1)-1:dot(1,1)+1, dot(1,2)-1:dot(1,2)+1)
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 1 1 1
etc..
I want to update the image step by step.
In my model the rect changes every time the values of dot change...
the function in the model (image down below) creates a rect with size 8by12 with a middle point coming from the variable input. Everything else is like my example description. Incoming binary image (78x120) is not full blank but hast lot of spots with 1. You can see it as a map with objects, but zeros = blank space, ones = occupied.
-
Is there a clever way to get this done in SIMULINK?
Thanks!
  11 Comments
Walter Roberson
Walter Roberson on 6 May 2020
Your question stated,
Let's say I have an false array full of zeros (or binary image):
If that is not the case, then you should be using the initial map as an input signal and you should be sending the signal back to the block with a suitable delay mechanism.
Domi
Domi on 6 May 2020
Edited: Domi on 7 May 2020
Got it by myself. Thank you.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!