Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/criptografia/pruebas/PruebaImagenes.class
Binary file not shown.
Binary file added images/Cripto.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/prueba3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 57 additions & 11 deletions src/criptografia/pruebas/PruebaImagenes.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,76 @@
public class PruebaImagenes {

public static void main(final String[] args) {
ImagePlus imgPlus = new ImagePlus("images/paisaje.jpg");
ImagePlus imgPlus = new ImagePlus("images/Cripto.jpg");
ImageProcessor imgProcessor = imgPlus.getProcessor();
imgProcessor.set(20, 30, 255);

int[] rgb = new int[3];
imgProcessor.getPixel(20, 30, rgb);
imgProcessor.getPixel(1, 0, rgb);
SearchInterestRegion search = new SearchInterestRegion();
search.setup(imgProcessor, 90, 5);
System.out.println("R:" + rgb[0] + " G:" + rgb[1] + " B:" + rgb[2] + " Total:" + imgProcessor.getPixel(20, 30));
ImagePlus imgPlus2 = new ImagePlus("images/Cripto.jpg");
ImageProcessor imgProcessor2 = imgPlus2.getProcessor();
search.setup(imgProcessor2, 90, 5);
System.out.println("R:" + rgb[0] + " G:" + rgb[1] + " B:" + rgb[2]);
System.out.println("HEIGTH:" + imgProcessor.getHeight() + " WIDTH:" + imgProcessor.getWidth());

Collection<DataDivision> datas = search.run();
for (DataDivision data : datas) {
System.out.println("left:" + data.getLeft() + " top:" + data.getTop() + " height:" + data.getHeight() + " width:" + data.getWidth() + " ROI:" + data.getROI().toString());
//for (DataDivision data : datas) {
//System.out.println("left:" + data.getLeft() + " top:" + data.getTop() + " height:" + data.getHeight() + " width:" + data.getWidth() + " ROI:" + data.getROI().toString());
//}
for (int i = 0; i <= 5 - 1; i++) {
for (int j = 0; j <= 5 - 1; j++) {
int[] rgb2 = new int[3];
imgProcessor.getPixel(i, j, rgb2);
System.out.print(rgb2[0] + " ");
}
System.out.println(" ");
}
System.out.println("--------------------------------");
for (int i = 0; i <= 5 - 1; i++) {
for (int j = 0; j <= 5 - 1; j++) {
int[] rgb2 = new int[3];
imgProcessor.getPixel(i, j, rgb2);
System.out.print(rgb2[1] + " ");
}
System.out.println(" ");
}
System.out.println("--------------------------------");
for (int i = 0; i <= 5 - 1; i++) {
for (int j = 0; j <= 5 - 1; j++) {
int[] rgb2 = new int[3];
imgProcessor.getPixel(i, j, rgb2);
System.out.print(rgb2[2] + " ");
}
System.out.println(" ");
}
System.out.println("------------------------------");
OmegaGenerator omega = new OmegaGenerator();
omega.setup(datas.stream().findFirst().get(), 7, 8, 2, 2, new int[] {
0, 1, 1, 1
omega.setup(datas.stream().findFirst().get(), 7, 8, 2, 2, new double[] {
0.2, 0.7, 1, 0.3
});
OmegaGenerator psi = new OmegaGenerator();
psi.setup(datas.stream().findFirst().get(), 6, 1, 5, 2, new double[] {
0.4, 0.8, 0.1, 0.9
});
omega.run();
int[][] sal = omega.run();
int[][] sal2 = psi.run();
System.out.println("-----------OMEGA--------------");
for (int i = 0; i <= sal.length - 1; i++) {
for (int j = 0; j <= sal[0].length - 1; j++) {
System.out.print(sal[i][j] + " ");
}
System.out.println(" ");
}
System.out.println("-----------PSI--------------");
for (int i = 0; i <= sal2.length - 1; i++) {
for (int j = 0; j <= sal2[0].length - 1; j++) {
System.out.print(sal2[i][j] + " ");
}
System.out.println(" ");
}
ImagePlus imp2 = new ImagePlus("ALM", search.imgProcessor);
FileSaver fs = new FileSaver(imp2);
fs.saveAsJpeg("images/prueba3.jpg");
System.out.println("HEIGTH:" + imgProcessor.getHeight() + " WIDTH:" + imgProcessor.getWidth());

}

Expand Down
13 changes: 7 additions & 6 deletions src/criptografia/utiles/OmegaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class OmegaGenerator {
public int b;
public int c;
public int d;
public int[] X;
public double[] X;
private Integer L;
private int F;
private int[][] matrixA;
Expand All @@ -20,7 +20,7 @@ public class OmegaGenerator {
};


public void setup(final DataDivision data, final int a, final int b, final int c, final int d, final int[] x) {
public void setup(final DataDivision data, final int a, final int b, final int c, final int d, final double[] x) {
this.a = a;
this.b = b;
this.c = c;
Expand Down Expand Up @@ -57,10 +57,11 @@ private int[][] calculateA() {
public int[][] run() {
int i = (int) Math.ceil(this.L / 16.0);
int[][] result = new int[this.data.getHeight()][this.data.getWidth()];
int[] Y = new int[i * 4];
double[] Y = new double[i * 4];
String[] Z = new String[i * 4];
for (int j = 1; j <= i; j++) {
int t = this.X[0] * this.U[0] + this.X[1] * this.U[1] + this.X[2] * this.U[2] + this.X[3] * this.U[3];
double t = this.X[0] * this.U[0] + this.X[1] * this.U[1] + this.X[2] * this.U[2] + this.X[3] * this.U[3];
t = Math.floor(t) + 1;
for (int b = 1; b <= t; b++) {
this.X = this.multiplicaAX();
}
Expand Down Expand Up @@ -103,8 +104,8 @@ private int[][] asignaSecuencia(final String secuenciaBinaria) {
return result;
}

private int[] multiplicaAX() {
int[] result = new int[4];
private double[] multiplicaAX() {
double[] result = new double[4];
for (int w = 0; w <= 3; w++) {
for (int p = 0; p <= 3; p++) {
result[w] = (result[w] + this.matrixA[w][p] * this.X[p]) % 2;
Expand Down