Skip to content

Commit

Permalink
Clase ImageManagement organizada
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoOquendo committed Aug 2, 2018
1 parent 398c732 commit b7f3233
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
Binary file removed Imagenes/At_100x100_iconjake.jpg
Binary file not shown.
Binary file added Imagenes/RB 2018-08-01 15.09.49.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 bin/ImageManagement.class
Binary file not shown.
57 changes: 13 additions & 44 deletions src/ImageManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import java.util.LinkedList;
import java.util.Queue;
import javax.imageio.ImageIO;

public class ImageManagement {

private static Color myWhite = Color.WHITE;
private static Color myBlack = Color.WHITE;

public static BufferedImage makeImage(int[] pixels, int w, int h) {
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY);
Expand Down Expand Up @@ -81,25 +85,16 @@ public static boolean imageToArf(BufferedImage[] list, char[] labels) {
}

public static void getDivitions(BufferedImage a) throws IOException {


Color myWhite=Color.WHITE;
Color myBlack=Color.BLACK;
Color myRed=Color.RED;
int rgbBlanco=myWhite.getRGB();
int rgbNegro=myBlack.getRGB();
int rgbRojo=myRed.getRGB();
Queue<Integer>dH=new LinkedList<Integer>();
Queue<Integer>dV=new LinkedList<Integer>();
boolean x=true;
for(int i=0; i<a.getHeight();i++) {
boolean y=x;
if(x) {
for(int j=0;j<a.getWidth();j++) {
if(a.getRGB(j, i)==rgbNegro) {
if(a.getRGB(j, i)==myBlack.getRGB()) {
x=!x;
j=a.getHeight();

}
}
if(x!=y) {
Expand All @@ -108,21 +103,16 @@ public static void getDivitions(BufferedImage a) throws IOException {
}else {
x=!x;
for(int j=0;j<a.getWidth();j++) {
if(a.getRGB(j, i)==rgbNegro) {
if(a.getRGB(j, i)==myBlack.getRGB()) {
x=!x;
j=a.getHeight();

}
}
if(x!=y) {
dH.add(i+2);
}
}



}

BufferedImage l[]=new BufferedImage[dH.size()/2];
int cont=0;
for(int i=0;i<l.length;i++) {
Expand All @@ -132,10 +122,9 @@ public static void getDivitions(BufferedImage a) throws IOException {
boolean y=x;
if(x) {
for(int j=0;j<l[i].getHeight();j++) {
if(l[i].getRGB(k, j)==rgbNegro) {
if(l[i].getRGB(k, j)==myBlack.getRGB()) {
x=!x;
j=a.getHeight();

}
}
if(x!=y) {
Expand All @@ -144,10 +133,9 @@ public static void getDivitions(BufferedImage a) throws IOException {
}else {
x=!x;
for(int j=0;j<l[i].getHeight();j++) {
if(l[i].getRGB(k, j)==rgbNegro) {
if(l[i].getRGB(k, j)==myBlack.getRGB()) {
x=!x;
j=a.getHeight();

}
}
if(x!=y) {
Expand All @@ -157,17 +145,13 @@ public static void getDivitions(BufferedImage a) throws IOException {
}
while(!dV.isEmpty()) {
BufferedImage aux=l[i].getSubimage(dV.peek(), 0, -dV.poll()+dV.poll(), l[i].getHeight());
ImageIO.write(redimencion(aux,32), "png", new File ("C:/Users/pgmpa/eclipse-workspace/Proyecto3/data/Imagenes/c/output"+cont+".png"));
ImageIO.write(redimention(aux,32), "png", new File ("C:/Users/pgmpa/eclipse-workspace/Proyecto3/data/Imagenes/c/output"+cont+".png"));
cont++;
}


}
}

}


public static BufferedImage redimencion(BufferedImage a, int n) {

public static BufferedImage redimention(BufferedImage a, int n) {
BufferedImage temp=new BufferedImage(n, n, BufferedImage.TYPE_BYTE_BINARY);
boolean v=true;
boolean h=true;
Expand All @@ -177,8 +161,6 @@ public static BufferedImage redimencion(BufferedImage a, int n) {
temp.setRGB(i, j, Color.WHITE.getRGB());
}
}


if(a.getWidth()<=n) {
V1=(n-a.getWidth())/2;
}else {
Expand Down Expand Up @@ -219,7 +201,6 @@ public static BufferedImage redimencion(BufferedImage a, int n) {
}
h=false;
}

if(v&&h) {
for(int i=V1;i<a.getWidth()+V1;i++) {
for(int j=H1;j<a.getHeight()+H1;j++) {
Expand All @@ -245,15 +226,9 @@ public static BufferedImage redimencion(BufferedImage a, int n) {
}
}
}




return temp;

}


public static int count(BufferedImage a, int p, boolean f) {
int ans=0;
if(f) {
Expand All @@ -272,12 +247,6 @@ public static int count(BufferedImage a, int p, boolean f) {
return ans;
}







public static void main(String[] args) throws IOException {
//Main de Binarize
File inputfile=new File("path");
Expand Down

0 comments on commit b7f3233

Please sign in to comment.