help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting a color gamut?


From: Carnë Draug
Subject: Re: Plotting a color gamut?
Date: Mon, 26 Jan 2015 22:04:04 +0000

On 26 January 2015 at 12:09, Alasdair McAndrew <address@hidden> wrote:
> I'm trying to plot a CRT gamut, similar to the picture at
>
> http://en.wikipedia.org/wiki/Gamut
>
> I have an N x 2 array "pts" of all the points to be plotted, and a
> corresponding N x 3 list "clrs" of the RGB color of each one.  However, the
> commands
>
> hold on
> for i = 1:N,plot(pts(i,1),pts(i,2),'color',clrs(i,:),'.'),end;
>
> works, but is very very slow.  Is there a way of speeding this up; or in
> general for plotting a very large amount of points (100,000, say), each
> with a particular color?

You create an actual RGB image and "plot" it.  From your snippet, the
following should work (may require some adjustments, specially if pts has
negative values but should give you an idea):

    im = ones ([max(pts) 3]);
    ind = sub2ind (size (im), repmat (pts(:,1), [3 1]),
                              repmat (pts(:,2), [3 1]),
                              repmat ([1 2 3], [rows(pts) 1])(:));

    im(ind) = clrs(:)
    image (im)

Also, to create a spectrum, take a look at the composite option of rgbplot

    rgbplot (hsv, "composite")

Carnë



reply via email to

[Prev in Thread] Current Thread [Next in Thread]