5 # The latest update : %G% at %U%
7 #%Z% mrcImage.h ver %I%
10 #%Z% Usage : mrcImage.h
16 * Language: C or CC(c++)
17 * Editor : tacyas.tkyemg.u_tokyo
19 * Modified: 2012 for CCP4(2000)
23 * Header File for MRC Format
35 typedef unsigned int mrcStatusMask;
37 typedef unsigned int mrcStatusMask;
42 typedef unsigned int mrcStatusType;
44 typedef unsigned int mrcStatusType;
51 #define mrcStatusMask_ExitFailure ((mrcStatusMask)0x80000000L)
52 #define mrcStatusMask_Warning ((mrcStatusMask)0x40000000L)
53 #define mrcStatusMask_Information ((mrcStatusMask)0x20000000L)
54 #define mrcStatusMask_Message ((mrcStatusMask)0x10000000L)
55 #define mrcStatusMask_1B ((mrcStatusMask)0x08000000L)
56 #define mrcStatusMask_1A ((mrcStatusMask)0x04000000L)
57 #define mrcStatusMask_19 ((mrcStatusMask)0x02000000L)
58 #define mrcStatusMask_18 ((mrcStatusMask)0x01000000L)
59 #define mrcStatusMask_17 ((mrcStatusMask)0x00800000L)
60 #define mrcStatusMask_16 ((mrcStatusMask)0x00400000L)
61 #define mrcStatusMask_15 ((mrcStatusMask)0x00200000L)
62 #define mrcStatusMask_14 ((mrcStatusMask)0x00100000L)
63 #define mrcStatusMask_ReferMRCInfo ((mrcStatusMask)0x00080000L)
64 #define mrcStatusMask_Mode ((mrcStatusMask)0x00040000L)
65 #define mrcStatusMask_ReferMemory ((mrcStatusMask)0x00020000L)
66 #define mrcStatusMask_ReferFile ((mrcStatusMask)0x00010000L)
68 #define MRC_Status_OK ((mrcStatusType)0x00000000L)
70 #define MRC_FileCanNotOpened ((mrcStatusType)0x00000000L|mrcStatusMask_ReferFile)
71 #define MRC_ImageHeaderCanNotRead ((mrcStatusType)0x00000001L|mrcStatusMask_ReferFile)
72 #define MRC_ImageDataCanNotRead ((mrcStatusType)0x00000002L|mrcStatusMask_ReferFile)
73 #define MRC_ImageHeaderCanNotWrite ((mrcStatusType)0x00000003L|mrcStatusMask_ReferFile)
74 #define MRC_ImageDataCanNotWrite ((mrcStatusType)0x00000004L|mrcStatusMask_ReferFile)
75 #define MRC_FileCanNotClosed ((mrcStatusType)0x00000005L|mrcStatusMask_ReferFile)
77 #define MRC_MemoryNotAllocate ((mrcStatusType)0x00000000L|mrcStatusMask_ReferMemory)
79 #define MRC_ModeNotSupported ((mrcStatusType)0x00000000L|mrcStatusMask_Mode)
80 #define MRC_ModeZNot1FFTMode ((mrcStatusType)0x00000001L|mrcStatusMask_Mode)
82 #define MRC_SizeOfZero ((mrcStatusType)0x00000000L|mrcStatusMask_ReferMRCInfo)
85 extern char* mrcImageGeneralTypeList[];
90 typedef union MRC_Status_t {
95 unsigned char category;
99 unsigned char category;
106 typedef int mrcImageParaTypeInteger;
108 typedef int mrcImageParaTypeInteger;
111 typedef float mrcImageParaTypeReal;
112 typedef unsigned char mrcImageParaTypeCharacter;
114 typedef struct mrcImageParaTypeIntegerCoord {
115 mrcImageParaTypeInteger x;
116 mrcImageParaTypeInteger y;
117 mrcImageParaTypeInteger z;
118 } mrcImageParaTypeIntegerCoord;
120 typedef struct mrcImageParaTypeRealCoord {
121 mrcImageParaTypeReal x;
122 mrcImageParaTypeReal y;
123 mrcImageParaTypeReal z;
124 } mrcImageParaTypeRealCoord;
133 #define MRC_HEADER (1024)
134 #define MRC_TAILER (1024)
136 /* Image Data Type */
137 /* for compatibility */
138 typedef mrcImageParaTypeInteger mrcImageMode;
139 #define MRC_char_image ((mrcImageMode)0)
140 #define MRC_short_image ((mrcImageMode)1)
141 #define MRC_float_image ((mrcImageMode)2)
142 #define MRC_complex_short_ft ((mrcImageMode)3)
143 #define MRC_complex_float_ft ((mrcImageMode)4)
144 #define MRC_long_image ((mrcImageMode)101)
145 #define MRC_double_image ((mrcImageMode)102)
146 #define MRC_complex_long_ft ((mrcImageMode)103)
147 #define MRC_complex_double_ft ((mrcImageMode)104)
148 #define MRC_complex_short_fft ((mrcImageMode)1003)
149 #define MRC_complex_float_fft ((mrcImageMode)1004)
150 #define MRC_complex_long_fft ((mrcImageMode)1103)
151 #define MRC_complex_double_fft ((mrcImageMode)1104)
152 #define MRC_NotSuppotedMode ((mrcImageMode)0xffffffffL)
154 #define mrcCharImage ((mrcImageMode)0)
155 #define mrcShortImage ((mrcImageMode)1)
156 #define mrcFloatImage ((mrcImageMode)2)
157 #define mrcComplexShortFT ((mrcImageMode)3)
158 #define mrcComplexFloatFT ((mrcImageMode)4)
159 #define mrcComplexFloatOneDimFT ((mrcImageMode)5)
161 #define mrcUShortImage ((mrcImageMode)6)
162 #define mrcCharImageRGB ((mrcImageMode)16)
163 // Change for IMOD: (6,7) -> (26,27)
164 #define mrcFloatRadonImage ((mrcImageMode)26)
165 #define mrcFloatRadonFT ((mrcImageMode)27)
166 #define mrcLongImage ((mrcImageMode)101)
167 #define mrcDoubleImage ((mrcImageMode)102)
168 #define mrcComplexLongFT ((mrcImageMode)103)
169 #define mrcComplexDoubleFT ((mrcImageMode)104)
170 #define mrcComplexShortFFT ((mrcImageMode)1003)
171 #define mrcComplexFloatFFT ((mrcImageMode)1004)
172 #define mrcComplexLongFFT ((mrcImageMode)1103)
173 #define mrcComplexDoubleFFT ((mrcImageMode)1104)
174 #define mrcNotSuppotedMode ((mrcImageMode)0xffffffffL)
176 #define MRC_MAX_LABEL_N (10)
177 #define MRC_MAX_LABEL_LEN (80)
178 #define MRC_MAX_EXTRA (29)
179 #define MRC_MAX_EXTRA_CCP4 (15)
185 typedef struct _mrcImageHeader {
186 mrcImageParaTypeIntegerCoord N; /* Data Numbers */
187 mrcImageMode Mode; /* Data Type */
188 mrcImageParaTypeIntegerCoord StartN; /* First in map */
189 mrcImageParaTypeIntegerCoord M; /* Number of Intervals */
190 mrcImageParaTypeRealCoord Length; /* Cell Dimensions : Angstrom */
191 mrcImageParaTypeReal Alpha; /* Cell Angle : Degree */
192 mrcImageParaTypeReal Beta;
193 mrcImageParaTypeReal Gamma;
194 mrcImageParaTypeInteger MAPC; /* Which Axis Corresponds to Columns */
195 mrcImageParaTypeInteger MAPR; /* Which Axis Corresponds to Rows */
196 mrcImageParaTypeInteger MAPS; /* Which Axis Corresponds to Sections */
197 mrcImageParaTypeReal AMin; /* Minimum Density Value */
198 mrcImageParaTypeReal AMax; /* Maximum Density Value */
199 mrcImageParaTypeReal AMean; /* Mean Density Value */
200 mrcImageParaTypeInteger ISPG; /* Space Group */
201 mrcImageParaTypeInteger NSYMBT; /* Number of bytes */
202 mrcImageParaTypeReal EXTRA[MRC_MAX_EXTRA]; /* Extra, user defined storage space */
203 mrcImageParaTypeReal OriginX;
204 mrcImageParaTypeReal OriginY;
205 mrcImageParaTypeInteger LabelN;
206 char Label[MRC_MAX_LABEL_N][MRC_MAX_LABEL_LEN];
209 /* For CCP4 2000 : Current New */
210 typedef struct _mrcImageHeaderCCP4 {
211 mrcImageParaTypeIntegerCoord N; /* Data Numbers */
212 mrcImageMode Mode; /* Data Type */
213 mrcImageParaTypeIntegerCoord StartN; /* First in map */
214 mrcImageParaTypeIntegerCoord NI; /* Number of Intervals */
215 mrcImageParaTypeRealCoord Length; /* Cell Dimensions : Angstrom */
216 mrcImageParaTypeReal Alpha; /* Cell Angle : Degree */
217 mrcImageParaTypeReal Beta;
218 mrcImageParaTypeReal Gamma;
219 mrcImageParaTypeInteger MAPC; /* Which Axis Corresponds to Columns */
220 mrcImageParaTypeInteger MAPR; /* Which Axis Corresponds to Rows */
221 mrcImageParaTypeInteger MAPS; /* Which Axis Corresponds to Sections */
222 mrcImageParaTypeReal AMin; /* Minimum Density Value */
223 mrcImageParaTypeReal AMax; /* Maximum Density Value */
224 mrcImageParaTypeReal AMean; /* Mean Density Value */
225 mrcImageParaTypeInteger ISPG; /* Space Group */
226 mrcImageParaTypeInteger NSYMBT; /* Number of bytes used for storing symmetry operators */
227 mrcImageParaTypeInteger LSKFLG; /* Flag for Skew transformation */
228 mrcImageParaTypeReal SKWMAT[9]; /* Skew matrix S */
229 mrcImageParaTypeReal SKWTRN[3]; /* Skew translation */
230 mrcImageParaTypeReal EXTRA[MRC_MAX_EXTRA_CCP4]; /* Extra, user defined storage space */
231 mrcImageParaTypeCharacter MAP[4];
232 mrcImageParaTypeInteger MARCHST;
233 mrcImageParaTypeReal ARMS;
234 mrcImageParaTypeInteger LabelN;
235 char Label[MRC_MAX_LABEL_N][MRC_MAX_LABEL_LEN];
236 } _mrcImageHeaderCCP4;
238 /* For IMOD: Current New */
239 typedef struct _mrcImageHeaderIMOD {
240 mrcImageParaTypeIntegerCoord N; /* Data Numbers */
241 mrcImageMode Mode; /* Data Type */
242 mrcImageParaTypeIntegerCoord StartN; /* First in map */
243 mrcImageParaTypeIntegerCoord M; /* Number of Intervals */
244 mrcImageParaTypeRealCoord Length; /* PixelSize=Len/M: Angstrom */
245 mrcImageParaTypeReal Alpha; /* Cell Angle : Degree */
246 mrcImageParaTypeReal Beta;
247 mrcImageParaTypeReal Gamma;
248 mrcImageParaTypeInteger MAPC; /* Which Axis Corresponds to Columns */
249 mrcImageParaTypeInteger MAPR; /* Which Axis Corresponds to Rows */
250 mrcImageParaTypeInteger MAPS; /* Which Axis Corresponds to Sections */
251 mrcImageParaTypeReal AMin; /* Minimum Density Value */
252 mrcImageParaTypeReal AMax; /* Maximum Density Value */
253 mrcImageParaTypeReal AMean; /* Mean Density Value */
254 mrcImageParaTypeInteger ISPG; /* Space Group */
255 mrcImageParaTypeInteger NSYMBT; /* Number of bytes used for extended header */
256 short creatid; /* Flag for Skew transformation */
257 short extra1[15]; /* Flag for Skew transformation */
259 short nreal; /*l Skew matrix S */
260 mrcImageParaTypeReal extra2[5]; /* Extra, user defined storage space */
261 mrcImageParaTypeInteger imodStamp;
262 mrcImageParaTypeInteger imodFlags;
269 mrcImageParaTypeReal tiltangles[6]; /* Extra, user defined storage space */
270 mrcImageParaTypeReal xorg; /* Extra, user defined storage space */
271 mrcImageParaTypeReal yorg; /* Extra, user defined storage space */
272 mrcImageParaTypeReal zorg; /* Extra, user defined storage space */
273 mrcImageParaTypeCharacter MAP[4];
274 mrcImageParaTypeInteger MARCHST;
275 mrcImageParaTypeReal ARMS;
276 mrcImageParaTypeInteger LabelN;
277 char Label[MRC_MAX_LABEL_N][MRC_MAX_LABEL_LEN];
278 } _mrcImageHeaderIMOD;
281 typedef union mrcImageHeader {
282 unsigned char All[MRC_HEADER];
283 mrcImageParaTypeInteger Int[MRC_HEADER/4];
284 mrcImageParaTypeReal Real[MRC_HEADER/4];
285 _mrcImageHeader Cont;
286 _mrcImageHeaderCCP4 ContCCP4;
287 _mrcImageHeaderIMOD ContIMOD;
291 #define FEI_EXTENDED_HEADER_EACH (128)
293 typedef struct _FEIextendedHeader {
294 mrcImageParaTypeReal aTilt; // Alpha tilt, in degrees
295 mrcImageParaTypeReal bTilt; // Beta tilt, in degrees
296 mrcImageParaTypeReal xStage; // Stage x position.
297 // Normally in SI units (meters),
298 // but some older files may be in micrometers.
299 // Check by looking at values for x,y,z.
300 // If one of these exceeds 1, it will be micrometers.
301 mrcImageParaTypeReal yStage; // Stage y position. For testing of units see x_stage.
302 mrcImageParaTypeReal zStage; // Stage z position. For testing of units see x_stage.
303 mrcImageParaTypeReal xShift; // Image shift x. For testing of units see x_stage.
304 mrcImageParaTypeReal yShift; // Image shift y. For testing of units see x_stage.
305 mrcImageParaTypeReal defocus;
306 mrcImageParaTypeReal expTime;
307 mrcImageParaTypeReal mean;
308 mrcImageParaTypeReal tiltAxis;
309 mrcImageParaTypeReal pixelSize;
310 mrcImageParaTypeReal magnification;
311 mrcImageParaTypeReal ht;
312 mrcImageParaTypeReal binning;
313 mrcImageParaTypeReal appliedDefocus;
314 mrcImageParaTypeReal reminder[FEI_EXTENDED_HEADER_EACH/4-16];
315 } _FEIextendedHeader;
317 typedef union FEIextendedHeader {
318 mrcImageParaTypeReal Real[FEI_EXTENDED_HEADER_EACH/4];
319 _FEIextendedHeader Cont;
329 #define mrcImageTailerMode2DProjection 0
333 typedef struct _mrcImageTailer {
335 mrcImageParaTypeInteger Mode;
336 char EulerAngleMode[4];
337 mrcImageParaTypeReal Rot1;
338 mrcImageParaTypeReal Rot2;
339 mrcImageParaTypeReal Rot3;
340 mrcImageParaTypeInteger Mirror;
344 typedef union mrcImageTailer {
345 unsigned char All[MRC_TAILER];
346 mrcImageParaTypeInteger Int[MRC_TAILER/4];
347 mrcImageParaTypeReal Real[MRC_TAILER/4];
348 _mrcImageTailer Cont;
352 typedef char mrcImageSymmetryOperator;
357 typedef struct mrcImage {
358 mrcImageHeader Header;
360 mrcImageParaTypeInteger BytePerBand;
361 mrcImageParaTypeInteger BandPerPixel;
362 size_t PixelPerImage;
363 mrcStatusType status;
365 unsigned char* ImageCharImage;
366 unsigned short* ImageShortImage;
367 unsigned long* ImageLongImage;
368 float* ImageFloatImage;
369 double* ImageDoubleImage;
372 mrcImageTailer* Tailer;
373 mrcImageParaTypeInteger numTailer;
375 /* FEIextendedHeader */
376 FEIextendedHeader* FEIHeader;
377 mrcImageParaTypeInteger numFEIHeader;
381 mrcImageParaTypeInteger dummyHeaderByte;
384 mrcImageParaTypeInteger flagByteSwap;
387 mrcImageParaTypeInteger flagCCP4;
388 mrcImageParaTypeInteger ImageOffset;
389 mrcImageSymmetryOperator* SymmetryOperator;
392 typedef struct mrcImageInformation {
394 double rootMeanSquare;
395 double meanOfSphereSurface;
396 double sdOfSphereSurface;
397 double seOfSphereSurface;
398 double meanOfCylinderSurface;
399 double sdOfCylinderSurface;
400 double seOfCylinderSurface;
405 mrcImageParaTypeRealCoord maxCoord;
407 mrcImageParaTypeRealCoord minCoord;
412 double RMS; /* Root mean square */
415 /* For Search Area */
430 } mrcImageInformation;
435 typedef enum mrcImageInformationMode {
437 meanOfSphereSurface = 1,
438 meanOfCylinderSurface = 2,
444 } mrcImageInformationMode;
449 #define HeaderN Header.Cont.N
450 #define HeaderMode Header.Cont.Mode
451 #define HeaderStartN Header.Cont.StartN
452 #define HeaderM Header.Cont.M
453 #define HeaderLength Header.Cont.Length
454 #define HeaderAlpha Header.Cont.Alpha
455 #define HeaderBeta Header.Cont.Beta
456 #define HeaderGamma Header.Cont.Gamma
457 #define HeaderMAPC Header.Cont.MAPC
458 #define HeaderMAPR Header.Cont.MAPR
459 #define HeaderMAPS Header.Cont.MAPS
460 #define HeaderAMin Header.Cont.AMin
461 #define HeaderAMax Header.Cont.AMax
462 #define HeaderAMean Header.Cont.AMean
463 #define HeaderISPG Header.Cont.ISPG
464 #define HeaderNSYMBT Header.Cont.NSYMBT
465 #define HeaderLSKFLG Header.ContCCP4.LSKFLG
466 #define HeaderEXTRA Header.Cont.EXTRA
467 #define HeaderOriginX Header.Cont.OriginX
468 #define HeaderOriginY Header.Cont.OriginY
469 #define HeaderLabelN Header.Cont.LabelN
470 #define HeaderLabel Header.Cont.Label
472 typedef enum mrcPixelDataType {
482 typedef enum mrcPixelDataHowToGet {
483 mrcPixelHowNearest = 0,
485 mrcPixelHowCubicConv,
487 } mrcPixelDataHowToGet;
492 typedef struct lmrcImageSmoothingInfo {
494 mrcImageParaTypeReal sx; /* Filter kernel size */
495 mrcImageParaTypeReal sy;
496 mrcImageParaTypeReal sz;
497 double sigma; /* for Lee-Sigma filter */
498 } lmrcImageSmoothingInfo;
500 typedef struct lmrcImageCVEInfo {
501 long sx; /* CVE domain size. */
502 long sy; /* Apr.30,1996 */
506 typedef struct lmrcImageTfunctionInfo {
507 long sx; /* Tfunction domain size. */
508 long sy; /* June 11,1996 */
510 } lmrcImageTfunctionInfo;
512 typedef struct lmrcImageHighlightInfo {
514 float Bias; /* May 1,1996 */
516 } lmrcImageHighlightInfo;
518 typedef struct lmrcImageLowPassFilterInfo
520 long mode; /* June 4,1996 */
522 } lmrcImageLowPassFilterInfo;
524 typedef struct lmrcImageHighPassFilterInfo
526 long mode; /* June 5,1996 */
529 float pathWindowHigh;
530 } lmrcImageHighPassFilterInfo;
532 typedef struct lmrcImageBandPassFilterInfo
534 long mode; /* June 5,1996 */
535 float hvl, hvh, wl, wh;
538 } lmrcImageBandPassFilterInfo;
541 /* Utility Routines */
545 /* prototype begin */
547 extern mrcStatusType mrcInit(mrcImage* mrc, char* filaname);
548 extern mrcStatusType mrcDefaultHeaderValueSet(mrcImage* mrc);
549 extern mrcStatusType mrcDefaultHeaderValueSetOnlyFixedValue(mrcImage* mrc);
550 extern mrcStatusType mrcHiddenDataSet(mrcImage* mrc, long mode);
551 extern void mrcImageFree(mrcImage* mrc, char* message);
553 extern void mrcTailerInit(mrcImage* mrc, long mode);
554 extern void mrcTailerCopy(mrcImage* dst, mrcImage* src, long mode);
555 /* mode 1: Tailer Memory Allocation */
557 extern mrcStatusType mrcFileReadGeneral (mrcImage* mrc, char* filename, char* type, char* message, long mode);
558 extern mrcStatusType mrcImageReadGeneral (mrcImage* mrc, char* filename, char* type, char* message, long mode);
559 extern mrcStatusType mrcHeaderReadGeneral(mrcImage* mrc, char* filename, char* type, char* message, long mode);
560 extern mrcStatusType mrcTailerReadGeneral(mrcImage* mrc, char* filename, char* type, char* message, long mode);
561 extern mrcStatusType mrcFileGeneralListPrint(FILE* fpt);
563 extern mrcStatusType mrcFileRead (mrcImage* mrc, char* filename, char* message, long mode);
564 extern mrcStatusType mrcImageRead (mrcImage* mrc, char* filename, char* message, long mode);
565 extern mrcStatusType mrcHeaderRead(mrcImage* mrc, char* filename, char* message, long mode);
566 extern mrcStatusType mrcTailerRead(mrcImage* mrc, char* filename, char* message, long mode);
568 extern mrcStatusType mrcFileReadFEIextendedMRC (mrcImage* mrc, char* filename, char* message, long mode);
569 extern mrcStatusType mrcImageReadFEIextendedMRC (mrcImage* mrc, char* filename, char* message, long mode);
570 extern mrcStatusType mrcHeaderReadFEIextendedMRC(mrcImage* mrc, char* filename, char* message, long mode);
571 extern mrcStatusType mrcTailerReadFEIextendedMRC(mrcImage* mrc, char* filename, char* message, long mode);
573 extern mrcStatusType mrcFileReadIMODextendedMRC (mrcImage* mrc, char* filename, char* message, long mode);
574 extern mrcStatusType mrcImageReadIMODextendedMRC (mrcImage* mrc, char* filename, char* message, long mode);
575 extern mrcStatusType mrcHeaderReadIMODextendedMRC(mrcImage* mrc, char* filename, char* message, long mode);
576 extern mrcStatusType mrcTailerReadIMODextendedMRC(mrcImage* mrc, char* filename, char* message, long mode);
578 extern int mrcImageByteSwap(mrcImage* mrc, long mode);
580 #define mrcFileWriteModeGet(x) BYTE4GETBYTE(x,0)
581 #define mrcImageWriteModeGet(x) BYTE4GETBYTE(x,1)
582 #define mrcHeaderWriteModeGet(x) BYTE4GETBYTE(x,2)
583 #define mrcTailerWriteModeGet(x) BYTE4GETBYTE(x,3)
585 #define mrcFileWriteMode_InfoPrint 1
586 #define mrcFileWriteMode_NoCallForStatData 2
588 extern mrcStatusType mrcFileWrite (mrcImage* mrc, char* filename, char* message, long mode);
589 extern mrcStatusType mrcImageWrite (mrcImage* mrc, char* filename, char* message, long mode);
590 extern mrcStatusType mrcHeaderWrite(mrcImage* mrc, char* filename, char* message, long mode);
591 extern mrcStatusType mrcTailerWrite(mrcImage* mrc, char* filename, char* message, long mode);
593 extern mrcStatusType mrcFileWriteLowerResolution(mrcImage* mrc, char* filename, char* message, long sample , long mode);
595 extern double mrcImageDataGetbyAU(mrcImage* mrc,
596 mrcImageParaTypeReal x /* Angstrom */,
597 mrcImageParaTypeReal y /* Angstrom */,
598 mrcImageParaTypeReal z /* Angstrom */,
600 mrcPixelDataType mode,
601 mrcPixelDataHowToGet how);
602 extern double mrcPixelDataGet(mrcImage* mrc,
603 mrcImageParaTypeReal x /* Pixel Unit */,
604 mrcImageParaTypeReal y /* Pixel Unit */,
605 mrcImageParaTypeReal z /* Pixel Unit */,
607 mrcPixelDataType mode,
608 mrcPixelDataHowToGet how);
610 static inline double mrcPixelDataGetFloatImage(mrcImage* img,
611 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z)
613 return img->ImageFloatImage[x + y*img->HeaderN.x + z*img->HeaderN.x*img->HeaderN.y];
616 static inline double mrcPixelDataGetFloatFTRe(mrcImage* fft,
617 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z)
619 return fft->ImageFloatImage[2*(x + y*(fft->HeaderN.x/2+1) + z*(fft->HeaderN.x/2+1)*fft->HeaderN.y)];
621 static inline double mrcPixelDataGetFloatFTIm(mrcImage* fft,
622 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z)
624 return fft->ImageFloatImage[2*(x + y*(fft->HeaderN.x/2+1) + z*(fft->HeaderN.x/2+1)*fft->HeaderN.y)+1];
627 /* in mrcImageSet.c */
628 extern void mrcInfoSet(mrcImage* mrc, FILE* fptIn, FILE* fptOut, mrcImageParaTypeInteger mode);
633 /* in mrcImageDataSet.c */
634 typedef enum mrcImageDataSetMode {
635 mrcImageDataSetModeCentre = 0,
636 mrcImageDataSetModeOrigin = 1
637 } mrcImageDataSetMode;
640 /* prototype begin */
641 extern void mrcImageDataSet(mrcImage* out,
643 mrcImageParaTypeReal x,
644 mrcImageParaTypeReal y,
645 mrcImageParaTypeReal z,
647 mrcImageDataSetMode mode);
650 extern double mrcImageDataSetbyAU(mrcImage* mrc,
651 mrcImageParaTypeReal x /* Angstrom */,
652 mrcImageParaTypeReal y /* Angstrom */,
653 mrcImageParaTypeReal z /* Angstrom */,
655 mrcPixelDataType mode);
656 extern double mrcPixelDataSet(mrcImage* mrc,
657 mrcImageParaTypeReal x /* Pixel Unit */,
658 mrcImageParaTypeReal y /* Pixel Unit */,
659 mrcImageParaTypeReal z /* Pixel Unit */,
661 mrcPixelDataType mode);
663 static inline void mrcPixelDataSetFloatImage(mrcImage* img,
664 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z, double data)
666 img->ImageFloatImage[x + y*img->HeaderN.x + z*img->HeaderN.x*img->HeaderN.y] = (float)data;
669 static inline void mrcPixelDataSetFloatFTRe(mrcImage* fft,
670 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z, double data)
672 fft->ImageFloatImage[2*(x + y*(fft->HeaderN.x/2+1) + z*(fft->HeaderN.x/2+1)*fft->HeaderN.y)] = (float)data;
675 static inline void mrcPixelDataSetFloatFTIm(mrcImage* fft,
676 mrcImageParaTypeInteger x, mrcImageParaTypeInteger y, mrcImageParaTypeInteger z, double data)
678 fft->ImageFloatImage[2*(x + y*(fft->HeaderN.x/2+1) + z*(fft->HeaderN.x/2+1)*fft->HeaderN.y)+1] = (float)data;
682 extern void mrcStatDataSet(mrcImage* mrc, mrcImageParaTypeInteger mode);
686 /* in mrcImageInfo.c */
687 extern void lmrcImageXSection(mrcImage* proj, mrcImage* img, double Y);
688 extern void lmrcImageYSection(mrcImage* proj, mrcImage* img, double X);
689 extern void lmrcImageXProjection(mrcImage* proj, mrcImage* img);
690 extern void lmrcImageYProjection(mrcImage* proj, mrcImage* img);
691 extern void lmrcImageZProjection(mrcImage* proj, mrcImage* img);
692 extern void lmrcImageXYProjection(mrcImage* proj, mrcImage* img);
693 extern void lmrcImageYZProjection(mrcImage* proj, mrcImage* img);
694 extern void lmrcImageZXProjection(mrcImage* proj, mrcImage* img);
696 /* Frequecy max -> 1 */
697 extern void lmrcImageHistgram(double** hist, unsigned long nlevel, mrcImage* img);
698 extern void lmrcImageHistgram2(double** hist, double delta, mrcImage* img);
699 extern void lmrcImageHistgram5(double** hist, unsigned long nlevel, double Low, double High, mrcImage* img);
701 extern void lmrcImageHistgram3(double** hist, unsigned long nlevel, mrcImage* img);
702 extern void lmrcImageHistgram4(double** hist, double delta, mrcImage* img);
703 extern void lmrcImageHistgram6(double** hist, unsigned long nlevel, double Low, double High, mrcImage* img);
704 extern void lmrcImageInformation(mrcImageInformation* info, mrcImage* img);
707 /* in mrcImageCopy.c */
708 extern void lmrcImageCopy(mrcImage* dst, mrcImage* src, mrcImageParaTypeRealCoord to);
711 extern int IsFloatImage(mrcImage* mrc, char* message, mrcImageParaTypeInteger mode);
712 extern int IsFloatFT(mrcImage* mrc, char* message, mrcImageParaTypeInteger mode);
713 extern int IsImage(mrcImage* mrc, char* message, mrcImageParaTypeInteger mode);
714 extern int IsFT(mrcImage* mrc, char* message, mrcImageParaTypeInteger mode);
715 extern int IsFFT(mrcImage* mrc, char* message, mrcImageParaTypeInteger mode);
716 extern void mrcImageInfoSet(mrcImage* mrc, FILE* fptIn, FILE* fptOut, long mode);
718 /* in mrcImageOperation.c */
719 extern void lmrcImageDividedByImage(mrcImage* img, mrcImage* i1, mrcImage* i2);
720 extern void lmrcImagetMapForZero(mrcImage* t, mrcImage* avg, mrcImage* se);
721 extern void lmrcImageSN(mrcImage* sn, mrcImage* avg, mrcImage* sig);
722 extern void lmrcImageDividedByReal(mrcImage* img, double d);
723 extern void lmrcImageDividedByRealForOnlyPositive(mrcImage* img, double d);
724 extern void lmrcImageAddedByReal(mrcImage* img, double d);
725 extern void lmrcImageStdDev(mrcImage* sig, mrcImage* avg, mrcImage* avg2, long num);
726 extern void lmrcImageStdErr(mrcImage* sig, mrcImage* avg, mrcImage* avg2, long num);
727 extern void lmrcImageAdd(mrcImage* img2, mrcImage* img1, long* num);
728 extern void lmrcSQRImageAdd(mrcImage* img2, mrcImage* img1, long* num);
729 extern void lmrcImageSquare(mrcImage* in);
730 extern void lmrcImageRoot(mrcImage* in ,double eps);
731 extern void lmrcImageAbs(mrcImage* out, mrcImage* in);
732 extern void lmrcImageConvolution(mrcImage* out, mrcImage* in, mrcImage* kernel, int mode);
734 /* in mrcImageToIntImage.c */
735 extern void lmrcImageToIntImage(mrcImage* dst, mrcImage* src, mrcImageParaTypeInteger mode);
738 extern void lfft2d(mrcImage* fft, mrcImage* img);
740 extern void lmrcImageFFT(mrcImage* fft, mrcImage* img, long mode);
741 extern void lmrcImageFFTFirstDimensionOnly(mrcImage* fft, mrcImage* img, long mode);
743 extern void lmrcImageFFTWFlagSet(unsigned int flag);
745 extern void lmrcFFTFGconj(mrcImage* out, mrcImage* in1, mrcImage* in2);
746 extern void lmrcFFTFxG(mrcImage* out, mrcImage* in1, mrcImage* in2);
747 extern void lmrcImageCorrelation(mrcImage* out, mrcImage* in, mrcImage* ref, long mode);
748 extern void lmrcImageCorrelationModePrint(FILE* fpt);
751 extern void lmrcImageCorrelationWithCTFCompensation(mrcImage* out, mrcImage* in, ctfInfo* inctf, mrcImage* ref, ctfInfo* refctf, long mode);
755 extern mrcStatusType mrcError(char* message, char* inRtnName, char* callRtnName, mrcStatusType status);
756 extern mrcStatusType mrcErrorMsg(FILE* fpt, char* message, char* inRtnName, char* callRtnName, mrcStatusType status);
757 /* in lmrcFFTInfo.c */
759 extern floatVector* lmrcFSInfoXAxisMag(mrcImage* fft);
760 extern floatVector* lmrcFSInfoXAxisPhase(mrcImage* fft);
761 extern floatVector* lmrcFSInfoYAxisMag(mrcImage* fft);
762 extern floatVector* lmrcFSInfoYAxisPhase(mrcImage* fft);
763 /* The returned values are not magnitudes but powers */
764 extern floatVector* lmrcFSInfoScatteringAngularDistribution(mrcImage* fft);
765 extern floatVector* lmrcFSInfoScatteringAngularDistributionAverage(mrcImage* fft);
766 extern floatVector* lmrcFSInfoScatteringAngularDistributionSD(mrcImage* fft);
767 extern floatVector* lmrcFSInfoSpacing(mrcImage* fft);
769 /* in mrcImageCheckSameSize.c */
770 extern void lmrcImageCheckSameSize(mrcImage* in, mrcImage* ref);
772 /* in mrcImageCheckFFT.c */
773 extern void lmrcImageCheckFFT(mrcImage* in, mrcImage* ref);
775 /* in lmrcImageSmoothing */
776 extern void lmrcImageSmoothingModeInfo(FILE* fpt);
777 extern void lmrcImageSmoothing(mrcImage* dst, mrcImage* src, lmrcImageSmoothingInfo* info, long mode);
779 /* in lmrcImageCVE */
780 extern void lmrcImageCVE(mrcImage* dst, mrcImage* src, lmrcImageCVEInfo* info);
782 /* in lmrcImageTfunction */
783 extern void lmrcImageTfunction(mrcImage* dst, mrcImage* src, lmrcImageTfunctionInfo* info, long mode);
785 /* in lmrcImageHighlighting */
786 extern void lmrcImageHighlightingInfoPrint(FILE* fpt);
787 extern void lmrcImageHighlighting(mrcImage* dst, mrcImage* src, lmrcImageHighlightInfo* info);
789 /* in lmrcImageLowPassFilter */
790 extern void lmrcImageLowPassFilter(mrcImage* dst, mrcImage* src, lmrcImageLowPassFilterInfo* info, long mode);
792 /* in lmrcImageHighPassFilter */
793 extern void lmrcImageHighPassFilter(mrcImage* dst, mrcImage* src, lmrcImageHighPassFilterInfo* info, long mode);
795 /* in lmrcImageBandPassFilter */
796 extern void lmrcImageBandPassFilter(mrcImage* dst, mrcImage* src, lmrcImageBandPassFilterInfo* info, long mode);
798 /* in lmrcImageShrink */
799 extern void lmrcImageShrink(mrcImage* dst, mrcImage* src, mrcImageParaTypeIntegerCoord S, long mode);
801 /* in lmrcImageShift */
802 extern void lmrcImageShift(mrcImage* out, mrcImage* in, mrcImageParaTypeRealCoord shift, mrcPixelDataHowToGet mode);
803 extern void lmrcImageShiftFollowingGC(mrcImage* out, mrcImage* in, int mode);
805 /* in mrcImagePrint */
806 extern void mrcInfoPrint(FILE* fpt, mrcImage* mrc, mrcImageParaTypeInteger mode);
811 /* in lmrcImageMultiCTFCompensation.c */
814 typedef enum lmrcImageMultiCTFCompensationSolventFlatteningMode {
815 lmrcImageMultiCTFCompensationSolventFlatteningModeDensityPeakIsSolvent=0,
816 lmrcImageMultiCTFCompensationSolventFlatteningModeDefinedSTDIsSolvent=1
817 } lmrcImageMultiCTFCompensationSolventFlatteningMode;
819 typedef struct lmrcImageMultiCTFCompensationInfo {
826 lmrcImageMultiCTFCompensationSolventFlatteningMode solventMode;
828 } lmrcImageMultiCTFCompensationInfo;
833 /* prototype begin */
835 extern void lmrcImageMultiCTFCompensationInfoInit(lmrcImageMultiCTFCompensationInfo* info);
836 extern void lmrcImageMultiCTFCompensationInfoSet(lmrcImageMultiCTFCompensationInfo* info);
837 extern void lmrcImageMultiCTFCompensation(mrcImage* dst, mrcImage* src, ctfInfo* ctf, long nfile, lmrcImageMultiCTFCompensationInfo info, long mode);
839 /* in lmrcImageCTFObservation.c */
840 extern void lmrcImageCTFObservation(mrcImage* dst, mrcImage* src, ctfInfo* ctf, long mode);
841 extern void lmrcImagesCTFObservation(mrcImage* dst, mrcImage* src, ctfInfo* ctf, long mode);
843 /* in lmrcImageCTFCompensation.c */
844 extern void lmrcImageCTFCompensation(mrcImage* src, ctfInfo* ctf, long mode);
849 /* in lmrcImageCTFSN.c */
851 typedef struct lmrcImageCTFSNInfo
853 long mode, deg1, deg2;
855 } lmrcImageCTFSNInfo;
858 /* prototype begin */
859 extern void lmrcImageCTFSN(mrcImage *outMrc, const mrcImage *inMrc, lmrcImageCTFSNInfo *info, long mode);
862 /* in lmrcImageFourierPowerSpectrum.c */
864 typedef struct mrcImageFourierPowerSpectrum
868 } mrcImageFourierPowerSpectrum;
870 typedef struct lmrcImageFourierPowerSpectrumInfo
873 } lmrcImageFourierPowerSpectrumInfo;
876 /* prototype begin */
878 extern mrcImageFourierPowerSpectrum lmrcImageFourierPowerSpectrumMakeSpectrum(const mrcImage *inFFT, lmrcImageFourierPowerSpectrumInfo *info);
879 extern void lmrcImageFourierPowerSpectrumDeleteSpectrum(mrcImageFourierPowerSpectrum theSpectrum);
880 extern mrcImageFourierPowerSpectrum lmrcImageFourierPowerSpectrum(const mrcImage *inMrc, lmrcImageFourierPowerSpectrumInfo *info, long mode);
882 extern void lmrcImageRotation3DModePrint(FILE* fpt);
883 extern void lmrcImageRotation3DFollowingEulerAngle(mrcImage* dst, mrcImage* src, const char* m,
884 mrcImageParaTypeReal rot1, mrcImageParaTypeReal rot2, mrcImageParaTypeReal rot3, mrcPixelDataHowToGet mode, int mode2);
886 #include "Matrix3D.h"
887 extern void lmrcImageRotation3DFollowingMatrix3D(mrcImage* dst, mrcImage* src, Matrix3D mat, mrcPixelDataHowToGet mode, int mode2);
889 extern void lmrcImageRotation3DZXY(mrcImage* dst, mrcImage* src,
890 mrcImageParaTypeReal rotx, mrcImageParaTypeReal roty, mrcImageParaTypeReal rotz, mrcPixelDataHowToGet mode, int mode2);
892 extern void lmrcImageRotation2D(mrcImage* dst, mrcImage* src, double angle, mrcPixelDataHowToGet mode);
893 extern void lmrcImageRotation2DPeriodicBoundary(mrcImage* dst, mrcImage* src, double angle, mrcPixelDataHowToGet mode);
895 /* in mrcImageSectionGet.c */
896 extern char* mrcImageSectionGetModeDescription(long mode);
897 extern void mrcImageSectionGet(mrcImage* dst, mrcImage* src, mrcImageParaTypeReal z, long mode);
899 /* in mrcImageSectionSet.c */
900 extern void mrcImageSectionSet(mrcImage* dst, mrcImage* src, mrcImageParaTypeReal z, long mode);
903 extern double lmrcImageMaxDataGet(mrcImage* src, long mode);
911 #endif /* MRC_IMAGE_H */