teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

転記ソースの誤りがあったため、修正

2018/02/07 07:55

投稿

ojioji
ojioji

スコア11

title CHANGED
File without changes
body CHANGED
@@ -7,28 +7,49 @@
7
7
 
8
8
  ### 該当のソースコード
9
9
 
10
+ ```
10
11
  int width = 画像サイズ(幅);
11
12
  int hight = 画像サイズ(高さ);
12
- intfilecount = ファイル件数;
13
+ int filecount = ファイル件数;
14
+ float *tmp = NULL;
13
- float ***buf = NULL
15
+ float ***tmp2 = NULL
14
- FILE *fp;
16
+ FILE *fp;
15
17
  char fpath = イメージ画像のパス
18
+ unsigned short int buf;
16
19
 
20
+ //tmp 用メモリの確保
21
+ tmp = (float*)calloc( width * hight, sizeof( float ) );
22
+
23
+ //tmp2 用メモリの確保
24
+ (*tmp2) = (float***)calloc( filecount, sizeof( float ** ) );
17
25
  for( i = 0 ; i < filecount ; i++ ){
26
+ (*tmp2)[i] = (float**)calloc( lines, sizeof( float * ) );
27
+ for( j = 0 ; j < hight ; j++ ){
28
+ (*tmp2)[i][j] = (float*)calloc( width, sizeof( float ) );
29
+ }
30
+ }
31
+
32
+ for( i = 0 ; i < filecount ; i++ ){
18
33
  fp = fopen( fpath, "rb" );
19
34
 
20
35
  for( j = 0 ; j < hight ; j++ ){
21
36
  for( k = 0 ; k < width ; k++ ){
22
37
  fread( &buf, sizeof( unsigned short int ), 1, fp );
23
38
  if( buf != 0 ){
24
- fTemp[j*width+k] = (float)( 10.0 * log10( (double)(buf*buf) ) - 83.0 );
39
+ tmp[j*width+k] = (float)( 10.0 * log10( (double)(buf*buf) ) 83.0 );
25
40
  }
26
41
  }
27
42
  }
43
+
44
+ for( j = 0 ; j < (3/2) ; j++ ){
45
+ for( k = 0 ; k < width ; k++ ){
46
+ (*tmp2)[i][j][k] = tmp[j*width+k];
47
+ }
48
+ }
28
49
  }
50
+ ```
29
51
 
30
52
 
31
-
32
53
  ### 補足情報(FW/ツールのバージョンなど)
33
54
 
34
55
  python 3.x