質問編集履歴

4

修正

2018/01/19 06:29

投稿

mashumaro0628
mashumaro0628

スコア19

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,13 @@
16
16
 
17
17
  ```
18
18
 
19
+ Exception in thread "main" javax.imageio.IIOException: Can't read input file!
20
+
19
- ![イメージ説明](7e63fb0a4bb18a7103c5b56ae5d73581.png)
21
+ at javax.imageio.ImageIO.read(ImageIO.java:1301)
22
+
23
+ at Test.main(Test.java:9)
24
+
25
+
20
26
 
21
27
  ```
22
28
 

3

修正

2018/01/19 06:29

投稿

mashumaro0628
mashumaro0628

スコア19

test CHANGED
File without changes
test CHANGED
@@ -16,39 +16,29 @@
16
16
 
17
17
  ```
18
18
 
19
- ソッド r(int) は型 main で未定義です
19
+ ![イージ説明](7e63fb0a4bb18a7103c5b56ae5d73581.png)
20
20
 
21
21
  ```
22
22
 
23
23
 
24
24
 
25
- ###該当のソースコード1
25
+ ###該当のソース
26
26
 
27
- ```Java
28
-
29
- package OCR;
27
+ import static img.ImageUtility.*;
30
28
 
31
29
 
32
30
 
33
31
  import java.awt.image.BufferedImage;
34
32
 
35
- import java.io.File;
33
+ import java.io.*;
36
-
37
-
38
34
 
39
35
  import javax.imageio.ImageIO;
40
36
 
37
+ public class Test {
41
38
 
39
+ public static void main(String[] args) throws IOException {
42
40
 
43
- public class main {
44
-
45
-
46
-
47
- public static void main(String[] args) {
48
-
49
- // TODO 自動生成されたメソッド・スタブ
50
-
51
- File f = new File("test.jpg");
41
+ File f = new File("test.jpg");
52
42
 
53
43
  BufferedImage read=ImageIO.read(f);
54
44
 
@@ -86,58 +76,6 @@
86
76
 
87
77
  ImageIO.write(write, "jpg", f2);
88
78
 
89
-
90
-
91
- }
92
-
93
-
94
-
95
- }
96
-
97
- ```
98
-
99
- ###該当のソースコード2
100
-
101
- ```Java
102
-
103
- package OCR;
104
-
105
- public class ImageUtility {
106
-
107
- public static int a(int c){
108
-
109
- return c>>>24;
110
-
111
- }
112
-
113
- public static int r(int c){
114
-
115
- return c>>16&0xff;
116
-
117
- }
118
-
119
- public static int g(int c){
120
-
121
- return c>>8&0xff;
122
-
123
- }
124
-
125
- public static int b(int c){
126
-
127
- return c&0xff;
128
-
129
- }
130
-
131
- public static int rgb(int r,int g,int b){
132
-
133
- return 0xff000000 | r <<16 | g <<8 | b;
134
-
135
- }
136
-
137
- public static int argb(int a,int r,int g,int b){
138
-
139
- return a<<24 | r <<16 | g <<8 | b;
140
-
141
79
  }
142
80
 
143
81
  }

2

すみません。修正しました

2018/01/19 06:22

投稿

mashumaro0628
mashumaro0628

スコア19

test CHANGED
File without changes
test CHANGED
@@ -102,4 +102,42 @@
102
102
 
103
103
  package OCR;
104
104
 
105
+ public class ImageUtility {
106
+
107
+ public static int a(int c){
108
+
109
+ return c>>>24;
110
+
111
+ }
112
+
113
+ public static int r(int c){
114
+
115
+ return c>>16&0xff;
116
+
117
+ }
118
+
119
+ public static int g(int c){
120
+
121
+ return c>>8&0xff;
122
+
123
+ }
124
+
125
+ public static int b(int c){
126
+
127
+ return c&0xff;
128
+
129
+ }
130
+
131
+ public static int rgb(int r,int g,int b){
132
+
133
+ return 0xff000000 | r <<16 | g <<8 | b;
134
+
135
+ }
136
+
137
+ public static int argb(int a,int r,int g,int b){
138
+
105
- i.hatenablog.com/entry/20111012/1318436587
139
+ return a<<24 | r <<16 | g <<8 | b;
140
+
141
+ }
142
+
143
+ }

1

ソースコード修正、エラーコード追加

2018/01/19 04:14

投稿

mashumaro0628
mashumaro0628

スコア19

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  ```
18
18
 
19
- エラーメッセージ
19
+ ド r(int) は型 main で未定義です
20
20
 
21
21
  ```
22
22
 
@@ -102,84 +102,4 @@
102
102
 
103
103
  package OCR;
104
104
 
105
-
106
-
107
- import java.awt.image.BufferedImage;
108
-
109
- import java.io.File;
110
-
111
-
112
-
113
- import javax.imageio.ImageIO;
114
-
115
-
116
-
117
- public class main {
118
-
119
-
120
-
121
- public static void main(String[] args) {
122
-
123
- // TODO 自動生成されたメソッド・スタブ
124
-
125
- File f = new File("test.jpg");
126
-
127
- BufferedImage read=ImageIO.read(f);
128
-
129
- int w = read.getWidth(),h=read.getHeight();
130
-
131
- BufferedImage write =
132
-
133
- new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
134
-
135
-
136
-
137
- for(int y=0;y<h;y++){
138
-
139
- for(int x=0;x<w;x++){
140
-
141
- int c = read.getRGB(x, y);
142
-
143
- int r = 255-r(c);
144
-
145
- int g = 255-g(c);
146
-
147
- int b = 255-b(c);
148
-
149
- int rgb = rgb(r,g,b);
150
-
151
- write.setRGB(x,y,rgb);
152
-
153
- }
154
-
155
- }
156
-
157
-
158
-
159
- File f2 = new File("ret.jpg");
160
-
161
- ImageIO.write(write, "jpg", f2);
162
-
163
-
164
-
165
- }
166
-
167
-
168
-
169
- }
170
-
171
- ```
172
-
173
-
174
-
175
- ###試したこと
176
-
177
- ソース1とソース2は同じパッケージに入れています。
178
-
179
-
180
-
181
- ###補足情報(言語/FW/ツール等のバージョンなど)
182
-
183
- ソースは以下のものを参考にしています。
184
-
185
- http://nodamushi.hatenablog.com/entry/20111012/1318436587
105
+ i.hatenablog.com/entry/20111012/1318436587