Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created March 11, 2020 14:37
Show Gist options
  • Save mattgaidica/89381829c6dc58ac63735849b0e8dc27 to your computer and use it in GitHub Desktop.
Save mattgaidica/89381829c6dc58ac63735849b0e8dc27 to your computer and use it in GitHub Desktop.
Reducing color palette script
paletteImPath = '~/Downloads/myLittePalette.JPG';
mypal = paletteMaker(paletteImPath);
imPath = '~/Downloads/squirrels.JPG';
[im, cmap] = rgb2ind(imread(imPath),256);
figure('position',[0 0 1200 800]);
subplot(121);
imshow(im,cmap);
subplot(122);
[Y,newmap] = imapprox(im,cmap,mypal/255);
imshow(Y,newmap);
linkaxes;
newimPath = 'mypalim.png';
imwrite(Y,newmap,newimPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment