Changeset 1606 for trunk/psLib/src/image
- Timestamp:
- Aug 23, 2004, 12:36:04 PM (22 years ago)
- Location:
- trunk/psLib/src/image
- Files:
-
- 4 edited
-
psImage.c (modified) (5 diffs)
-
psImage.h (modified) (2 diffs)
-
psImageExtraction.c (modified) (5 diffs)
-
psImageExtraction.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r1440 r1606 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:34:58$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-23 22:36:03 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 { 44 44 int area = 0; 45 int elementSize = PSELEMTYPE_SIZEOF(type); // element 46 47 // size in 48 // bytes 49 int rowSize = numCols * elementSize; // row 50 51 // size 52 53 // in bytes. 45 int elementSize = PSELEMTYPE_SIZEOF(type); // element size in bytes 46 int rowSize = numCols * elementSize; // row size in bytes. 54 47 55 48 area = numCols * numRows; … … 71 64 image->data.V = psAlloc(sizeof(void *) * numRows); 72 65 if (image->data.V == NULL) { 66 psFree(image); 73 67 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); 74 68 } 75 69 76 image->data.V[0] = psAlloc(area * elementSize); 77 if (image->data.V[0] == NULL) { 70 image->rawDataBuffer = psAlloc(area * elementSize); 71 if (image->rawDataBuffer == NULL) { 72 psFree(image); 73 psFree(image->data.V); 78 74 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); 79 75 } 80 76 77 // set the row pointers. 78 image->data.V[0] = image->rawDataBuffer; 81 79 for (int i = 1; i < numRows; i++) { 82 80 image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize); … … 119 117 psImageFreeChildren(image); 120 118 121 psFree(image-> data.V[0]);119 psFree(image->rawDataBuffer); 122 120 psFree(image->data.V); 123 121 image->data.V = NULL; … … 167 165 } 168 166 // Resize the image buffer 169 old-> data.V[0]= psRealloc(old->data.V[0], numCols * numRows * elementSize);167 old->rawDataBuffer = psRealloc(old->data.V[0], numCols * numRows * elementSize); 170 168 old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *)); 171 169 172 170 // recreate the row pointers 171 old->data.V[0] = old->rawDataBuffer; 173 172 for (int i = 1; i < numRows; i++) { 174 173 old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize); -
trunk/psLib/src/image/psImage.h
r1442 r1606 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-08- 10 01:05:53 $14 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-08-23 22:36:03 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 68 68 int nChildren; ///< Number of subimages. 69 69 struct psImage* *children; ///< Children of this region. 70 71 void* rawDataBuffer; 70 72 } 71 73 psImage; -
trunk/psLib/src/image/psImageExtraction.c
r1603 r1606 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-2 0 01:10:54$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-23 22:36:03 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "psError.h" 24 24 25 psImage* psImageSubset(psImage* out, 26 psImage* image, 25 psImage* psImageSubset(psImage* image, 27 26 unsigned int numCols, 28 27 unsigned int numRows, … … 30 29 unsigned int row0) 31 30 { 32 unsigned int elementSize; // size of image 33 34 // element in 35 // bytes 36 unsigned int outputRowSize; // output row 37 38 // size in bytes 39 unsigned int inputColOffset; // offset 40 41 // in 42 // bytes 43 // to 44 // first 45 // subset 46 47 // pixel in input row 31 psImage* out; 32 unsigned int elementSize; // size of image element in bytes 33 unsigned int inputColOffset; // offset in bytes to first subset pixel in input row 48 34 49 35 if (image == NULL || image->data.V == NULL) { … … 80 66 elementSize = PSELEMTYPE_SIZEOF(image->type.type); 81 67 82 out = psImageRecycle(out, numCols, numRows, image->type.type); 83 84 // set the parent information into the child 85 // output image 86 *(int *)&out->row0 = row0; 87 *(int *)&out->col0 = col0; 88 *(psImage* *) & out->parent = (psImage* ) image; 68 out = psAlloc(sizeof(psImage)); 69 *(psType*)&out->type = image->type; 70 *(unsigned int*)&out->numCols = numCols; 71 *(unsigned int*)&out->numRows = numRows; 72 *(int*)&out->row0 = row0; 73 *(int*)&out->col0 = col0; 74 out->parent = image; 75 out->nChildren = 0; 76 out->children = NULL; 77 out->rawDataBuffer = psMemIncrRefCounter(image->rawDataBuffer); 78 out->data.V = psAlloc(sizeof(void*)*numRows); 79 80 // set the new psImage's deallocator to the same as the input image 81 p_psMemSetDeallocator(out,p_psMemGetDeallocator(image)); 82 83 inputColOffset = elementSize * col0; 84 for (int row = 0; row < numRows; row++) { 85 out->data.V[row] = image->data.U8[row0 + row] + inputColOffset; 86 } 89 87 90 88 // add output image as a child of the input 91 89 // image. 92 90 image->nChildren++; 93 image->children = (psImage* *) psRealloc(image->children, image->nChildren * sizeof(psImage* ));91 image->children = (psImage**) psRealloc(image->children, image->nChildren * sizeof(psImage* )); 94 92 image->children[image->nChildren - 1] = out; 95 96 inputColOffset = elementSize * col0;97 outputRowSize = elementSize * numCols;98 99 for (int row = 0; row < numRows; row++) {100 memcpy(out->data.V[row], image->data.U8[row0 + row] + inputColOffset, outputRowSize);101 }102 93 103 94 return (out); … … 151 142 // datatype. 152 143 if (type == inDatatype) { 153 memcpy(output->data.V[0], input->data.V[0], elementSize * elements); 144 for (int row=0;row<numRows;row++) { 145 memcpy(output->data.V[row], input->data.V[row], elementSize * numCols); 146 } 154 147 return output; 155 148 } 156 149 #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \ 157 ps##INTYPE *in = IN->data.INTYPE[0]; \ 158 ps##OUTTYPE *out = OUT->data.OUTTYPE[0]; \ 159 for (int e=0;e<ELEMENTS;e++) { \ 160 *(out++) = *(in++); \ 150 ps##INTYPE *in; \ 151 ps##OUTTYPE *out; \ 152 for(int row=0;row<numRows;row++) { \ 153 in = IN->data.INTYPE[row]; \ 154 out = OUT->data.OUTTYPE[row]; \ 155 for (int col=0;col<numCols;col++) { \ 156 *(out++) = *(in++); \ 157 } \ 161 158 } \ 162 159 } -
trunk/psLib/src/image/psImageExtraction.h
r1441 r1606 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$12 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-23 22:36:03 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 */ 45 45 psImage* psImageSubset( 46 psImage* out, ///< image to recycle, or NULL.47 46 psImage* image, ///< Parent image. 48 47 unsigned int numCols, ///< Subimage width (<= image.nCols - col0). … … 50 49 unsigned int col0, ///< Subimage col-offset (0 <= col0 < nCol). 51 50 unsigned int row0 ///< Subimage row-offset (0 <= row0 < nCol). 51 ); 52 53 /** Create a subimage of the specified area. 54 * 55 * Uses psLib memory allocation functions to create an image based on a larger 56 * one. 57 * 58 * @return psImage* : Pointer to psImage. 59 * 60 */ 61 psImage* psImageSubsection( 62 psImage* image, ///< Parent image. 63 const char* section ///< Subsection in the form '[x1:x2,y1:y2]' 52 64 ); 53 65
Note:
See TracChangeset
for help on using the changeset viewer.
