Hi,
Apparently when I use the following code I am creating a matrix with 15x15 pixels.
dmin1=2;
n=15;
manhattan=ones(n,n,3);
manhattan(2:dmin1:end,2:dmin1:end,:)=0;
imwrite(manhattan,'matrix_15x15.png');
How can I make it bigger, in order to see the black points (the 0's) bigger?
To make something like:
Supose that the 0's are 32 pixel...
Then I do something like 32 pixel are 20 meters...
So, I need the 0's be bigger than 1 pixel.
Any suggestion?

8 Kommentare

KSSV
KSSV am 18 Aug. 2020
Increase n.
Oliver Lestrange
Oliver Lestrange am 18 Aug. 2020
Bearbeitet: Oliver Lestrange am 18 Aug. 2020
With the actual code, I have this:
If I increase the n for, for example 20 I get:
But this is what I see in axes of guide, cause if I look to the image saved with imwrite I get what is in the anex.
The black parts are supposed to be buildings and with the ginput I put rectangles. These rectangles probably are going to be much bigger than the buildings which is a huge problem.
Walter Roberson
Walter Roberson am 18 Aug. 2020
checkerboard() https://www.mathworks.com/help/images/ref/checkerboard.html
Oliver Lestrange
Oliver Lestrange am 18 Aug. 2020
Hi Walter,
The problem of that function is putting the squares in check position. It has to be like this
I am trying to make a manhattan grid. The balck squares are buildings and the white are street's.
Oliver Lestrange
Oliver Lestrange am 18 Aug. 2020
I am trying to understand if it's possible do this with mandist function, but if is, I am not being well succeed.
At the command line command
type checkerboard
and study how they do it.
Oliver Lestrange
Oliver Lestrange am 18 Aug. 2020
Walter Roberson, are you saying that with the checkerboard function I can display the squares in other positioning other than chess?
Walter Roberson
Walter Roberson am 18 Aug. 2020
I am suggesting that checkerboard() is a function that creates a regular repeated pattern, and that studying how it is coded would give you ideas on how to form the regular repeated pattern that you want.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Rik
Rik am 18 Aug. 2020

0 Stimmen

If you want to increase the size of the black and white parts in equal proportion, you can use the repelem function.

3 Kommentare

Hi Rik,
Thanks a lot, it works, I didn't know this function.
Oddly now a rectangle putted with the help of the ginput function, stopped work.
It doesn't show the rectangle
function insertAntenna_Callback(hObject, eventdata, handles)
% hObject handle to insertAntenna (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject)
[x_gNB, y_gNB] = ginput(1);
handles.nAntena = handles.nAntena + 1
Antena_x = x_gNB;
Antena_y = y_gNB;
rectangle('Position', [(Antena_x - handles.Rwidth/2) (Antena_y - handles.Rheight/2)...
handles.Rwidth handles.Rheight], 'FaceColor', 'r','LineStyle', 'none');
handles.Antena( handles.nAntena ).Antena_x = Antena_x;
handles.Antena( handles.nAntena ).Antena_y = Antena_y;
if ~myIsField(handles.Antena(1), 'handles.Antena(1).Info')
handles.Antena(1).Info = readAntenna('Ant60.pln', strcat(pwd,'\'));
end
handles.Antena(handles.nAntena).Info = handles.Antena(1).Info;
handles.Antena( handles.nAntena ).Altura = handles.Antena_Altura;
guidata(hObject, handles)
Any ideia why?
Rik
Rik am 18 Aug. 2020
Did you make sure the Position property of the rectangle take the new image dimensions into account?
Oliver Lestrange
Oliver Lestrange am 18 Aug. 2020
The width and height were smaller than I thought. Thanks Rik

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Exploration finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by