-
Notifications
You must be signed in to change notification settings - Fork 0
/
gabor_filter.java~
145 lines (110 loc) · 4.48 KB
/
gabor_filter.java~
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BandCombineOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ByteLookupTable;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.awt.image.LookupOp;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import java.io.*;
import java.applet.*;
import java.awt.*;
import javax.imageio.*;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.Graphics;
import java.util.Arrays;
import java.lang.Object;
import java.lang.Math;
import java.lang.*;
import java.lang.reflect.Array;
import java.util.Calendar;
public class gabor_filter {
public static void main(String[] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("1.bmp"));
int width = img.getWidth(null);
int height = img.getHeight(null);
sharpen_image shar = new sharpen_image();
int[][] array = new int[height+100][width+100];
int[][] filter_arr = new int[height+100][width+100];
int[][] norm_arr = new int[height+100][width+100];
int[][] sharp_arr = new int[height+100][width+100];
int[][] clear_arr = new int[height+100][width+100];
int[][] foreground_arr = new int[height+100][width+100];
/*long process = System.currentTimeMillis();
BufferedImage clear = shar.Clear(img);
long endtime = System.currentTimeMillis();
File outputfile0 = new File("cleared.bmp");
ImageIO.write(clear, "bmp", outputfile0);
System.out.println("runtime:filter "+(endtime-process));*/
est gf =new est();
array = shar.img_arr(img);
long process = System.currentTimeMillis();
// norm_arr=shar.Normalize(array,width,height);
// BufferedImage normalized = shar.arr_img(norm_arr,width,height);
// File outputfile2 = new File("normalized.bmp");
// ImageIO.write(normalized, "bmp", outputfile2);
/* foreground_arr=shar.check_foreground(norm_arr,13,width,height);
BufferedImage foreground = shar.arr_img(foreground_arr,width,height);
File outputfile7 = new File("foreground.bmp");
ImageIO.write(foreground, "bmp", outputfile7);*/
clear_arr = shar.Clear(array,17,width,height);
// BufferedImage clear = shar.arr_img(clear_arr,width,height);
// File outputfile4 = new File("clear.bmp");
// ImageIO.write(clear, "bmp", outputfile4);
/* sharp_arr=shar.processImage(norm_arr,width,height);
BufferedImage sharp_norm = shar.arr_img(sharp_arr,width,height);
File outputfile3 = new File("norm&sharp.bmp");
ImageIO.write(sharp_norm, "bmp", outputfile3);*/
filter_arr = gf.orientation(clear_arr,width,height,17,7);
long endtime = System.currentTimeMillis();
System.out.println("runtime:filter "+(endtime-process));
BufferedImage filtered1 = shar.arr_img(filter_arr,width,height);
File outputfile1 = new File("Gabor_output.bmp");
ImageIO.write(filtered1, "bmp", outputfile1);
/*BufferedImage sharpen11 = shar.binarizing(filtered);
//BufferedImage sharpen1 = shar.inverseimage(sharpen11);
File outputfile2 = new File("gabor_binar.bmp");
ImageIO.write(sharpen11, "bmp", outputfile2);
BufferedImage sharpen2 = shar.binarizing(img);
File outputfile3 = new File("only_binar.bmp");
ImageIO.write(sharpen2, "bmp", outputfile3);*/
//BufferedImage fil_sharp = shar.processImage(filtered);
//File outputfile1 = new File("filtered.bmp");
//ImageIO.write(filtered, "bmp", outputfile1);
/*sharpen_new shar = new sharpen_new();
process = System.currentTimeMillis();
BufferedImage binarized = shar.binarizing(shar.sharpen(img,1));
//BufferedImage sharpened = shar.processImage(binarized);
//endtime = System.currentTimeMillis();
//BufferedImage binarized_after = shar.binarizing(sharpened);
//System.out.println("runtime :sharpen_net "+(endtime-process));
File outputfile1 = new File("binarized.bmp");
ImageIO.write(binarized, "bmp", outputfile1);*/
//File outputfile2 = new File("binarized_after.bmp");
//ImageIO.write(binarized_after, "bmp", outputfile2);
}catch (IOException e) {}
}
}