Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created March 11, 2020 14:11
Show Gist options
  • Save mattgaidica/3ad4c3b7372c2df8777f2a35bfda476f to your computer and use it in GitHub Desktop.
Save mattgaidica/3ad4c3b7372c2df8777f2a35bfda476f to your computer and use it in GitHub Desktop.
Creates a color palette (i.e. colormap) by selecting points on an image
function mypal = paletteMaker(paletteImPath)
% input: image path for your palette
% output: color palette as a colormap
im = imresize(imread(paletteImPath),0.5);
figure;
imshow(im);
[xs,ys,mypal] = impixel();
for iColor = 1:size(mypal,1)
im = insertShape(im,'filledcircle',[xs(iColor) ys(iColor) size(im,1)/40],...
'color',mypal(iColor,:),'opacity',1);
im = insertShape(im,'circle',[xs(iColor) ys(iColor) size(im,1)/40],...
'color','black','lineWidth',10);
imshow(im);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment