i want to shuffle the pixels of an color image using keys which is generated by chaotic map.But i get black and white image instead of color image.

1 次查看(过去 30 天)
clc;
clear all;
close all;
%split to rgb planes
img = imread('lenacolor32.tif'); % Read image
red = img(:,:,1); % Red channel
% figure, imshow(red), title('red')
green = img(:,:,2); % Green channel
% figure, imshow(green), title('green')
blue = img(:,:,3); % Blue channel
% figure, imshow(blue),title('blue')
a = zeros(size(img, 1), size(img, 2));
% figure, imshow(a),title('a')
R = cat(3, red, a, a);
G = cat(3, a, green, a);
B = cat(3, a, a, blue);
figure, imshow(img), title('Original image');
figure, imshow(R), title('Red plane');
figure, imshow(G), title('Green plane');
figure, imshow(B), title('Blue plane');
[r,c,n]=size(img);
id=fix(r/3);
im1=img(1:id,:,:);
im2=img(id+1:2*id,:,:);
im3=img(2*id+1:r,:,:);
op1=horzcat(im1,im2,im3);
figure, imshow(op1),title('Horizontal format');
maxpointsp = 25;
Np = 3074;
ap = 0;
bp = 4;
rsp = linspace(ap,bp,Np);
Mp = 500;
for j = 1:length(rsp)
rp=rsp(j);
xp=zeros(Mp,1);
xp(1) = 0.5;
a1p=4-rp;
for i=1:Mp
if (xp(i)<=0.5 )
xp(i+1)=mod(((rp*xp(i))/2+(a1p*sin(pi*xp(i)))/4),0.999);
else
xp(i+1)=mod(((rp*(1-xp(i)))/2+(a1p*sin(pi*(1-xp(i)))/4)),0.999);
end
end
outp{j} =xp(end-maxpointsp:end);
end
datap = [];
for k = 1:length(rsp)
n = length(outp{k});
datap = [datap; rsp(k)*ones(n,1),outp{k}];
end
% hp=plot(datap(:,1),datap(:,2),'k.');
opp=datap(:,2).*3074;
resp=round(opp);
ap =resp;
[bp,m1,n1] = unique(ap);
[c1,d1] =sort(m1);
bp = bp(d1);
pkey=bp;%final key
pkey=vec2mat(pkey,96);
%pixel perm
actu2=zeros(size(img));
actu2=img(:,:,:);
chang2=zeros(size(actu2));
chang2=actu2(:,:,:);
for r=1:1:32
for c=1:1:96
if(pkey(r,c)==0);
else
actu2(r,c,:)=chang2(pkey(r,c),:);
end
end
end
figure, imshow(actu2),title('Pixel permutation');
  1 个评论
Guillaume
Guillaume 2018-2-1
i get black and white image instead
Your code is very convoluted but if I read it correctly the only thing it can produce without erroring is a black image. If the else branch of your last if is executed then
actu2(r,c,:)=chang2(pkey(r,c),:);
will produce an error (unless the image is only 3 pixels wide)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by