Arji
Arji

Reputation: 117

Matlab - plotting points on the complex plain with certain color

I have a uint8 matrix

A = (1:512,1:512,1:3)

which contains information about an 512x512 RGB image. I Also have a matrix B which is in the format of

B = (1:512,1:512)

which holds complex numbers. Now I would like to plot every complex number

B(x,y)

on the complex plane with RGB color of

A(x,y,1:3)

How can I achieve that?

Upvotes: 0

Views: 187

Answers (2)

Mikhail Genkin
Mikhail Genkin

Reputation: 3460

1) Make your color matrix of the size Mx3 (where M is the total number of your points):

A=reshape (A,512*512,3);

2) Use Scatter plot:

scatter(real(B(:)), imag(B(:)), [], A/255)

Note that here your colormap should be from 0 to 1. Assuming that your original A contained the values from 0 to 255, you need to divide by the maximum value.

Upvotes: 2

user P520
user P520

Reputation: 317

    for r=1:512
       for c=1:512
         plot( B(r,c) ,'Color',reshape(A(r,c,1:3),1,3),'LineStyle','none','Marker','o')
       end
    end

I couldnt figure out how to make the reshape work in vectorized form without an error. This works though (albeit very slowly)!

Upvotes: 0

Related Questions