1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
clc;clear; pic='lsb.png'; [I, ~, alpha]=imread(pic); [X,Y,~]=size(I); if isempty(alpha) alpha=ones([X,Y])*255; end speed=0.5; color={'red','green','blue', 'alpha'}; imshow(I); pause(1);
for plane=1:3 for bit=1:8 pause(speed); bits=bitget(I, bit); imshow(logical(bits(:, :, plane))); title(strcat(color(plane), ' plane-', num2str(bit))); end end
plane=4; for bit=1:8 pause(speed); bits=bitget(alpha, bit); imshow(logical(bits)); title(strcat(color(plane), ' plane-', num2str(bit)));
end
for plane=1:3 I0=I; y0=bitget(I0, 1); for bit=1:3 bits=y0(:, :, bit); bits(find(bits == 0))=randi([1, 255]); bits(find(bits == 1))=randi([1, 255]); I0(:, :, bit)=bits; end imshow(I0); title(strcat( 'random color map-', num2str(plane))); pause(speed) end
R=I;R(:,:,[2 3])=0; G=I;G(:,:,[1 3])=0; B=I;B(:,:,[1 2])=0; A=alpha;A(:,:,[2 3])=0; imshow(R);title('Full Red');pause(speed) imshow(G);title('Full Green');pause(speed) imshow(B);title('Full Blue');pause(speed) imshow(A);title('Full Alpha');pause(speed)
imshow(255 - imread(pic)); title('colour inversion');pause(speed);
I0=I;
for x=1:X for y =1:Y if isequal(I0(x,y,1),I0(x,y,2),I0(x,y,3))==1 I0(x,y,1)=255; I0(x,y,2)=255; I0(x,y,3)=255; else I0(x,y,1)=0; I0(x,y,2)=0; I0(x,y,3)=0; end end end imshow(I0) title('Gray bits');
|
评论