#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxUniform (HxImageRep im, HxSizes sizes) |
Uniform filter. More... |
|
Uniform filter.
00015 { 00016 HxString fname("HxUniform"); 00017 00018 if (im.isNull()) 00019 { 00020 HxGlobalError::instance()->reportError(fname, im.name(), "null image", HxGlobalError::HX_GE_INVALID); 00021 return HxImageRep(); 00022 } 00023 00024 if ((sizes.x() < 1) || (sizes.x() > im.dimensionSize(1))) 00025 { 00026 HxGlobalError::instance()->reportError(fname, "illegal size x", HxGlobalError::HX_GE_INVALID); 00027 return HxImageRep(); 00028 } 00029 00030 if ((sizes.y() < 1) || (sizes.y() > im.dimensionSize(2))) 00031 { 00032 HxGlobalError::instance()->reportError(fname, "illegal size y", HxGlobalError::HX_GE_INVALID); 00033 return HxImageRep(); 00034 } 00035 if (im.dimensionality() == 3) 00036 { 00037 if ((sizes.z() < 1) || (sizes.z() > im.dimensionSize(3))) 00038 { 00039 HxGlobalError::instance()->reportError(fname, "illegal size z", HxGlobalError::HX_GE_INVALID); 00040 return HxImageRep(); 00041 } 00042 } 00043 00044 // An image signature for a 2D image with 64-bit real valued scalar pixels 00045 HxImageSignature sig(2, 1, REAL_VALUE, 64); 00046 00047 // Construct the separable kernels 00048 HxImageRep kx = HxImageFactory::instance().fromValue(sig, 00049 HxSizes(sizes.x(),1,1), 1./sizes.x()); 00050 HxImageRep ky = HxImageFactory::instance().fromValue(sig, 00051 HxSizes(sizes.y(),1,1), 1./sizes.y()); 00052 HxImageRep kz = HxImageFactory::instance().fromValue(sig, 00053 HxSizes(sizes.z(),1,1), 1./sizes.z()); 00054 00055 // and apply the operation 00056 if (im.dimensionality() == 3) { 00057 return im.genConv3dSep(kx, ky, kz, "mul", "addAssign", 00058 HxImageRep::ARITH_PREC); 00059 } 00060 00061 return im.genConv2dSep(kx, ky, "mul", "addAssign", HxImageRep::ARITH_PREC); 00062 } |