修订版 | 193bed700abcae852649c12493b2b9d6e209397a (tree) |
---|---|
时间 | 2015-03-06 05:09:11 |
作者 | Takuo Yasunaga <yasunaga@bio....> |
Commiter | Takuo Yasunaga |
modified: .gitignore
modified: util/src/Graphics/Makefile
@@ -33,6 +33,9 @@ bin/wish/*/tclIndex | ||
33 | 33 | */*/tclIndex |
34 | 34 | */tclIndex |
35 | 35 | |
36 | +#util | |
37 | +util/src.org/ | |
38 | + | |
36 | 39 | # |
37 | 40 | data/ |
38 | 41 | .acmlg/ |
@@ -17,36 +17,52 @@ | ||
17 | 17 | |
18 | 18 | #define DEBUG |
19 | 19 | #include "genUtil.h" |
20 | +#include "Memory.h" | |
21 | +#include "Matrix3D.h" | |
22 | +#include "Vector.h" | |
20 | 23 | #include "mrcImage.h" |
21 | 24 | |
22 | 25 | typedef struct lmrcImageShapeSearchInfo { |
23 | - int radius; // Sylinder, plane | |
24 | - int minRadius; | |
25 | - int maxRadius; | |
26 | + float radius; // Sylinder, plane | |
27 | + float minRadius; | |
28 | + float maxRadius; | |
29 | + float delRadius; | |
26 | 30 | |
27 | - int length; // Sylinder | |
28 | - int minLength; | |
29 | - int maxLength; | |
31 | + float length; // Sylinder | |
32 | + float minLength; | |
33 | + float maxLength; | |
34 | + float delLength; | |
30 | 35 | |
31 | - int thickness; // Plane | |
32 | - int minThickness; | |
33 | - int maxThickness; | |
36 | + float thickness; // Plane | |
37 | + float minThickness; | |
38 | + float maxThickness; | |
39 | + float delThickness; | |
34 | 40 | |
35 | 41 | float minTheta; |
36 | 42 | float maxTheta; |
37 | 43 | float delTheta; |
44 | + | |
38 | 45 | float minPhi; |
39 | 46 | float maxPhi; |
40 | 47 | float delPhi; |
48 | + | |
41 | 49 | float minPsi; |
42 | 50 | float maxPsi; |
43 | 51 | float delPsi; |
44 | 52 | |
45 | - mrcImage shape; | |
53 | + int interpMode; | |
54 | + mrcImage shape; // Template Structure | |
55 | + | |
56 | + // Output | |
57 | + mrcImage average; // Average for all orientations | |
58 | + mrcImage SD; // SD for all | |
59 | + mrcImage Zscore; // Z-score; | |
60 | + mrcImage shapeInfo; // Shape, Orientation, ... | |
46 | 61 | } lmrcImageShapeSearchInfo; |
47 | 62 | |
48 | 63 | typedef enum lmrcImageShapeSearchMode { |
49 | - lmrcImageShapeSearchModeSylinder=0 | |
64 | + lmrcImageShapeSearchModeSylinder=0, | |
65 | + lmrcImageShapeSearchModePlane=1 | |
50 | 66 | } lmrcImageShapeSearchMode; |
51 | 67 | |
52 | 68 | extern void lmrcImageShapeSearch(mrcImage* out, mrcImage* in, lmrcImageShapeSearchInfo* linfo, int mode); |
@@ -99,6 +115,7 @@ void | ||
99 | 115 | lmrcImageShapeSearchModePrint(FILE* fpt) |
100 | 116 | { |
101 | 117 | fprintf(fpt, "%d: Cylinder with radius and length\n", lmrcImageShapeSearchModeSylinder); |
118 | + fprintf(fpt, "%d: Plane with radius and thickness\n", lmrcImageShapeSearchModePlane); | |
102 | 119 | } |
103 | 120 | |
104 | 121 |
@@ -110,6 +127,10 @@ lmrcImageShapeSearch(mrcImage* out, mrcImage* in, lmrcImageShapeSearchInfo* linf | ||
110 | 127 | lmrcImageShapeSearchSylinder(out, in, linfo, mode); |
111 | 128 | break; |
112 | 129 | } |
130 | + case lmrcImageShapeSearchModePlane: { | |
131 | + lmrcImageShapeSearchPlane(out, in, linfo, mode); | |
132 | + break; | |
133 | + } | |
113 | 134 | default: { |
114 | 135 | fprintf(stderr, "Not supported mode: %d\n", mode); |
115 | 136 | break; |
@@ -122,45 +143,98 @@ void | ||
122 | 143 | lmrcImageShapeSearchSylinder(mrcImage* out, mrcImage* in, lmrcImageShapeSearchInfo* linfo, int mode) |
123 | 144 | { |
124 | 145 | float x, y, z; |
125 | - float theta, phi, psi; | |
126 | - int iPhi, iTheta, iPsi; | |
127 | - int nPhi, nTheta, nPsi; | |
128 | - int iR; | |
146 | + float srcx, srcy, srcz; | |
147 | + float dstx, dsty, dstz; | |
148 | + float theta, phi, psi, radius, length; | |
149 | + int iPhi, iTheta, iPsi, iRadius, iLength; | |
150 | + int nPhi, nTheta, nPsi, nRadius, nLength; | |
129 | 151 | float max; |
130 | - mrcImage template; | |
131 | - | |
132 | - max = MAX(2*linfo->radius, linfo->length); | |
133 | - | |
134 | - template->Header = in->Header; | |
135 | - template->HeaderLength.x = max; | |
136 | - template->HeaderLength.y = max; | |
137 | - template->HeaderLength.z = max; | |
138 | - mrcInit(&template, NULL); | |
139 | - | |
140 | - for(z=0; z<in->HeaderN.z; z++) { | |
141 | - for(y=0; y<in->HeaderN.y; y++) { | |
142 | - for(x=0; x<in->HeaderN.x; x++) { | |
143 | - | |
144 | - } | |
145 | - } | |
146 | - } | |
147 | - | |
148 | - nPhi = (int)((linfo->maxPhi -linfo->minPhi) /linfo->delPhi) +1; | |
149 | - nTheta = (int)((linfo->maxTheta-linfo->minTheta)/linfo->delTheta)+1; | |
150 | - nPsi = 2*M_PI/linfo->delPsi; | |
152 | + double* data; | |
153 | + double d, cp, sp; | |
154 | + double score; | |
155 | + int nData, index; | |
156 | + float r, l, p; | |
157 | + Matrix3D mat; | |
158 | + floatVector v; | |
159 | + | |
160 | + nPhi = (int)((linfo->maxPhi - linfo->minPhi) /linfo->delPhi) +1; | |
161 | + nTheta = (int)((linfo->maxTheta - linfo->minTheta)/linfo->delTheta)+1; | |
162 | + nPsi= (int)((linfo->maxTheta - linfo->minTheta)/linfo->delTheta)+1; | |
163 | + nRadius = (int)((linfo->maxRadius - linfo->minRadius)/linfo->delRadius) + 1; | |
164 | + nLength = (int)((linfo->maxLength - linfo->minLength)/linfo->delLength) + 1; | |
165 | + | |
166 | + nData = nPhi*nTheta*nPsi*nRadius*nLength; | |
167 | + data = (double*)memoryAllocate(sizeof(double)*nData, "in lmrcImageShapeSearchSylinder"); | |
168 | + | |
169 | + floatVectorInit(&v, 4); | |
170 | + v.data[3] = 1; | |
151 | 171 | |
152 | 172 | for(z=0; z<in->HeaderN.z; z++) { |
153 | 173 | for(y=0; y<in->HeaderN.y; y++) { |
154 | 174 | for(x=0; x<in->HeaderN.x; x++) { |
155 | - for(iTheta=0; iTheta<nTheta; iTheta++) { | |
156 | - theta = linfo->minTheta + iTheta*linfo->delTheta; | |
157 | 175 | for(iPhi=0; iPhi<nPhi; iPhi++) { |
158 | 176 | phi = linfo->minPhi + iPhi*linfo->delPhi; |
159 | - for(iR=linfo->minRadius; iR<=linfo->maxRadius; iR++) { | |
160 | - | |
177 | + for(iTheta=0; iTheta<nTheta; iTheta++) { | |
178 | + theta = linfo->minTheta + iTheta*linfo->delTheta; | |
179 | + for(iPsi=0; iPsi<nPsi; iPsi++) { | |
180 | + psi= linfo->minPsi+ iPhi*linfo->delPsi; | |
181 | + | |
182 | + matrix3DRotationSetFollowingEulerAngle(mat, "ZENS", phi, theta, psi, MATRIX_3D_MODE_INITIALIZE); | |
183 | + | |
184 | + for(iRadius=linfo->minRadius; iRadius<=linfo->maxRadius; iRadius++) { | |
185 | + radius = linfo->minRadius + iRadius*linfo->delRadius; | |
186 | + for(iLength=linfo->minLength; iLength<=linfo->maxLength; iLength++) { | |
187 | + length = linfo->minLength + iLength*linfo->delLength; | |
188 | + | |
189 | + index = iPhi | |
190 | + +iTheta *nPhi | |
191 | + +iPsi *nPhi*nTheta | |
192 | + +iRadius*nPhi*nTheta*nPsi | |
193 | + +iLength*nPhi*nTheta*nPsi*nRadius; | |
194 | + | |
195 | + score = 0; | |
196 | + for(p=0; r<2*M_PI; l+=linfo->delPsi) { | |
197 | + cp = cos(p); | |
198 | + sp = sin(p); | |
199 | + for(l=0; r<=length; l+=linfo->delLength) { | |
200 | + v.data[2] = l-length/2; | |
201 | + for(r=0; r<=radius; r+=linfo->delRadius) { | |
202 | + v.data[0] = r*cp; | |
203 | + v.data[1] = r*sp; | |
204 | + | |
205 | + matrix3DMultiplyVector(&v, mat); | |
206 | + dstx = x + v.data[0]; | |
207 | + dsty = y + v.data[1]; | |
208 | + dstz = z + v.data[2]; | |
209 | + mrcPixelDataGet(in, dstx, dsty, dstz, &d, mrcPixelRePart, linfo->interpMode); | |
210 | + score += d; | |
211 | + } | |
212 | + v.data[0] = r*cos(p); | |
213 | + v.data[1] = r*sin(p); | |
214 | + matrix3DMultiplyVector(&v, mat); | |
215 | + dstx = x + v.data[0]; | |
216 | + dsty = y + v.data[1]; | |
217 | + dstz = z + v.data[2]; | |
218 | + mrcPixelDataGet(in, dstx, dsty, dstz, &d, mrcPixelRePart, linfo->interpMode); | |
219 | + score -= d; | |
161 | 220 | } |
221 | + } | |
222 | + data[index] = score; | |
223 | + } | |
224 | + } | |
225 | + } | |
226 | + } | |
227 | + } | |
228 | + sum = 0; | |
229 | + for(i=0; i<nData; i++) { | |
230 | + sum += data[i]; | |
162 | 231 | } |
232 | + ave = sum/nData; | |
233 | + sum = 0; | |
234 | + for(i=0; i<nData; i++) { | |
235 | + sum += SQR(data[i]-ave); | |
163 | 236 | } |
237 | + sd = sqrt(sum/nData); | |
164 | 238 | } |
165 | 239 | } |
166 | 240 | } |
@@ -169,48 +243,5 @@ lmrcImageShapeSearchSylinder(mrcImage* out, mrcImage* in, lmrcImageShapeSearchIn | ||
169 | 243 | void |
170 | 244 | lmrcImageShapeSearchPlane(mrcImage* out, mrcImage* in, lmrcImageShapeSearchInfo* linfo, int mode) |
171 | 245 | { |
172 | - float x, y, z; | |
173 | - float theta, phi, psi; | |
174 | - int iPhi, iTheta, iPsi; | |
175 | - int nPhi, nTheta, nPsi; | |
176 | - int iR; | |
177 | - float max; | |
178 | - mrcImage template; | |
179 | - | |
180 | - max = MAX(2*linfo->radius, linfo->length); | |
181 | - | |
182 | - template->Header = in->Header; | |
183 | - template->HeaderLength.x = max; | |
184 | - template->HeaderLength.y = max; | |
185 | - template->HeaderLength.z = max; | |
186 | - mrcInit(&template, NULL); | |
187 | - | |
188 | - for(z=0; z<in->HeaderN.z; z++) { | |
189 | - for(y=0; y<in->HeaderN.y; y++) { | |
190 | - for(x=0; x<in->HeaderN.x; x++) { | |
191 | - | |
192 | - } | |
193 | - } | |
194 | - } | |
195 | - | |
196 | - nPhi = (int)((linfo->maxPhi -linfo->minPhi) /linfo->delPhi) +1; | |
197 | - nTheta = (int)((linfo->maxTheta-linfo->minTheta)/linfo->delTheta)+1; | |
198 | - nPsi = 2*M_PI/linfo->delPsi; | |
199 | - | |
200 | - for(z=0; z<in->HeaderN.z; z++) { | |
201 | - for(y=0; y<in->HeaderN.y; y++) { | |
202 | - for(x=0; x<in->HeaderN.x; x++) { | |
203 | - for(iTheta=0; iTheta<nTheta; iTheta++) { | |
204 | - theta = linfo->minTheta + iTheta*linfo->delTheta; | |
205 | - for(iPhi=0; iPhi<nPhi; iPhi++) { | |
206 | - phi = linfo->minPhi + iPhi*linfo->delPhi; | |
207 | - for(iR=linfo->minRadius; iR<=linfo->maxRadius; iR++) { | |
208 | - | |
209 | - } | |
210 | - } | |
211 | - } | |
212 | - } | |
213 | - } | |
214 | - } | |
215 | 246 | } |
216 | 247 |
@@ -1 +0,0 @@ | ||
1 | -orgsrc/src | |
\ No newline at end of file |
@@ -3,12 +3,18 @@ SHELL=/bin/sh | ||
3 | 3 | |
4 | 4 | include ${EOS_HOME}/src/Config/${EOS_HOST}${FLAG_ICC}.inc |
5 | 5 | |
6 | -JPEGVERSION=6b | |
6 | +#JPEGVERSION=6b | |
7 | +JPEGVERSION=9a | |
7 | 8 | ##GIFVERSION=3.0 |
8 | -GIFVERSION=4.1.6 | |
9 | +#GIFVERSION=4.1.6 | |
10 | +GIFVERSION=5.1.1 | |
9 | 11 | MESAVERSION=4.0.3 |
10 | 12 | #TIFFVERSION=v3.4beta037 |
11 | -TIFFVERSION=3.8.2 | |
13 | +#TIFFVERSION=3.8.2 | |
14 | +TIFFVERSION=4.0.3 | |
15 | + | |
16 | +help: | |
17 | + echo "JPEG/GIF/TIFF/MESA" | |
12 | 18 | |
13 | 19 | check: JPEGInit GIFInit TIFFInit MESAInit |
14 | 20 |
@@ -16,61 +22,128 @@ config: JPEGConfig GIFConfig MESAConfig TIFFConfig | ||
16 | 22 | |
17 | 23 | all: JPEG GIF MESA TIFF |
18 | 24 | |
19 | -clean: | |
20 | - | |
21 | -JPEGInit:: | |
22 | - ln -sf ../../src/Graphics/jpeg-$(JPEGVERSION).tar.gz . | |
23 | - gzip -dc jpeg-$(JPEGVERSION).tar.gz | tar xvf - | |
24 | - | |
25 | -TIFFInit:: | |
26 | - ln -sf ../..//src/Graphics/tiff-$(TIFFVERSION).tar.gz . | |
27 | - gzip -dc tiff-$(TIFFVERSION).tar.gz | tar xvf - | |
25 | +clean: JPEGClean GIFClean MESAClean TIFFClean | |
28 | 26 | |
29 | -MESAInit:: | |
30 | - ln -sf ../../src/Graphics/MesaLib-$(MESAVERSION).tar.gz . | |
31 | - gzip -dc MesaLib-$(MESAVERSION).tar.gz | tar xvf - | |
27 | +cleanAll: JPEGCleanAll GIFCleanAll MESACleanAll TIFFCleanAll | |
32 | 28 | |
33 | -GIFInit:: | |
34 | - ln -sf ../../src/Graphics/giflib-$(GIFVERSION).tar.gz . | |
35 | - gzip -dc giflib-$(GIFVERSION).tar.gz | tar xvf - | |
29 | +# | |
30 | +# JPEG | |
31 | +# | |
32 | +JPEGInit:: | |
33 | + #ln -sf ../../src/Graphics/jpeg-$(JPEGVERSION).tar.gz . | |
34 | + curl -O http://www.ijg.org/files/jpegsrc.v$(JPEGVERSION).tar.gz | |
35 | + gzip -dc jpegsrc.v$(JPEGVERSION).tar.gz | tar xvf - | |
36 | + #gzip -dc jpeg-$(JPEGVERSION).tar.gz | tar xvf - | |
36 | 37 | |
37 | 38 | JPEGConfig:: |
38 | 39 | cd jpeg-$(JPEGVERSION) ; \ |
39 | 40 | $(MAKE) clean ; \ |
40 | - ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) --enable-static --enable-shared | |
41 | - | |
42 | -GIFConfig:: | |
43 | - cd giflib-$(GIFVERSION) ; \ | |
44 | - ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) --exec-prefix=${EOS_HOME}/util/$(OSTYPE) ; \ | |
45 | - $(MAKE) clean | |
46 | - | |
47 | -MESAConfig:: | |
48 | - cd Mesa-$(MESAVERSION) ; \ | |
49 | - ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) --with-glut=${EOS_HOME}/util/$(OSTYPE)/lib ; \ | |
50 | - $(MAKE) clean | |
51 | - | |
52 | -TIFFConfig:: | |
53 | - cd tiff-$(TIFFVERSION) ; \ | |
54 | - $(MAKE) clean ; \ | |
55 | - ./configure CC=icc --with-x --prefix=$(EOS_HOME)/util/$(OSTYPE) | |
56 | - | |
41 | + if [ ! -z $${USE_ICC} ] ; then \ | |
42 | + ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) ; \ | |
43 | + else \ | |
44 | + ./configure --prefix=${EOS_HOME}/util/$(OSTYPE) ; \ | |
45 | + fi | |
57 | 46 | |
58 | 47 | JPEG:: |
59 | 48 | cd jpeg-$(JPEGVERSION); \ |
60 | 49 | $(MAKE) install ; \ |
61 | 50 | $(MAKE) install-lib |
62 | 51 | |
52 | +JPEGClean:: | |
53 | + cd jpeg-$(JPEGVERSION); \ | |
54 | + $(MAKE) -i clean | |
55 | + | |
56 | +JPEGCleanAll:: | |
57 | + rm -rf jpeg-$(JPEGVERSION) | |
58 | + rm jpegsrc.v$(JPEGVERSION).tar.gz | |
59 | + | |
60 | +# | |
61 | +# GIF | |
62 | +# | |
63 | +GIFInit:: | |
64 | + #ln -sf ../../src/Graphics/giflib-$(GIFVERSION).tar.gz . | |
65 | + curl -L http://sourceforge.net/projects/giflib/files/giflib-$(GIFVERSION).tar.gz/download > giflib-$(GIFVERSION).tar.gz | |
66 | + gzip -dc giflib-$(GIFVERSION).tar.gz | tar xvf - | |
67 | + | |
68 | +GIFConfig:: | |
69 | + cd giflib-$(GIFVERSION) ; \ | |
70 | + $(MAKE) -i clean ; \ | |
71 | + if [ ! -z $${USE_ICC} ] ; then \ | |
72 | + ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) --exec-prefix=${EOS_HOME}/util/$(OSTYPE) ; \ | |
73 | + else \ | |
74 | + ./configure --prefix=${EOS_HOME}/util/$(OSTYPE) --exec-prefix=${EOS_HOME}/util/$(OSTYPE) ; \ | |
75 | + fi ; | |
76 | + | |
63 | 77 | GIF:: |
64 | 78 | cd giflib-$(GIFVERSION) ; \ |
65 | 79 | $(MAKE) ; \ |
66 | 80 | mkdir ${EOS_HOME}/util/$(OSTYPE)/bin ; \ |
67 | 81 | $(MAKE) DEST=${EOS_HOME}/util/$(OSTYPE)/bin LIBDIR=${EOS_HOME}/util/$(OSTYPE)/lib install |
68 | 82 | |
83 | +GIFClean:: | |
84 | + cd giflib-$(GIFVERSION) ; \ | |
85 | + $(MAKE) -i clean | |
86 | + | |
87 | +GIFCleanAll:: | |
88 | + rm -rf giflib-$(GIFVERSION) | |
89 | + rm -rf giflib-$(GIFVERSION).tar.gz | |
90 | + | |
91 | +# | |
92 | +# MESA | |
93 | +# | |
94 | + | |
95 | +MESAInit:: | |
96 | + ln -sf ../../src/Graphics/MesaLib-$(MESAVERSION).tar.gz . | |
97 | + gzip -dc MesaLib-$(MESAVERSION).tar.gz | tar xvf - | |
98 | + | |
99 | +MESAConfig:: | |
100 | + cd Mesa-$(MESAVERSION) ; \ | |
101 | + if [ ! -z $${USE_ICC} ] ; then \ | |
102 | + ./configure CC=icc --prefix=${EOS_HOME}/util/$(OSTYPE) --with-glut=${EOS_HOME}/util/$(OSTYPE)/lib ; \ | |
103 | + else \ | |
104 | + ./configure --prefix=${EOS_HOME}/util/$(OSTYPE) --with-glut=${EOS_HOME}/util/$(OSTYPE)/lib ; \ | |
105 | + fi ; | |
106 | + | |
69 | 107 | MESA:: |
70 | - cd ../../src$(OSTYPE)/Graphics/Mesa-$(MESAVERSION) ; \ | |
108 | + cd Mesa-$(MESAVERSION) ; \ | |
71 | 109 | $(MAKE) -i linux; \ |
72 | 110 | $(MAKE) install |
73 | 111 | |
112 | +MESAClean:: | |
113 | + cd Mesa-$(MESAVERSION) ; \ | |
114 | + $(MAKE) clean | |
115 | + | |
116 | +MESACleanAll:: | |
117 | + rm -rf Mesa-$(MESAVERSION) | |
118 | + rm -f MesaLib-$(MESAVERSION).tar.gz | |
119 | + | |
120 | +# | |
121 | +# TIFF | |
122 | +# | |
123 | + | |
124 | +TIFFInit:: | |
125 | + #ln -sf ../..//src/Graphics/tiff-$(TIFFVERSION).tar.gz . | |
126 | + curl -O http://download.osgeo.org/libtiff/tiff-$(TIFFVERSION).tar.gz | |
127 | + gzip -dc tiff-$(TIFFVERSION).tar.gz | tar xvf - | |
128 | + | |
129 | +TIFFConfig:: | |
130 | + cd tiff-$(TIFFVERSION) ; \ | |
131 | + $(MAKE) -i clean ; \ | |
132 | + if [ ! -z $${USE_ICC} ] ; then \ | |
133 | + ./configure CC=icc --with-x --with-jpeg-lib-dir=$(EOS_HOME)/util/$(OSTYPE)/lib --with-jpeg-include-dir=$(EOS_HOME)/util/$(OSTYPE)/include --prefix=$(EOS_HOME)/util/$(OSTYPE); \ | |
134 | + else \ | |
135 | + ./configure --with-x --with-x --with-jpeg-lib-dir=$(EOS_HOME)/util/$(OSTYPE)/lib --with-jpeg-include-dir=$(EOS_HOME)/util/$(OSTYPE)/include --prefix=$(EOS_HOME)/util/$(OSTYPE); \ | |
136 | + fi | |
137 | + | |
74 | 138 | TIFF:: |
75 | 139 | cd tiff-$(TIFFVERSION); \ |
76 | 140 | $(MAKE) install |
141 | + | |
142 | +TIFFClean:: | |
143 | + cd tiff-$(TIFFVERSION); \ | |
144 | + $(MAKE) -i clean | |
145 | + | |
146 | +TIFFCleanAll:: | |
147 | + rm -rf tiff-$(TIFFVERSION) | |
148 | + rm -rf tiff-$(TIFFVERSION).tar.gz | |
149 | + |