質問編集履歴
3
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,10 +4,12 @@
|
|
4
4
|
どのサイズの画像でも、面積平均法を使って、縦横を半分のサイズにしたいです。
|
5
5
|
|
6
6
|
このような感じです。
|
7
|
+
画像1
|
7
8
|

|
8
9
|
|
9
10
|
|
10
11
|
しかし、平均する方法がわかりません。以下のような方法で実行しようとしましたが、ここから先どうしたらいいかわかりません。もしかしたらそもそもこの方法が間違っているのだと思います。
|
12
|
+
画像2
|
11
13
|

|
12
14
|
|
13
15
|
```
|
2
説明の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,15 +17,16 @@
|
|
17
17
|
Picture newpic=new Picture(picture.getWidth()/2, picture.getHeight()/2);
|
18
18
|
for (int c = 0; c < w; c++) {
|
19
19
|
for (int r = 0; r < h; r++) {
|
20
|
-
//
|
20
|
+
//元の画像から以下をコピーする
|
21
21
|
Pixel p1= picture.getPixel(r, c);
|
22
22
|
Pixel p2= picture.getPixel(r+1, c);
|
23
23
|
Pixel p3= picture.getPixel(r, c+1);
|
24
24
|
Pixel p4= picture.getPixel(r+1, c+1);
|
25
25
|
|
26
|
-
int total=//
|
26
|
+
int total=// piからp4までを足す
|
27
|
-
int average= //
|
27
|
+
int average= // それを4でわり平均を出す
|
28
28
|
|
29
|
+
// コピーしたものをaverageに置き換える
|
29
30
|
newpic.setPixel(r,c,average);
|
30
31
|
|
31
32
|
}
|
1
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|

|
12
12
|
|
13
13
|
```
|
14
|
-
|
14
|
+
|
15
15
|
int w = picture.getWidth();
|
16
16
|
int h = picture.getHeight();
|
17
17
|
Picture newpic=new Picture(picture.getWidth()/2, picture.getHeight()/2);
|