フィルターのクリア

Generate all colour permutations of an image

2 ビュー (過去 30 日間)
Noah Posner
Noah Posner 2021 年 8 月 25 日
コメント済み: Noah Posner 2021 年 8 月 25 日
Hello,
I am looking to take the mondrian art image below and generate all the possible colour permutations. Does anyone have advice as to how to go about this?

採用された回答

Chunru
Chunru 2021 年 8 月 25 日
x = imread("image.png");
image(x)
% unique colors in the image
uc = unique(reshape(x, numel(x)/3, 3), 'rows');
nc = size(uc, 1);
fprintf('There are %d unique colors\n', nc);
p = perms(1:nc);
fprintf('There are %d permutations of colors\n', size(p, 1));
x2 = reshape(x, numel(x)/3, 3);
for i=1:size(p,1)
xp = x2;
for j=1:nc
idx = all(x2 == uc(j,:), 2);
for k=1:3
xp(idx, k) = uc(p(i,j), k);
end
end
xp = reshape(xp, size(x));
image(xp);
drawnow
pause(0.05)
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by