forked from b3dk7/StegExpose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimarySets.java
More file actions
107 lines (90 loc) · 2.35 KB
/
PrimarySets.java
File metadata and controls
107 lines (90 loc) · 2.35 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* On Steganalysis of Random LSB Embedding in Continuous-tone Images
*
* source: http://code.google.com/p/simple-steganalysis-suite/
* author: Bastien Faure
*/
import java.awt.Color;
import java.awt.image.BufferedImage;
public class PrimarySets {
private BufferedImage image;
private double result;
public PrimarySets(BufferedImage image)
{
this.image = image;
}
public void run()
{
int width = image.getWidth();
int height = image.getHeight();
int red, green, blue;
int red2, green2, blue2;
int P=0, X=0, Y=0, V=0, W=0, Z=0;
double a, b, c, delta, p1, p2;
for(int j=0; j<height; j++)
{
for(int i=0; i<width; i+=2)
{
if( (i+1) < width)
{
red = new Color(image.getRGB(i,j)).getRed();
/*green = new Color(image.getRGB(i,j)).getGreen();
blue = new Color(image.getRGB(i,j)).getBlue();*/
red2 = new Color(image.getRGB(i+1,j)).getRed();
/*green2 = new Color(image.getRGB(i+1,j)).getGreen();
blue2 = new Color(image.getRGB(i+1,j)).getBlue();*/
P++;
// (v is even and u < v) or (v is odd and u > v)
if((((red2&0x01) == 0) && (red < red2) ) || ( ((red2&0x01) == 1) && (red > red2)))
{
X++;
}
// (v is even and u > v) or (v is odd and u < v)
else if((((red2&0x01) == 0) && (red > red2) ) || ( ((red2&0x01) == 1) && (red < red2)))
{
Y++;
// (u even and v odd) or (u odd and v even)
if((((red&0x01) == 0) && ((red2&0x01) == 1)) || (((red&0x01) == 1) && ((red2&0x0) == 0)))
{
W++;
}
else
{
V++;
}
}
else if(red == red2)
{
Z++;
}
}
}
}
/*System.out.println("--> Y = V + W = "+Y);
System.out.println("--> V = "+V);
System.out.println("--> W = "+W);
System.out.println("--> V + W = "+(V+W));
System.out.println("X = "+X);
System.out.println("Z = "+Z);
System.out.println("P = X + Y + Z = "+P);
System.out.println("--> X + Y + Z = "+(X+Y+Z));*/
a = 0.5*(W+Z);
b = (2*X)-P;
c = Y-X;
delta = Math.pow(b, 2)-(4*a*c);
p1 = (-b+Math.sqrt(delta))/(2*a);
p2 = (-b-Math.sqrt(delta))/(2*a);
if(p1 < p2)
{
result = p1;
}
else
{
result = p2;
}
}
public double getResult()
{
return result;
}
}