massspec/structelem.h
00001 
#ifndef _STRUCTELEM_H_
00002 
#define _STRUCTELEM_H_
00003 
00004 
00005 
00006 
00007 
00008 
00009 
typedef struct
00010 
{
00011         
int**                   matrix;
00012         
Peak2i                  center;
00013         Dimensions2i    dim;
00014         
int                             sum;
00015 } StructElem;
00016 
00017 
int             StructElem_create(StructElem* SE, 
char* name, 
int center_scan, 
int center_bin);
00018 
void    StructElem_init(StructElem* SE);
00019 
int             isStructElemValid(
char* se);
00020 
00021 
#define INIT_STRUCTURING_ELEMENT(se)\
00022 
        int ii, jj, k, l;\
00023 
        Peak2i neigh;\
00024 
        StructElem SE;\
00025 
        if(!StructElem_create(&SE, se, -1, -1))\
00026 
        {\
00027 
                fprintf(stderr, "INIT_STRUCTURING_ELEMENT: Error! Illegal structuring element string %s\n", se);\
00028 
                exit(1);\
00029 
        }
00030 
00031 
00032 
00033 
#define DESTROY_STRUCTURING_ELEMENT()                                                                                           \
00034 
        free_imatrix(SE.matrix, 1, SE.dim.SCAN_SIZE, 1, SE.dim.BIN_SIZE);
00035 
00036 
00037 
#define FOR_ALL_POINTS_IN_STRUCTURING_ELEMENT(MAP, point)                                                                       \
00038 
        k = 1;                                                                                                                                                  \
00039 
        for(ii = 1 - SE.center.rt_i; ii <= SE.dim.SCAN_SIZE - SE.center.rt_i; ii++)             \
00040 
        {                                                                                                                                                               \
00041 
                l = 1;                                                                                                                                          \
00042 
                for(jj = 1 - SE.center.mz_j; jj <= SE.dim.BIN_SIZE - SE.center.mz_j; jj++)      \
00043 
                {                                                                                                                                                       \
00044 
                        neigh = Peak2i_new(point.rt_i+ii, point.mz_j+jj);                                               \
00045 
                        if(isPointWithinRect(MAP->dim, neigh.rt_i, neigh.mz_j) &&                               \
00046 
                           SE.matrix[k][l] == 1)                                                                                                \
00047 
                        {
00048 
00049 
#define FOR_ALL_POINTS_IN_STRE_AND_MESH(mesh, point)                                                                    \
00050 
        k = 1;                                                                                                                                                  \
00051 
        for(ii = 1 - SE.center.rt_i; ii <= SE.dim.SCAN_SIZE - SE.center.rt_i; ii++)             \
00052 
        {                                                                                                                                                               \
00053 
                l = 1;                                                                                                                                          \
00054 
                for(jj = 1 - SE.center.mz_j; jj <= SE.dim.BIN_SIZE - SE.center.mz_j; jj++)      \
00055 
                {                                                                                                                                                       \
00056 
                        neigh = Peak2i_new(point.rt_i+ii, point.mz_j+jj);                                               \
00057 
                        if(Mesh2D_isPointInside(mesh, neigh.rt_i, neigh.mz_j) &&                                \
00058 
                           SE.matrix[k][l] == 1)                                                                                                \
00059 
                        {
00060 
00061 
00062 
#define END_FOR                                                         \
00063 
                        }                                                               \
00064 
                        l++;                                                    \
00065 
                }                                                                       \
00066 
                k++;                                                            \
00067 
        }       
00068 
00069 
#endif
00070 
00071 
Generated on Sun Feb 13 01:05:59 2005 for MapQuant by
 1.3.7