Mapping two sets of co-ordinates with two different colours onto blank white screen

1 次查看(过去 30 天)
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

采纳的回答

yanqi liu
yanqi liu 2021-11-30
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by