-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2fe7ed5
Showing
33 changed files
with
506 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function [xMin, xMax, imageBitmap] = DDBTC_Encode(inputImage, blockSizeX, blockSizeY, classMatrix, diffusedMatrix); | ||
inputImage = double(inputImage); | ||
[row, col] = size(inputImage); | ||
|
||
numberOfBlockX = row / blockSizeX; | ||
numberOfBlockY = col / blockSizeY; | ||
|
||
inputImage = mat2cell(inputImage, blockSizeX*ones(1, numberOfBlockX), blockSizeY*ones(1, numberOfBlockY)); | ||
imageBitmap = zeros(row, col); | ||
imageBitmap = mat2cell(imageBitmap, blockSizeX*ones(1, numberOfBlockX), blockSizeY*ones(1, numberOfBlockY)); | ||
xMin = zeros(numberOfBlockX, numberOfBlockY); | ||
xMax = zeros(numberOfBlockX, numberOfBlockY); | ||
|
||
for i=1: numberOfBlockX | ||
for j=1: numberOfBlockY | ||
pixel = inputImage{i, j}; | ||
[xMin(i, j), xMax(i, j), imageBitmap{i, j}] = PerformErrorDiffusionHalftoning(pixel, classMatrix, diffusedMatrix); | ||
end; | ||
end; | ||
|
||
imageBitmap = cell2mat(imageBitmap); | ||
|
||
|
||
function [xMin, xMax, imageBitmap] = PerformErrorDiffusionHalftoning(pixel, classMatrix, diffusedMatrix); | ||
[row, col] = size(pixel); | ||
[classMatrixSizeX, classMatrixSizeY] = size(classMatrix); | ||
|
||
xMin = min(pixel(:)); | ||
xMax = max(pixel(:)); | ||
xMean = mean(pixel(:)); | ||
|
||
r = 1; | ||
x = padarray(pixel, [r r], 'symmetric'); | ||
paddedClassMatrix = padarray(classMatrix, [r r], 'symmetric'); | ||
|
||
imageBitmap = zeros(row, col); | ||
|
||
for processingOrder = 0: classMatrixSizeX*classMatrixSizeY-1 | ||
[positionOrderX, positionOrderY] = find(classMatrix == processingOrder); | ||
|
||
if x(positionOrderX+r, positionOrderY+r) < xMean | ||
imageBitmap(positionOrderX, positionOrderY) = 0; | ||
o = xMin; | ||
else | ||
imageBitmap(positionOrderX, positionOrderY) = 1; | ||
o = xMax; | ||
end; | ||
|
||
e = x(positionOrderX+r, positionOrderY+r) - o; | ||
unProcessedPixel = (paddedClassMatrix(positionOrderX+r-r: positionOrderX+r+r, positionOrderY+r-r: positionOrderY+r+r) >= processingOrder); | ||
x(positionOrderX+r-r: positionOrderX+r+r, positionOrderY+r-r: positionOrderY+r+r) = x(positionOrderX+r-r: positionOrderX+r+r, positionOrderY+r-r: positionOrderY+r+r) + e*(unProcessedPixel.*diffusedMatrix)/sum(sum(unProcessedPixel.*diffusedMatrix)); | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
function [H]=DDbtc1(in,met,bs) | ||
%in–> input image, bs-block size(2,4,..) | ||
in=im2double(in); | ||
[s1 s2]=size(in); | ||
inpad=padarray(in,[1,1],'both'); | ||
% inpad_hist=0; | ||
|
||
if(met==1) | ||
|
||
CM = [47 31 51 24 27 45 5 21; | ||
37 63 53 11 22 4 1 33; | ||
61 0 57 16 26 29 46 8; | ||
20 14 9 62 18 41 38 6; | ||
17 13 25 15 55 48 52 58; | ||
3 7 2 32 30 34 56 60; | ||
28 40 36 39 49 43 35 10; | ||
54 23 50 12 42 59 44 19;]; %Messe-Vaidhya | ||
kr=8;nn=63; | ||
elseif(met==2) | ||
|
||
CM= [34 48 40 32 29 15 23 31; | ||
42 58 56 53 21 5 7 10; | ||
50 62 61 45 13 1 2 18; | ||
38 46 54 37 25 17 9 26; | ||
28 14 22 30 35 49 41 33; | ||
20 4 6 11 43 59 57 52; | ||
12 0 3 19 51 63 60 44; | ||
24 16 8 27 39 47 55 36;]; %Knuth | ||
kr=8;nn=63; | ||
else | ||
|
||
CM= [207 0 13 17 28 55 18 102 81 97 74 144 149 169 170 172; | ||
3 6 23 36 56 50 65 87 145 130 137 158 182 184 195 221; | ||
7 14 24 37 67 69 86 5 106 152 150 165 183 192 224 1; | ||
15 26 43 53 51 101 115 131 139 136 166 119 208 223 226 4; | ||
22 39 52 71 84 103 164 135 157 173 113 190 222 225 227 16; | ||
40 85 72 83 104 117 167 133 168 180 200 219 231 228 12 21; | ||
47 120 54 105 123 132 146 176 179 202 220 230 245 2 20 41; | ||
76 73 127 109 138 134 178 181 206 196 229 244 246 19 42 49; | ||
80 99 112 147 142 171 177 203 218 232 243 248 247 33 48 68; | ||
108 107 140 143 185 163 204 217 233 242 249 255 44 45 70 79; | ||
110 141 88 75 175 205 214 234 241 250 254 38 46 77 116 100; | ||
111 148 160 174 201 215 235 240 251 252 253 61 62 93 94 125; | ||
151 159 189 199 197 216 236 239 25 31 60 82 92 95 124 114; | ||
156 188 191 209 213 237 238 29 32 59 64 91 118 78 128 155; | ||
187 194 198 212 9 10 30 35 58 63 90 96 122 129 154 161; | ||
193 210 211 8 11 27 34 57 66 89 98 121 126 153 162 186]; | ||
kr=16;nn=255; | ||
|
||
end | ||
|
||
CM=repmat(CM,round(bs/kr),round(bs/kr)); | ||
|
||
%Diffusion Matrix | ||
|
||
DM=[1 2 1; | ||
2 0 2; | ||
1 2 1;]/12; | ||
|
||
% CM1=zeros(s1+2,s2+2)-1; | ||
% CM1(2:s1+1,2:s1+1)=CM; | ||
% CM=CM1; | ||
CM=padarray(CM,[1 1],-1,'both'); | ||
H=zeros(s1,s2); | ||
|
||
for i=1:bs:s1 | ||
for j=1:bs:s2 | ||
block=in(i:i+bs-1,j:j+bs-1); | ||
mn=mean(block(:)); | ||
a=max(block(:)); | ||
b=min(block(:)); | ||
% i1=1; j1=1; | ||
for ii=0:1:nn | ||
[p1,p2]=(find(CM==ii)); | ||
y=1; | ||
x=1; | ||
while y<=size(p1,1) | ||
while x<=size(p2,1) | ||
inpix=inpad(i-1+p1(y),j-1+p2(x)); | ||
if inpix>=mn | ||
out=a; | ||
else | ||
out=b; | ||
end | ||
H(i-1+p1(y),j-1+p2(x)) = out; | ||
qerr=inpix-out; | ||
cl=CM(p1(y)-1:p1(y)+1,p2(x)-1:p2(x)+1); | ||
k=cl>ii; | ||
DM1=(DM.*k); | ||
DM1=DM/sum(DM1(:)); | ||
err=DM1*qerr; | ||
|
||
inpad(p1(y)-1:p1(y)+1,p2(x)-1:p2(x)+1)= inpad(p1(y)-1:p1(y)+1,p2(x)-1:p2(x)+1)+err; | ||
|
||
y=y+1; | ||
x=x+1; | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
H=H(2:(s1+1),2:(s2+1)); | ||
|
||
% in1=imgaussfilt(in,1.3); | ||
% H1=imgaussfilt(H,1.3); | ||
% | ||
% fprintf('\n'); | ||
% [peaksnr, snr] = psnr(in1, H1); | ||
% fprintf('\n The H-Peak-SNR-1 value is %0.4f. \n', peaksnr); | ||
% [peaksnr, snr] = psnr(in, H); | ||
% fprintf('\n The Peak-SNR value is %0.4f. \n', peaksnr); | ||
% imshow(in),figure,imshow(H),figure,imshow(H1); | ||
|
||
% imwrite(H,'lena_DDbtc_64.jpg'); | ||
|
||
in=im2uint8(in); | ||
H=im2uint8(H); | ||
hp=HPSNRnew(in,H,bs,1.3); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function [out]=EDbtc(in,bs) | ||
%in–> input image, bs-block size(2,4,..) | ||
in=im2double(in); | ||
fc=[0 -99*16 7; 3 5 1]/16; | ||
|
||
[ri,ci]=size(in); | ||
[rm,cm]=size(fc); | ||
[r0,c0]=find(fc==-99); % find origin of error filter | ||
fc(r0,c0)=0; | ||
|
||
rm=rm-1; cm=cm-1; | ||
inpad=padarray(in,[0 1],'both'); | ||
inpad=padarray(inpad,[1],'post'); | ||
out=zeros(ri,ci); qn=out; | ||
|
||
for i=r0:bs:ri+(r0-1) | ||
for j=c0:bs:ci+(c0-1) | ||
i1=i-(r0-1); | ||
j1=j-(c0-1); | ||
block=in(i1:i1+bs-1,j1:j1+bs-1); | ||
mn=mean(block(:)); | ||
a=max(block(:)); | ||
b=min(block(:)); | ||
|
||
for y=i:i+bs-1 | ||
for x=j:j+bs-1 | ||
y1=y-(r0-1); | ||
x1=x-(c0-1); | ||
|
||
if inpad(y,x)>=mn | ||
outpix=a; | ||
else | ||
outpix=b; | ||
end | ||
out(y1,x1)=outpix; | ||
qerr=inpad(y,x)-outpix; | ||
qn(y1,x1)=qerr; | ||
qerr=qerr.*fc; | ||
bl_inpad=inpad(y1:y1+rm,x1:x1+cm); | ||
bl_inpad=bl_inpad+qerr; | ||
inpad(y1:y1+rm,x1:x1+cm)=bl_inpad; | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
% in1=imgaussfilt(in,1.3); | ||
% out1=imgaussfilt(out,1.3); | ||
% | ||
% fprintf('\n'); | ||
% [peaksnr, snr] = psnr(in, out); | ||
% fprintf('\n The Peak-SNR value is %0.4f. \n', peaksnr); | ||
% [peaksnr, snr] = psnr(in1, out1); | ||
% fprintf('\n The H-Peak-SNR value is %0.4f. \n', peaksnr); | ||
% imshow(in),figure,imshow(out),figure,imshow(out1); | ||
|
||
% imwrite(out,'lena_EDbtc_64.jpg'); | ||
|
||
in=im2uint8(in); | ||
out=im2uint8(out); | ||
hp=HPSNRnew(in,out,bs,1.3); | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
%Function to compute HPSNR | ||
|
||
function hp=HPSNRnew(in,in1,fs,d) | ||
%fs==> Block Size | ||
%d==> standard deviation | ||
|
||
[s1 s2]=size(in); | ||
in=double(in); | ||
in1=double(in1); | ||
|
||
b1=mod(s1,fs); | ||
b2=mod(s2,fs); | ||
bs=fs-1; | ||
in=padarray(in,[b1 b2]); | ||
in1=padarray(in1,[b1 b2]); | ||
|
||
%Gaussian Filter | ||
gaulen=(fs-1)/2; | ||
for k=-gaulen:gaulen | ||
for l=-gaulen:gaulen | ||
c=(k*k + l*l)/(2*d*d); | ||
GF(k+gaulen+1,l+gaulen+1)=exp(-c)/(2*3.14*d*d); | ||
end | ||
end | ||
SErr=0; | ||
for i=1:fs:s1-1 | ||
for j=1:fs:s2-1 | ||
ima=in(i:i+bs,j:j+bs); | ||
imr=in1(i:i+bs,j:j+bs) ; | ||
Err=ima-imr; | ||
Err=conv2(Err,GF,'same').^2; | ||
SErr=SErr+sum(sum(Err)); | ||
end | ||
end | ||
hp=10*log10(((s1)*(s2)*255.^2)/SErr); | ||
fprintf('\n The H-Peak-SNR value is %0.4f. \n', hp); | ||
end | ||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
function [H]=ODbtc(in,bs) | ||
%in–> input image, bs-block size(2,4,..) | ||
in=im2double(in); | ||
[s1 s2]=size(in); | ||
|
||
|
||
%Ordered Dithering - Halftoning | ||
od=[1 17 5 21 2 18 6 22; | ||
25 9 29 13 26 10 30 14; | ||
7 23 3 19 8 24 4 20; | ||
31 15 27 11 32 16 28 12; | ||
2 18 6 22 1 17 5 21; | ||
26 10 30 14 25 9 29 13; | ||
8 24 4 20 7 23 3 19; | ||
32 16 28 12 31 15 27 11]/32; | ||
|
||
for a=1:8 | ||
for b=1:8 | ||
od_temp=(od(a,b)-min(od(:)))/(max(od(:))-min(od(:))); | ||
od_new(a,b)=od_temp; | ||
end | ||
end | ||
|
||
od_new=repmat(od_new,round(s1/8),round(s2/8)); | ||
|
||
%BTC | ||
for i=1:bs:s1 | ||
for j=1:bs:s2 | ||
bl=in(i:i+(bs-1),j:j+(bs-1)); | ||
|
||
a=max(bl(:)); | ||
b=min(bl(:)); | ||
|
||
k=(a-b); | ||
|
||
for m=i:1:i+bs-1 | ||
for n=j:1:j+bs-1 | ||
DA = k*od_new(m,n); | ||
th = DA + b; | ||
c=in(m,n)>th; | ||
out=((c).*a+((~c)).*b); | ||
H(m,n)=out; | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
% in1=imgaussfilt(in,1.3); | ||
% H1=imgaussfilt(H,1.3); | ||
|
||
% [peaksnr, snr] = psnr(in, H); | ||
% fprintf('\n The Peak-SNR value is %0.4f. \n', peaksnr); | ||
% [peaksnr, snr] = psnr(in1, H1); | ||
% fprintf('\n The H-Peak-SNR value is %0.4f. \n', peaksnr); | ||
% imshow(in),figure,imshow(H); | ||
|
||
% imwrite(H,'lena_ODbtc_64.jpg'); | ||
|
||
in=im2uint8(in); | ||
H=im2uint8(H); | ||
hp=HPSNRnew(in,H,bs,1.3); | ||
end |
Binary file not shown.
Binary file added
BIN
+329 KB
Paper/Hiding Data in Ordered Dithering Halftone Images by Bit Interleaving.pdf
Binary file not shown.
Binary file added
BIN
+3.66 MB
...her block truncation coding with dither array LUT and its scalable coding application.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.36 MB
Paper/Improved Block Truncation Coding Using Optimized Dot Diffusion.pdf
Binary file not shown.
Binary file added
BIN
+196 KB
Paper/Improved block truncation coding using modified error diffusion.pdf
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function [H]=ambtc(in,bs) | ||
%in–> input image; bs–> blocksize | ||
|
||
in=rgb2gray(in); | ||
in=im2double(in); | ||
[s1 s2]=size(in); | ||
n=bs*bs; | ||
for i=1:bs:s1 | ||
for j=1:bs:s2 | ||
bl=in(i:i+(bs-1),j:j+(bs-1)); | ||
mn=mean(mean(bl)) ; %Computing Mean | ||
fm=mean(mean(abs(bl-mn))) ; %Abs moment | ||
g=(n*fm)/2; | ||
c=bl>mn; | ||
q=nnz(c); | ||
if(q==n) | ||
b=mn; | ||
a=0; | ||
else | ||
b=mn+(g/q); | ||
a=mn-(g/(n-q)); | ||
end | ||
out=round(c.*b+(~c).*a); | ||
H(i:i+(bs-1),j:j+(bs-1))=out; | ||
end | ||
end | ||
imshow(H); | ||
end |
Oops, something went wrong.