Changeset 10136 for trunk/psLib/src/imageops/psImageUnbin.c
- Timestamp:
- Nov 22, 2006, 4:26:07 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageUnbin.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageUnbin.c
r7766 r10136 50 50 for (int ix = Xs; (ix < Xe) && (ix < Nx); ix++) { 51 51 vOut[iy][ix] = V; 52 //assert (fabs(V - psImageUnbinPixel(ix, iy, in, DX, DY, dx, dy)) < 1e-5*fabs(V)); 52 53 V += dV; 53 54 } … … 161 162 return out; 162 163 } 164 165 /************************************************************************************************************/ 166 /* 167 * Get the value of a single unbinned pixel from the binned representation 168 * 169 * N.b. This code only works for the central part of the image; the edge 170 * cases should be added 171 */ 172 double psImageUnbinPixel(const int ix, const int iy, // desired Unbinned point 173 const psImage *in, // binned image 174 const int DX, const int DY, //!< Scaling factors in x and y 175 const int dx, const int dy) //!< Overhang 176 { 177 PS_ASSERT_IMAGE_NON_NULL(in, NAN); 178 assert (in->type.type == PS_TYPE_F32); 179 PS_ASSERT_INT_POSITIVE(DX, NAN); 180 PS_ASSERT_INT_POSITIVE(DY, NAN); 181 PS_ASSERT_INT_NONNEGATIVE(dx, NAN); 182 PS_ASSERT_INT_NONNEGATIVE(dy, NAN); 183 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dx, DX, NAN); 184 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dy, DY, NAN); 185 /* 186 * Find which binned pixel we're in 187 */ 188 const int Ix = (ix + dx)/DX - 1; // index of binned pixel 189 const int Iy = (iy + dy)/DY - 1; 190 191 if (Ix < 0 || Ix >= in->numCols - 1 || Iy < 0 || Iy >= in->numRows - 1) { 192 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Point (%d,%d) lies outside binned image", ix, iy); 193 return NAN; 194 } 195 196 double V00 = in->data.F32[Iy+0][Ix+0]; 197 double V01 = in->data.F32[Iy+0][Ix+1]; 198 double V10 = in->data.F32[Iy+1][Ix+0]; 199 double V11 = in->data.F32[Iy+1][Ix+1]; 200 201 const int Xs = (Ix + 1)*DX - dx; // centre of bottom left corner of binned pixel 202 const int Ys = (Iy + 1)*DY - dy; // (i.e. [Iy][Ix]) in unbinned coordinates 203 204 const double Vxs = (V10 - V00)*(iy - Ys)/DY + V00; 205 const double Vxe = (V11 - V01)*(iy - Ys)/DY + V01; 206 207 return Vxs + (Vxe - Vxs)*(ix - Xs)/DX; // value at [iy][ix] 208 }
Note:
See TracChangeset
for help on using the changeset viewer.
