Revisión | 95c2deac747444176bb088db47ee16a23766d3e7 (tree) |
---|---|
Tiempo | 2015-03-04 09:28:21 |
Autor | Takuo Yasunaga <yasunaga@bio....> |
Commiter | Takuo Yasunaga |
deleted: src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/:-1,.co.
@@ -1,248 +0,0 @@ | ||
1 | -/* | |
2 | -# mrcImageMeanFreePathCalc : $Revision$ | |
3 | -# $Date$ | |
4 | -# Created by $Author$ | |
5 | -# Usage : mrcImageMeanFreePathCalc | |
6 | -# Attention | |
7 | -# $Loccker$ | |
8 | -# $State$ | |
9 | -# | |
10 | -*/ | |
11 | -#include <stdio.h> | |
12 | -#include <stdlib.h> | |
13 | -#include <string.h> | |
14 | -#include <math.h> | |
15 | -#define GLOBAL_DECLARATION | |
16 | -#include "../inc/config.h" | |
17 | - | |
18 | -#define DEBUG | |
19 | -#include "genUtil.h" | |
20 | -#include "mrcImage.h" | |
21 | -#include "Memory.h" | |
22 | - | |
23 | -typedef struct lmrcImageMeanFreePathCalcInfo { | |
24 | - int N; | |
25 | - int* countWhite; | |
26 | - int* countBlack; | |
27 | - int* countWhiteEdge; | |
28 | - int* countBlackEdge; | |
29 | - double averageWhite; | |
30 | - double averageBlack; | |
31 | - double averageWhiteEdge; | |
32 | - double averageBlackEdge; | |
33 | -} lmrcImageMeanFreePathCalcInfo; | |
34 | - | |
35 | -typedef enum lmrcImageMeanFreePathCalcMode { | |
36 | - MeanFreePathCalcModeAlongZaxis=0, | |
37 | -} lmrcImageMeanFreePathCalcMode; | |
38 | - | |
39 | -extern void lmrcImageMeanFreePathCalcPrint(FILE* fpt, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode); | |
40 | -extern void lmrcImageMeanFreePathCalc(mrcImage* in, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode); | |
41 | -extern void lmrcImageMeanFreePathCalcAlongZaxis(mrcImage* in, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode); | |
42 | - | |
43 | -extern void lmrcImageMeanFreePathCalcModePrint(FILE* fpt); | |
44 | - | |
45 | -int | |
46 | -main(int argc, char* argv[]) | |
47 | -{ | |
48 | - mrcImageMeanFreePathCalcInfo info; | |
49 | - lmrcImageMeanFreePathCalcInfo linfo; | |
50 | - mrcImage in; | |
51 | - | |
52 | - init0(&info); | |
53 | - argCheck(&info, argc, argv); | |
54 | - init1(&info); | |
55 | - | |
56 | - DEBUGPRINT("Program Start\n"); | |
57 | - | |
58 | - mrcFileRead(&in, info.In, "in main", 0); | |
59 | - | |
60 | - lmrcImageMeanFreePathCalc(&in, &linfo, info.mode); | |
61 | - | |
62 | - lmrcImageMeanFreePathCalcPrint(info.fptOut, &linfo, info.mode); | |
63 | - | |
64 | - exit(EXIT_SUCCESS); | |
65 | -} | |
66 | - | |
67 | -void | |
68 | -additionalUsage() | |
69 | -{ | |
70 | - fprintf(stderr, "----- Additional Usage -----\n"); | |
71 | - lmrcImageMeanFreePathCalcModePrint(stderr); | |
72 | -} | |
73 | - | |
74 | - | |
75 | -void | |
76 | -lmrcImageMeanFreePathCalcModePrint(FILE* fpt) | |
77 | -{ | |
78 | - fprintf(fpt, "%d: AlongZ-axis\n", MeanFreePathCalcModeAlongZaxis); | |
79 | -} | |
80 | - | |
81 | -void | |
82 | -lmrcImageMeanFreePathCalc(mrcImage* in, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode) | |
83 | -{ | |
84 | - switch(mode) { | |
85 | - case MeanFreePathCalcModeAlongZaxis: { | |
86 | - lmrcImageMeanFreePathCalcAlongZaxis(in, linfo, mode); | |
87 | - break; | |
88 | - } | |
89 | - default: { | |
90 | - fprintf(stderr, "Not supported mode: %d\n", mode); | |
91 | - exit(EXIT_FAILURE); | |
92 | - break; | |
93 | - } | |
94 | - } | |
95 | - | |
96 | -} | |
97 | - | |
98 | -void | |
99 | -lmrcImageMeanFreePathCalcPrint(FILE* fpt, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode) | |
100 | -{ | |
101 | - int i; | |
102 | - for(i=0; i<=linfo->N; i++) { | |
103 | - fprintf(fpt, "%4d %6d %6d %6d %6d %6.3f %6.3f %6.3f %6.3f\n", | |
104 | - i, | |
105 | - linfo->countWhite[i], linfo->countBlack[i], | |
106 | - linfo->countWhiteEdge[i], linfo->countBlackEdge[i], | |
107 | - linfo->countWhite[i]/(double)linfo->countWhite[0]*100, linfo->countBlack[i]/(double)linfo->countBlack[0]*100, | |
108 | - linfo->countWhiteEdge[i]/(double)linfo->countWhiteEdge[0]*100, linfo->countBlackEdge[i]/(double)linfo->countBlackEdge[0]*100); | |
109 | - } | |
110 | -} | |
111 | - | |
112 | - | |
113 | -void | |
114 | -lmrcImageMeanFreePathCalcAlongZaxis(mrcImage* in, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode) | |
115 | -{ | |
116 | - int* countBlack; | |
117 | - int* countWhite; | |
118 | - int* countBlackEdge; | |
119 | - int* countWhiteEdge; | |
120 | - int x, y, z; | |
121 | - int flagEdge; | |
122 | - double data; | |
123 | - double prevData; | |
124 | - int lengthWhite; | |
125 | - int lengthBlack; | |
126 | - int i; | |
127 | - | |
128 | - countBlack = memoryAllocate(sizeof(int)*(in->HeaderN.z+1), "in lmrcImageMeanFreePathCalc"); | |
129 | - countWhite = memoryAllocate(sizeof(int)*(in->HeaderN.z+1), "in lmrcImageMeanFreePathCalc"); | |
130 | - countBlackEdge = memoryAllocate(sizeof(int)*(in->HeaderN.z+1), "in lmrcImageMeanFreePathCalc"); | |
131 | - countWhiteEdge = memoryAllocate(sizeof(int)*(in->HeaderN.z+1), "in lmrcImageMeanFreePathCalc"); | |
132 | - | |
133 | - linfo->countBlack = countBlack; | |
134 | - linfo->countWhite = countWhite; | |
135 | - linfo->countBlackEdge = countBlackEdge; | |
136 | - linfo->countWhiteEdge = countWhiteEdge; | |
137 | - linfo->N = in->HeaderN.z; | |
138 | - | |
139 | - for(y=0; y<in->HeaderN.y; y++) { | |
140 | - for(x=0; x<in->HeaderN.x; x++) { | |
141 | - flagEdge = 1; | |
142 | - lengthWhite = 0; | |
143 | - lengthBlack = 0; | |
144 | - | |
145 | - // Start | |
146 | - mrcPixelDataGet(in, x, y, 0, &data, mrcPixelRePart, mrcPixelHowNearest); | |
147 | - if(0<data) { | |
148 | - countWhiteEdge[0]++; | |
149 | - lengthWhite++; | |
150 | - } else { | |
151 | - countBlackEdge[0]++; | |
152 | - lengthBlack++; | |
153 | - } | |
154 | - prevData = data; | |
155 | - | |
156 | - // Interval | |
157 | - for(z=1; z<in->HeaderN.z-1; z++) { | |
158 | - mrcPixelDataGet(in, x, y, z, &data, mrcPixelRePart, mrcPixelHowNearest); | |
159 | - if(0<prevData) { | |
160 | - if(0<data) { // White continue | |
161 | - if(flagEdge) { | |
162 | - countWhiteEdge[0]++; | |
163 | - } else { | |
164 | - countWhite[0]++; | |
165 | - } | |
166 | - lengthWhite++; | |
167 | - } else { // White -> Black | |
168 | - if(flagEdge) { | |
169 | - countWhiteEdge[lengthWhite]++; | |
170 | - flagEdge=0; | |
171 | - } else { | |
172 | - countWhite[lengthWhite]++; | |
173 | - } | |
174 | - countBlack[0]++; | |
175 | - lengthWhite=0; | |
176 | - lengthBlack++; | |
177 | - } | |
178 | - } else { | |
179 | - if(0<data) { // Black -> White | |
180 | - if(flagEdge) { | |
181 | - countBlackEdge[lengthBlack]++; | |
182 | - flagEdge=0; | |
183 | - } else { | |
184 | - countBlack[lengthBlack]++; | |
185 | - } | |
186 | - countWhite[0]++; | |
187 | - lengthBlack=0; | |
188 | - lengthWhite++; | |
189 | - } else { // Black continue | |
190 | - if(flagEdge) { | |
191 | - countBlackEdge[0]++; | |
192 | - } else { | |
193 | - countBlack[0]++; | |
194 | - } | |
195 | - lengthBlack++; | |
196 | - } | |
197 | - } | |
198 | - prevData = data; | |
199 | - } | |
200 | - | |
201 | - // End | |
202 | - mrcPixelDataGet(in, x, y, in->HeaderN.z-1, &data, mrcPixelRePart, mrcPixelHowNearest); | |
203 | - | |
204 | - if(0<prevData) { | |
205 | - if(0<data) { // White continue | |
206 | - lengthWhite++; | |
207 | - countWhiteEdge[lengthWhite]++; | |
208 | - countWhiteEdge[0]++; | |
209 | - } else { // White -> Black | |
210 | - if(flagEdge) { | |
211 | - countWhiteEdge[lengthWhite]++; | |
212 | - } else { | |
213 | - countWhite[lengthWhite]++; | |
214 | - } | |
215 | - countBlackEdge[1]++; | |
216 | - countBlackEdge[0]++; | |
217 | - } | |
218 | - } else { | |
219 | - if(0<data) { // Black -> White | |
220 | - if(flagEdge) { | |
221 | - countBlackEdge[lengthBlack]++; | |
222 | - } else { | |
223 | - countBlack[lengthBlack]++; | |
224 | - } | |
225 | - countWhiteEdge[1]++; | |
226 | - countWhiteEdge[0]++; | |
227 | - } else { // Black continue | |
228 | - lengthBlack++; | |
229 | - if(flagEdge) { | |
230 | - countBlackEdge[lengthBlack]++; | |
231 | - countBlackEdge[0]++; | |
232 | - } else { | |
233 | - countBlack[lengthBlack]++; | |
234 | - countBlack[0]++; | |
235 | - } | |
236 | - } | |
237 | - } | |
238 | - } | |
239 | - } | |
240 | - | |
241 | - linfo->averageWhite = linfo->averageBlack = 0; | |
242 | - linfo->averageWhiteEdge = linfo->averageBlackEdge = 0; | |
243 | - for(i=0; i<=linfo->N; i++) { | |
244 | - linfo->averageWhite += linfo->countWhite[i]; | |
245 | - linfo->averageBlack += linfo->countBlack[i]; | |
246 | - } | |
247 | - | |
248 | -} |