reversible contrast mapping based watermarking on dicom image
조회 수: 1 (최근 30일)
이전 댓글 표시
i have written a code for watermarking on a dicom image based on reversible contrast mapping algorithm.
trouble shooted many times but didnt get the correct embedding and extraction. kindly help me to correct the same. the code is as follows
clc;
%code for separating the ROI and RONI of a DCM file
clear all;
close all;
[RONI,MAP]=dicomread('189.dcm');
InputImg1 = uint8(255*mat2gray(RONI));
% Display the Image
figure,imshow(InputImg1,[]);title('Select the region of interest(ROI)');
% Get Inputs from Mouse,Select 4 Seed Points in Image
[Col Row]=ginput(4);
c =Col;
r =Row;
% Select polygonal region of interest
BinaryMask = roipoly(InputImg1,c,r);
%figure,imshow(BinaryMask,[]); title('Selected Region of Interest')
%Create Buffer for ROI
ROI=zeros(512,512);
%Create Buffer for NONROI
RONI=zeros(512,512);
for i=1:512
for j=1:512
if BinaryMask(i,j)==1
ROI(i,j)=InputImg1(i,j);
else
RONI(i,j)=InputImg1(i,j);
end
end
end
%Display ROI and Non ROI
figure,imshow(ROI,[]);title('ROI');
impixelinfo
figure,imshow(RONI,[]);title('NON ROI');
img=uint8(ROI);
%img=imread('cameraman.tif');
%figure,imshow(img);
impixelinfo
%grouping the pixel pairs
[rows,cols]=size(img);
x1=img(:);
x2=buffer(x1,2);
pixels=x2';
p=pixels;
[row1,cols1]=size(pixels);
%watermark bit generation
wm=randsrc(row1,1,[0 1]);
for i=1:length(pixels)
if (0<(2*pixels(i,1)-pixels(i,2)<=511)&& (bitget(pixels(i,1),1)==0)) && (0<(2*pixels(i,2)-pixels(i,1)<=511)&& (bitget(pixels(i,2),1)==0))
a=pixels(i,1);
b=pixels(i,2);
pixels(i,1)=2*a-b;
c(i,1)=2*a-b;
pixels(i,2)=2*b-a;
c(i,2)=2*b-a;
pixels(i,1)=bitset(pixels(i,1),1,1);
pixels(i,2)=bitset(pixels(i,1),1,wm(i));
wmnew(i)=wm(i);
else if (0<(2*pixels(i,1)-pixels(i,2)<=511)&& (bitget(pixels(i,1),1)==1)) && (0<(2*pixels(i,2)-pixels(i,1)<=511)&& (bitget(pixels(i,2),1)==1))
pixels(i,1)=bitset(pixels(i,1),1,0);
pixels(i,2)=bitset(pixels(i,1),1,wm(i));
wmnew(i)=wm(i);
else
pixels(i,1)=bitset(pixels(i,1),1,0);
wmnew(i)=bitget(pixels(i,2),1);
end
end
end
x3=pixels';
x4=x3(:);
x5=buffer(x4,512);
figure,imshow(x5)
title('embedded image');
impixelinfo
%1.grouping the pixel pairs
[rows,cols]=size(img);
y1=x5(:);
y2=buffer(y1,2);
expixels=y2';
for i=1:length(expixels)
if (bitget(expixels(i,1),1)==1)
extractedwm(i)=bitget(expixels(i,2),1);
expixels(i,1)=bitset(expixels(i,1),1,0);
expixels(i,2)=bitset(expixels(i,2),1,0);
expixels(i,1)=ceil(((2*expixels(i,1))+expixels(i,2))/3);
expixels(i,2)=ceil(((2*expixels(i,2))+expixels(i,1))/3);
else
if (bitget(expixels(i,1),1)==1) && (0<(2*expixels(i,1))-expixels(i,2)<+ 511 && 0<(2*expixels(i,2))-expixels(i,1) <=511)
expixels(i,1)=bitset(expixels(i,1),1,1);
expixels(i,2)=bitset(expixels(i,2),1,1);
else
expixels(i,1)=bitset(expixels(i,1),1,wmnew(i));
end
end
end
y3=expixels';
y4=y3(:);
y5=buffer(y4,512);
figure,imshow(y5)
title('extracted image');
impixelinfo
댓글 수: 2
Sivakumaran Chandrasekaran
2016년 1월 12일
you are not getting extraction part or embedded part? please mail us to siva@photontech.net . we will assist you
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Neuroimaging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!