⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 epr_band.c

📁 Insar图像处理软件
💻 C
📖 第 1 页 / 共 5 页
字号:
                                int step_x,                                 void* raster_buffer,                                int raster_pos){    int x, x1, x2;    uchar* sa = (uchar*) source_array;       float* buf = (float*) raster_buffer;     x1 = offset_x;    x2 = x1 + raster_width - 1;    if (band_id->scaling_method == e_smid_log) {       for (x = x1; x <= x2; x += step_x)  {           buf[raster_pos++] = (float)pow(10, band_id->scaling_offset + band_id->scaling_factor * (sa[2 * x] & 0xff));       }    } else if (band_id->scaling_method == e_smid_lin){       for (x = x1; x <= x2; x += step_x)  {           buf[raster_pos++] = band_id->scaling_offset + band_id->scaling_factor * (sa[2 * x] & 0xff);       }    } else {       for (x = x1; x <= x2; x += step_x)  {           buf[raster_pos++] = (float)(sa[2 * x] & 0xff);       }    }}void decode_line_uchar_2_of_2_to_float(void* source_array,                                EPR_SBandId* band_id,                                 int offset_x,                                 int raster_width,                                 int step_x,                                 void* raster_buffer,                                int raster_pos){    int x, x1, x2;    uchar* sa = (uchar*) source_array;       float* buf = (float*) raster_buffer;     x1 = offset_x;    x2 = x1 + raster_width - 1;    if (band_id->scaling_method == e_smid_log) {       for (x = x1; x <= x2; x += step_x) {           buf[raster_pos++] = (float)pow(10, band_id->scaling_offset + band_id->scaling_factor * (sa[2 * x + 1] & 0xff));       }    } else if (band_id->scaling_method == e_smid_lin){       for (x = x1; x <= x2; x += step_x)  {           buf[raster_pos++] = band_id->scaling_offset + band_id->scaling_factor * (sa[2 * x + 1] & 0xff);       }    } else {       for (x = x1; x <= x2; x += step_x)  {           buf[raster_pos++] = (float)(sa[2 * x + 1] & 0xff);       }    }}void decode_line_uchar_3_to_i_to_ulong(void* source_array,                                EPR_SBandId* band_id,                                 int offset_x,                                 int raster_width,                                 int step_x,                                 void* raster_buffer,                                int raster_pos){    int x, x1, x2, n;    uchar* sa = (uchar*) source_array;       ulong* buf = (ulong*) raster_buffer;     x1 = offset_x;    x2 = x1 + raster_width - 1;    for (x = x1; x <= x2; x += step_x)  {        n = 3 * x;        buf[raster_pos++] = (sa[n] & 0xff) | ((sa[n+1] & 0xff) << 8) | ((sa[n+2] & 0xff) << 16);    }}/** * Computes the physical values for the annotation data. * * @param sa_beg the float array of tie points "before" Y-coordinate of the point to search * @param sa_end the float array of tie points "after" Y-coordinate of the point to search * @param samples_per_tie_pt the "distance" between two neighbour tie points (in scan-line direction) * @param num_elems number of elements in one tie point scan-line * @param band_id the information about properties and quantities of ENVISAT data. * @param offset_x [PIXEL] X-coordinate (0-based) of the upper right raster corner to search * @param y_mod [PIXEL] relative location of the point is being searched for (in flight direction) * @param raster_width [PIXEL] the width of the raster is being searched for * @param s_x [PIXEL] X-step to get the next point (in source coordinates) to search * @param raster_buffer the float user array to be filled with physical values * @param raster_pos the actual "filled" position in raster_buffer-array * */void decode_tiepoint_band(float* sa_beg,                           float* sa_end,                          ulong samples_per_tie_pt,                          uint num_elems,                          EPR_SBandId* band_id,                           int offset_x,                           float scan_offset_x,                          float y_mod,                          int raster_width,                           int s_x,                           float* raster_buffer,                           int raster_pos) {     int ix;    float x_mod;    uint x_knot;    int longi_flag = 0;    int intersection = 0;    float circle;    float half_circle;     float null_point;    circle = EPR_LONGI_ABS_MAX - EPR_LONGI_ABS_MIN;    half_circle = 0.5F * circle;     null_point = 0.5F * (EPR_LONGI_ABS_MAX + EPR_LONGI_ABS_MIN);    if (strncmp(band_id->band_name, EPR_LONGI_BAND_NAME, strlen(EPR_LONGI_BAND_NAME)) == 0){        longi_flag = 1;    } else {        longi_flag = 0;    }    for (ix = offset_x; ix < offset_x + raster_width; ix += s_x) {        x_mod = (ix - scan_offset_x) / samples_per_tie_pt;        if (x_mod >= 0.0F){            x_knot = (uint)floor(x_mod);            if (x_knot >= num_elems - 1) {				x_knot = num_elems - 2;			}        } else {            x_knot = (uint)0;        }        x_mod -= x_knot;        if (longi_flag == 1) {            if (fabs((float)(sa_beg[x_knot + 1] - sa_beg[x_knot])) > half_circle ||                fabs((float)(sa_beg[x_knot] - sa_end[x_knot])) > half_circle ||                fabs((float)(sa_end[x_knot] - sa_end[x_knot + 1])) > half_circle ||                fabs((float)(sa_end[x_knot + 1] - sa_beg[x_knot + 1])) > half_circle) {                intersection = 1;                if (sa_beg[x_knot] < (float)null_point) {                    sa_beg[x_knot] += circle;                }                if (sa_beg[x_knot + 1] < (float)null_point) {                    sa_beg[x_knot + 1] += circle;                }                if (sa_end[x_knot] < (float)null_point) {                    sa_end[x_knot] += circle;                }                if (sa_end[x_knot + 1] < (float)null_point) {                    sa_end[x_knot + 1] += circle;                }            }        } else {            intersection = 0;        }        raster_buffer[raster_pos] = epr_interpolate2D(x_mod, y_mod,                                                      sa_beg[x_knot], sa_beg[x_knot + 1],                                                      sa_end[x_knot], sa_end[x_knot + 1]);        if (longi_flag == 1 &&             intersection == 1 &&             raster_buffer[raster_pos] > EPR_LONGI_ABS_MAX) {            raster_buffer[raster_pos] -= circle;        }        raster_pos++;    }}float epr_interpolate2D(float wi, float wj, float x00, float x10, float x01, float x11){    return x00 + wi * (x10 - x00) + wj * (x01 - x00) + wi * wj * (x11 + x00 - x01 - x10);}void transform_array_short_to_float (void* sourceArray,                                      EPR_SBandId* band_id,                                       float* raster_buffer,                                     uint nel){    uint ix;    short* sa = (short*) sourceArray;      for (ix = 0; ix < nel; ix ++) {       raster_buffer[ix] = band_id->scaling_offset + band_id->scaling_factor * sa[ix];   }}void transform_array_ushort_to_float (void* sourceArray,                                      EPR_SBandId* band_id,                                       float* raster_buffer,                                     uint nel){    uint ix;    ushort* sa = (ushort*) sourceArray;      for (ix = 0; ix < nel; ix ++) {       raster_buffer[ix] = band_id->scaling_offset + band_id->scaling_factor * sa[ix];   }}void transform_array_long_to_float (void* sourceArray,                                      EPR_SBandId* band_id,                                       float* raster_buffer,                                     uint nel){    uint ix;    long* sa = (long*) sourceArray;      for (ix = 0; ix < nel; ix ++) {       raster_buffer[ix] = band_id->scaling_offset + band_id->scaling_factor * sa[ix];   }}void transform_array_ulong_to_float (void* sourceArray,                                      EPR_SBandId* band_id,                                       float* raster_buffer,                                     uint nel){    uint ix;    ulong* sa = (ulong*) sourceArray;      for (ix = 0; ix < nel; ix ++) {       raster_buffer[ix] = band_id->scaling_offset + band_id->scaling_factor * sa[ix];   }}void mirror_float_array(float* raster_buffer, uint raster_width, uint raster_height){    uint w, h, pol_w, offset;    float tmp;    pol_w = raster_width / 2;    for (h = 0; h < raster_height; h ++) {        for (w = 0; w < pol_w; w ++) {            offset = h * raster_width;            tmp = raster_buffer[w + offset];            raster_buffer[w + offset] = raster_buffer[raster_width - 1 - w + offset];            raster_buffer[raster_width - 1 - w + offset] = tmp;        }    }}void mirror_uchar_array(uchar* raster_buffer, uint raster_width, uint raster_height){    uint w, h, pol_w, offset;    uchar tmp;    pol_w = raster_width / 2;    for (h = 0; h < raster_height; h ++) {        for (w = 0; w < pol_w; w ++) {            offset = h * raster_width;            tmp = raster_buffer[w + offset];            raster_buffer[w + offset] = raster_buffer[raster_width - 1 - w + offset];            raster_buffer[raster_width - 1 - w + offset] = tmp;        }    }}void mirror_ushort_array(ushort* raster_buffer, uint raster_width, uint raster_height){    uint w, h, pol_w, offset;    ushort tmp;    pol_w = raster_width / 2;    for (h = 0; h < raster_height; h ++) {        for (w = 0; w < pol_w; w ++) {            offset = h * raster_width;            tmp = raster_buffer[w + offset];            raster_buffer[w + offset] = raster_buffer[raster_width - 1 - w + offset];            raster_buffer[raster_width - 1 - w + offset] = tmp;        }    }}void mirror_ulong_array(ulong* raster_buffer, uint raster_width, uint raster_height){    uint w, h, pol_w, offset;    ulong tmp;    pol_w = raster_width / 2;    for (h = 0; h < raster_height; h ++) {        for (w = 0; w < pol_w; w ++) {            offset = h * raster_width;            tmp = raster_buffer[w + offset];            raster_buffer[w + offset] = raster_buffer[raster_width - 1 - w + offset];            raster_buffer[raster_width - 1 - w + offset] = tmp;        }    }}void epr_zero_invalid_pixels(EPR_SRaster* raster, EPR_SRaster* bm_raster) {    uchar* bm_pixels;    uint bm_pos = 0;    uint bm_len = raster->raster_width * raster->raster_height;    assert(bm_raster->data_type == e_tid_char            || bm_raster->data_type == e_tid_uchar);    bm_pixels = (uchar*) bm_raster->buffer;    switch (raster->data_type) {    case e_tid_char:    case e_tid_uchar: {            char* pixels = (char*) raster->buffer;             for (bm_pos = 0; bm_pos < bm_len; bm_pos++) {                if (bm_pixels[bm_pos] == 0) {                    pixels[bm_pos] = 0;                }            }        }        break;    case e_tid_short:    case e_tid_ushort: {            short* pixels = (short*) raster->buffer;             for (bm_pos = 0; bm_pos < bm_len; bm_pos++) {                if (bm_pixels[bm_pos] == 0) {                    pixels[bm_pos] = 0;                }            }        }        break;    case e_tid_long:    case e_tid_ulong: {            long* pixels = (long*) raster->buffer;             for (bm_pos = 0; bm_pos < bm_len; bm_pos++) {                if (bm_pixels[bm_pos] == 0) {                    pixels[bm_pos] = 0;                }            }        }        break;    case e_tid_float: {            float* pixels = (float*) raster->buffer;             for (bm_pos = 0; bm_pos < bm_len; bm_pos++) {                if (bm_pixels[bm_pos] == 0) {                    pixels[bm_pos] = 0.0F;                }            }        }        break;    case e_tid_double: {            double* pixels = (double*) raster->buffer;             for (bm_pos = 0; bm_pos < bm_len; bm_pos++) {                if (bm_pixels[bm_pos] == 0) {                    pixels[bm_pos] = 0.0;                }            }        }        break;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -