필터 지우기
필터 지우기

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

조회 수: 3 (최근 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');
  댓글 수: 1
Manny Kins
Manny Kins 2021년 11월 30일
Thank you! I managed to get them on the same screen using:
im = imfuse(Screen1,Screen2,'blend','Scaling','joint');
imshow(im)
Many thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by