Mapping two sets of co-ordinates with two different colours onto blank white screen
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Manny Kins
am 29 Nov. 2021
Kommentiert: Manny Kins
am 30 Nov. 2021
Hi, I have a blank Screen with dimensions:
Screen = 255*ones(1024,1280,3);
Where 1024 and 1280 are the height and width and 3 is the RGB component.
If I have two separate co-ordinate systems:
r1 = [randi([1 1000],1,1500)', randi([1 1000],1,1500)']; %1500 xy positions within the Screen (wanted in Blue)
r2 = [randi([1 1000],1,1500)', randi([1 1000],1,1500)']; %1500 xy positions within the Screen (wanted in Red)
Is there a quick way (without for loop, and without using plot) to map these co-ordinates onto the Screen, with r1 being blue and r2 being red?
Below is a crude image I've made using paint to give a little more context of what I'm trying to achieve (of course with way more dots!):

Any help would be greatly appreaciated! The reason I wanted to find a quick way is because I'll be doing something like this over many iterations so was wondering if there was a fast non-for-loopy way of mapping.
For example in the next iteration I wanted to keep this Screen with the blue and red dots and then overlay a new set of blue and red dots.
Many Thanks
0 Kommentare
Akzeptierte Antwort
yanqi liu
am 30 Nov. 2021
yes,sir,may be use
clc
clear all
close all
Screen = 255*ones(1024,1280,3);
r1 = [randi([1 1000],1,1500)', randi([1 1000],1,1500)']; %1500 xy positions within the Screen (wanted in Blue)
r2 = [randi([1 1000],1,1500)', randi([1 1000],1,1500)']; %1500 xy positions within the Screen (wanted in Red)
Screen1 = insertShape(uint8(Screen),'FilledCircle',[r1 ones(size(r1,1),1)],'color','blue');
Screen2 = insertShape(uint8(Screen),'FilledCircle',[r2 ones(size(r2,1),1)],'color','red');
figure; imshow(Screen1); title('blue');
figure; imshow(Screen2); title('red');
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!