Hi there Community,
I have the folllowing image and the antenna:
[Horizontal,Vertical,Optional] = msiread(strcat(pathName,fileName));
How can I associate a rectangle to an antenna?
I made the rectangle using:
rectangle('Position', [(x - handles.Rwidth/2) (y - handles.Rwidth/2)...
handles.Rwidth handles.Rheight], 'FaceColor', 'g','LineStyle', 'none');
Is it possible to affect the rectangule with the struct (antenna)?

10 Kommentare

Walter Roberson
Walter Roberson am 5 Aug. 2020
Could you explain more what you mean by "associate" ?
Are you asking for some image processing to locate the yellow blobs, calculate the centroids, and then use those centroids as the locations to place antennae ?
My guess is that you want to change the position of the rectangle according to some other object on the plot. Changing the position of an existing rectangle can be done by changing its position property.
h = rectangle('Position', [1 2 3 4]);
% change position
h.Position = [2 3 4 5];
Walter Roberson
Walter Roberson am 5 Aug. 2020
I see that you edited your question, but unfortunately I do not know what you mean by "affect the rectangle with the struct (antenna)" ??
Oliver Lestrange
Oliver Lestrange am 6 Aug. 2020
Well... the yellow squares is supoosed to be antennas. Those green rectangles were made with ginput because I didn't found another way to say that I want that the yellow squares are antennas.
Walter Roberson
Walter Roberson am 6 Aug. 2020
Are you asking for some image processing to locate the yellow blobs, calculate the centroids, and then use those centroids as the locations to place antennae ?
Oliver Lestrange
Oliver Lestrange am 6 Aug. 2020
I don't need exactly the centroids, I just need to somehow know that the part of the image with yellow squares is the antenna. In other words, I need to know that the yellow blobs have a certain gain, elevation, etc.
Adam Danz
Adam Danz am 6 Aug. 2020
If you plotted the yellow squares, then you know their positions. Use the positions to keep track of where the yellow squares are. The problem is still not clear.
Oliver Lestrange
Oliver Lestrange am 6 Aug. 2020
Maybe with this image is more easy to explain.
Imagine that I read this image. Now, I need to know, or put, the antennas in the yellow thing called BTS_xx, in order to calculate the coverage.
Adam Danz
Adam Danz am 6 Aug. 2020
So this is an image processing problem as Walter Roberson elluded to, correct?
Oliver Lestrange
Oliver Lestrange am 6 Aug. 2020
Yes

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Aug. 2020

1 Stimme

rgb = imread(filename) ;
mask = rgb(:, 1) < 32 & rgb(:, 2) > 224 & rgb(:, 3) > 224;
mask = bwareafilt(mask, [50 inf]);
props = regionprops(mask, 'centroid') ;
locations = vertcat(props.Centroid);
The constants in the above are not tested, only "by eye", and probably need to be adjusted.
The resulting variable will be a something by 2 array in which the first column is x and the second is y. Note that x corresponds to columns, second array index, and y corresponds to row, first index.

4 Kommentare

Can you explain me what the following line does in order to understand what this values mean?
mask = rgb(:, 1) < 32 & rgb(:, 2) > 224 & rgb(:, 3) > 224;
Thanks a lot for the answer!
Best regards
Walter Roberson
Walter Roberson am 6 Aug. 2020
It detects bright yellow. Yellow has little red component but bright yellow has strong blue and green components.
Oliver Lestrange
Oliver Lestrange am 7 Aug. 2020
And why the < 32 and > 224 ? Where this numbers came from?
Looks like I should have used
mask = rgb(:, :, 1) > 224 & rgb(:, :, 2) > 224 & rgb(:, :, 3) < 32;
as I was mistaken about the composition of yellow in RGB.
filename = 'image.png';
rgb = imread(filename) ;
mask = rgb(:, :, 1) > 200 & rgb(:, :, 2) > 200 & rgb(:, :, 3) < 32;
maskfilt = bwareafilt(mask, [50 inf]);
props = regionprops(maskfilt, 'centroid') ;
locations = vertcat(props.Centroid);
imshow(rgb)
hold on
scatter(locations(:,1), locations(:,2), 'r*')
hold off
The 32 and 224 came from my experience with RGB colors.
Your yellow blobs appear to be approximately "dark yellow 1". You can tell the values by imshow(rgb) and using the data cursor tool to read RGB values off of the image.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Read, Write, and Modify Image 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