Return a boolean status (true: interpolation is OK) and the interpolated value for a pixel, ignoring pixels given by badmask.
2131 {
2132#if defined(SDSS)
2133 BADCOLUMN defect;
2135 int i;
2136 int i0, i1;
2137
2138 int ndata;
2139 static int ndatamax = 40;
2140 int nrow, ncol;
2142 int z1, z2;
2143
2144 shAssert(badmask != NULL && badmask->type == shTypeGetFromName("OBJMASK"));
2145 shAssert(reg != NULL && reg->type == TYPE_PIX);
2146 nrow = reg->nrow;
2147 ncol = reg->ncol;
2148
2149 if (horizontal) {
2150 for (z1 = colc - 1; z1 >= 0; z1--) {
2151 if (!phPixIntersectMask(badmask, z1, rowc)) {
2152 break;
2153 }
2154 }
2155 z1++;
2156
2157 for (z2 = colc + 1; z2 < ncol; z2++) {
2158 if (!phPixIntersectMask(badmask, z2, rowc)) {
2159 break;
2160 }
2161 }
2162 z2--;
2163
2164 i0 = (z1 > 2) ? z1 - 2 : 0;
2165 i1 = (z2 < ncol - 2) ? z2 + 2 : ncol - 1;
2166
2167 if (i0 < 2 || i1 >= ncol - 2) {
2168 return (-1);
2169 }
2170
2171 ndata = (i1 - i0 + 1);
2172 if (ndata > ndatamax) {
2173 return (-1);
2174 }
2175
2176 data = alloca(ndata *
sizeof(PIX));
2177 for (i = i0; i <= i1; i++) {
2178 data[i - i0] = reg->ROWS[rowc][i];
2179 }
2181 } else {
2182 for (z1 = rowc - 1; z1 >= 0; z1--) {
2183 if (!phPixIntersectMask(badmask, colc, z1)) {
2184 break;
2185 }
2186 }
2187 z1++;
2188
2189 for (z2 = rowc + 1; z2 < nrow; z2++) {
2190 if (!phPixIntersectMask(badmask, colc, z2)) {
2191 break;
2192 }
2193 }
2194 z2--;
2195
2196 i0 = (z1 > 2) ? z1 - 2 : 0;
2197 i1 = (z2 < nrow - 2) ? z2 + 2 : nrow - 1;
2198
2199 if (i0 < 2 || i1 >= ncol - 2) {
2200 return (-1);
2201 }
2202
2203 ndata = (i1 - i0 + 1);
2204 if (ndata > ndatamax) {
2205 return (-1);
2206 }
2207
2208 data = alloca(ndata *
sizeof(PIX));
2209 for (i = i0; i <= i1; i++) {
2210 data[i - i0] = reg->ROWS[i][colc];
2211 }
2213 }
2214
2215 defect.x1 = z1 - i0;
2216 defect.x2 = z2 - i0;
2217 classify_defects(&defect, 1, ndata);
2218 do_defect(&defect, 1,
data, ndata, minval);
2219
2221#endif
2222
2224}