Changeset 5214 for trunk/psLib/src/types
- Timestamp:
- Sep 30, 2005, 2:14:17 PM (21 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
-
psPixels.c (modified) (20 diffs)
-
psPixels.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psPixels.c
r5137 r5214 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $10 * @date $Date: 2005- 09-26 22:35:53$9 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-10-01 00:14:17 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 33 33 // for use by qsort, etc. 34 static int comparePixelCoord(psPixelCoord* coord1, psPixelCoord* coord2) 34 static int comparePixelCoord(psPixelCoord* coord1, 35 psPixelCoord* coord2) 35 36 { 36 37 // check row first … … 79 80 80 81 81 psPixels* psPixelsRealloc(psPixels* pixels, long nalloc) 82 psPixels* psPixelsRealloc(psPixels* pixels, 83 long nalloc) 82 84 { 83 85 if (pixels == NULL) { … … 101 103 } 102 104 103 psPixels* p_psPixelsAppend(psPixels* pixels, long growth, int x, int y) 105 psPixels* p_psPixelsAppend(psPixels* pixels, 106 long growth, 107 float x, 108 float y) 104 109 { 105 110 if (growth < 1) { … … 111 116 } 112 117 113 intn = pixels->n;118 long n = pixels->n; 114 119 115 120 pixels->data[n].x = x; … … 121 126 } 122 127 123 psPixels* psPixelsCopy(psPixels* out, const psPixels* pixels) 128 psPixels* psPixelsCopy(psPixels* out, 129 const psPixels* pixels) 124 130 { 125 131 if (pixels == NULL) { … … 137 143 } 138 144 139 psImage *psPixelsToMask(psImage *out, const psPixels *pixels, psRegion region, psMaskType maskVal) 145 psImage *psPixelsToMask(psImage *out, 146 const psPixels *pixels, 147 psRegion region, 148 psMaskType maskVal) 140 149 { 141 150 // check that the input pixel vector is valid … … 154 163 } 155 164 156 int x0 = region.x0;157 int x1 = region.x1;158 int y0 = region.y0;159 int y1 = region.y1;165 float x0 = region.x0; 166 float x1 = region.x1; 167 float y0 = region.y0; 168 float y1 = region.y1; 160 169 161 170 // determine the output image size … … 165 174 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 166 175 PS_ERRORTEXT_psPixels_REGION_INVALID, 167 y0,y1,x0,x1);176 (int)y0,(int)y1,(int)x0,(int)x1); 168 177 psFree(out); 169 178 return NULL; … … 178 187 return NULL; 179 188 } 180 *(psS32*)&out->row0 = y0;181 *(psS32*)&out->col0 = x0;189 *(psS32*)&out->row0 = (int)y0; 190 *(psS32*)&out->col0 = (int)x0; 182 191 183 192 // initialize image to all zeros … … 188 197 189 198 // determine the length of the pixel vector 190 intlength = pixels->n;199 long length = pixels->n; 191 200 192 201 // cycle through the vector of pixels and insert pixels into image 193 202 psMaskType** outData = out->data.PS_TYPE_MASK_DATA; 194 203 for (int p = 0; p < length; p++) { 195 psS32x = data[p].x;196 psS32y = data[p].y;204 float x = data[p].x; 205 float y = data[p].y; 197 206 // pixel in region? 198 207 if (x >= x0 && x < x1 && y >= y0 && y < y1) { 199 outData[ y-y0][x-x0] |= maskVal;208 outData[(int)(y-y0)][(int)(x-x0)] |= maskVal; 200 209 } 201 210 } … … 204 213 } 205 214 206 psPixels* psPixelsFromMask(psPixels* out, const psImage* mask, psMaskType maskVal) 215 psPixels* psPixelsFromMask(psPixels* out, 216 const psImage* mask, 217 psMaskType maskVal) 207 218 { 208 219 if (mask == NULL) { … … 227 238 // total pixels, so it is best to just start with a guess and resize if 228 239 // necessary 229 intminPixels = numRows*numCols/100; // initial guess, 1% of pixels masked240 long minPixels = numRows*numCols/100; // initial guess, 1% of pixels masked 230 241 if (minPixels < 32) { // enforce a minimum size 231 242 minPixels = 32; … … 241 252 242 253 // find the mask pixels in the image 243 intnumPixels = 0;254 long numPixels = 0; 244 255 psPixelCoord* data = out->data; 245 256 int nalloc = out->nalloc; … … 266 277 } 267 278 268 psPixels* psPixelsConcatenate(psPixels *out,const psPixels *pixels) 279 psPixels* psPixelsConcatenate(psPixels *out, 280 const psPixels *pixels) 269 281 { 270 282 if (pixels == NULL) { … … 274 286 } 275 287 276 intpixelsN = pixels->n;288 long pixelsN = pixels->n; 277 289 psPixelCoord* pixelsData = pixels->data; 278 290 … … 284 296 285 297 // make sure the out is large enough to fit the result 286 intoutN = out->n;298 long outN = out->n; 287 299 out = psPixelsRealloc(out,outN + pixelsN); 288 300 psPixelCoord* outData = out->data; … … 294 306 // add non-duplicate values in pixels to out 295 307 psPixelCoord pCoord; 296 intend = outN;297 for ( intn = 0; n < pixelsN; n++) {308 long end = outN; 309 for (long n = 0; n < pixelsN; n++) { 298 310 pCoord = pixelsData[n]; 299 311 if (bsearch(&pCoord, outData, outN, sizeof(psPixelCoord), … … 318 330 } 319 331 320 intn = pixels->n;332 long n = pixels->n; 321 333 psPixelCoord* data = pixels->data; 322 334 … … 326 338 } 327 339 328 for ( inti = 0; i < n; i++) {329 fprintf (fd, "(% d,%d)\n", data[i].x, data[i].y);340 for (long i = 0; i < n; i++) { 341 fprintf (fd, "(%f,%f)\n", data[i].x, data[i].y); 330 342 } 331 343 fprintf (fd, "\n"); -
trunk/psLib/src/types/psPixels.h
r5137 r5214 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2005- 09-26 22:35:53$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-10-01 00:14:17 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 typedef struct 25 25 { 26 int x; ///< x coordinate27 int y; ///< y coordinate26 float x; ///< x coordinate 27 float y; ///< y coordinate 28 28 } 29 29 psPixelCoord; … … 86 86 long growth, 87 87 ///< number of elements to grow the psPixels list, if necessary. if growth < 1, 10 is used. 88 int x, ///< x coordinate to append89 int y ///< y coordinate to append88 float x, ///< x coordinate to append 89 float y ///< y coordinate to append 90 90 ); 91 91
Note:
See TracChangeset
for help on using the changeset viewer.
