Changeset 16910 for trunk/psLib/src/imageops/psImageGeomManip.c
- Timestamp:
- Mar 10, 2008, 2:41:30 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageGeomManip.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r12815 r16910 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $13 * @date $Date: 200 7-04-12 18:55:10 $12 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2008-03-11 00:41:30 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 659 659 } 660 660 661 bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask, 662 psMaskType maskVal, float dx, float dy, double exposed, psMaskType blank, 663 psImageInterpolateMode mode) 664 { 665 PS_ASSERT(out, false); 666 PS_ASSERT_IMAGE_NON_NULL(in, false); 667 if (inMask) { 668 PS_ASSERT_IMAGE_NON_NULL(inMask, false); 669 PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false); 670 PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_MASK, false); 671 } 672 673 int numRows = in->numRows, numCols = in->numCols; // Size of image 674 psElemType type = in->type.type; // Type of image 675 676 *out = psImageRecycle(*out, numCols, numRows, type); 677 if (outMask) { 678 *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_MASK); 679 } 680 681 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BICUBE, in, NULL, 682 inMask, maskVal, exposed, NAN, blank, 683 blank, 0.0); 684 685 #define PSIMAGE_SHIFT_MASK_CASE(TYPE) \ 686 case PS_TYPE_##TYPE: \ 687 if (exposed < PS_MIN_##TYPE || \ 688 exposed > PS_MAX_##TYPE || \ 689 exposed < PS_MIN_##TYPE || \ 690 exposed > PS_MAX_##TYPE) { \ 691 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 692 _("Specified exposed value, %g%+gi, is not the the range of input image's " \ 693 "valid pixel values (%s), i.e. [%g:%g]."), \ 694 exposed, exposed, \ 695 PS_TYPE_##TYPE##_NAME, \ 696 (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \ 697 psFree(out); \ 698 out = NULL; \ 699 break; \ 700 } \ 701 /* note: output(i,j) = input(i+0.5-dx,j+0.5-dy) */ \ 702 /* positive dx,dy moves pixel i-dx,j-dy to i,y */ \ 703 /* also: pixel center is 0.5,0.5 */ \ 704 for (int row = 0; row < numRows; row++) { \ 705 ps##TYPE* outRow = (*out)->data.TYPE[row]; \ 706 psMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \ 707 float y = row + 0.5 - dy; \ 708 for (int col = 0; col < numCols; col++) { \ 709 float x = col + 0.5 - dx; \ 710 double value; \ 711 psMaskType valueMask; \ 712 if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \ 713 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \ 714 psFree(interp); \ 715 return false; \ 716 } \ 717 outRow[col] = value; \ 718 if (outMask) { \ 719 outMaskRow[col] = valueMask; \ 720 } \ 721 } \ 722 } \ 723 break; 724 725 switch (type) { 726 PSIMAGE_SHIFT_MASK_CASE(U8); 727 PSIMAGE_SHIFT_MASK_CASE(U16); 728 PSIMAGE_SHIFT_MASK_CASE(U32); 729 PSIMAGE_SHIFT_MASK_CASE(U64); 730 PSIMAGE_SHIFT_MASK_CASE(S8); 731 PSIMAGE_SHIFT_MASK_CASE(S16); 732 PSIMAGE_SHIFT_MASK_CASE(S32); 733 PSIMAGE_SHIFT_MASK_CASE(S64); 734 PSIMAGE_SHIFT_MASK_CASE(F32); 735 PSIMAGE_SHIFT_MASK_CASE(F64); 736 default: { 737 char* typeStr; 738 PS_TYPE_NAME(typeStr,type); 739 psError(PS_ERR_BAD_PARAMETER_TYPE, true, _("Specified psImage type, %s, is not supported."), 740 typeStr); 741 psFree(interp); 742 return false; 743 } 744 } 745 746 psFree(interp); 747 return true; 748 } 749 661 750 psImage* psImageTransform(psImage *output, 662 751 psPixels** blankPixels, … … 745 834 // create the output image. 746 835 output = psImageRecycle(output, numCols, numRows, input->type.type); 747 P_PSIMAGE_SET_COL0(output, region.x0);748 P_PSIMAGE_SET_ROW0(output, region.y0);836 P_PSIMAGE_SET_COL0(output, region.x0); 837 P_PSIMAGE_SET_ROW0(output, region.y0); 749 838 } else { // size of output is determined by output parameter 750 839 numRows = output->numRows;
Note:
See TracChangeset
for help on using the changeset viewer.
