Image reconstruction after converting it from PBC to CGC and back.
3 次查看(过去 30 天)
显示 更早的评论
I'm currently working BPCS steganography, only on gray scale images though. The process requires me to convert the image from pbc to cgc and then perform bit plane slicing and in the end, i'm required to merge the bit planes and then convert it back to cgc.
The problem is that the output of the final image shows to be in binary even when the matrix values range from 0 255.
clear; clc; close all; x=rgb2gray(imresize(imread(imgetfile),[512 512])); x=uint8(x); c0=mod(x,2); c1=mod(floor(x/2),2); c2=mod(floor(x/4),2); c3=mod(floor(x/8),2); c4=mod(floor(x/16),2); c5=mod(floor(x/32),2); c6=mod(floor(x/64),2); c7=mod(floor(x/128),2); cgc=zeros(512,512,8); cgc(:,:,1)=pbc(c0); cgc(:,:,2)=pbc(c1); cgc(:,:,3)=pbc(c2); cgc(:,:,4)=pbc(c3); cgc(:,:,5)=pbc(c4); cgc(:,:,6)=pbc(c5); cgc(:,:,7)=pbc(c6); cgc(:,:,8)=pbc(c7); rpbc=zeros(512,512,8); for i = 1:1:8 rpbc(:,:,i)=cgc2(cgc(:,:,i)); end finali=zeros(512,512); for i = 1:1:512 for j = 1:1:512 finali(i,j)=(rpbc(i,j,8)*128)+(rpbc(i,j,7)*64)+(rpbc(i,j,6)*32)+(rpbc(i,j,5)*16)+(rpbc(i,j,4)*8)+(rpbc(i,j,3)*4)+(rpbc(i,j,2)*2)+(rpbc(i,j,1)*1); end end finali=mat2gray(finali); figure,imshow(finali); %pbc2cgc function [ cgc ] = pbc( img ) [rows, cols] = size(img); %img=logical(img); x=img; for i=1:rows x(i,1)=img(i,1); end for i=1:1:rows for j=2:1:cols x(i,j)=bitxor(img(i,j-1),img(i,j)); end end cgc=uint8(x); end
%cgc2pbc function [ pbc ] = cgc2( img ) [rows, cols] = size(img); %img=logical(img); x=img; for i=1:rows x(i,1)=img(i,1); end for i=1:1:rows for j=2:1:cols x(i,j)=bitxor(img(i,j-1),x(i,j)); end end pbc=uint8(x);
end
回答(1 个)
Image Analyst
2014-4-13
Just before the end, what does this show:
whos x
class x
5 个评论
Image Analyst
2014-4-14
Evidently the formatting tutorial was too tough.
The image I saw was in grayscale.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!