28 #include <vigra/imageinfo.hxx>
44 template <
class ImgIter,
class ImgAcc>
45 vigra::triple<ImgIter, ImgIter, ImgAcc>
46 applyRect(vigra::Rect2D & r, vigra::triple<ImgIter, ImgIter, ImgAcc> img)
49 vigra::Diff2D t = img.second - (img.first + r.lowerRight());
53 return vigra::triple<ImgIter, ImgIter, ImgAcc>
54 (img.first + r.upperLeft(),
55 img.first + r.lowerRight(),
64 template <
class ImgIter,
class ImgAcc>
65 vigra::pair<ImgIter, ImgAcc>
66 applyRect(vigra::Rect2D & r, vigra::pair<ImgIter, ImgAcc> img)
68 return vigra::pair<ImgIter, ImgAcc>
69 (img.first + r.upperLeft(),
84 template <
class Image,
class Mask>
126 m_image.resize(vigra::Size2D(1,1));
127 m_mask.resize(vigra::Size2D(1,1));
250 if (
m_region.contains(vigra::Point2D(pos))) {
253 return vigra::NumericTraits<image_value_type>::zero();
260 return getMask(vigra::Diff2D(x,y));
265 if (
m_region.contains(vigra::Point2D(pos))) {
268 return vigra::NumericTraits<mask_value_type>::zero();
283 template<
typename Image,
typename Mask>
284 inline vigra::triple<typename ROIImage<Image, Mask>::image_const_traverser,
289 return vigra::triple<typename ROIImage<Image,Mask>::image_const_traverser,
297 template<
typename Image,
typename Mask>
298 inline vigra::pair<typename ROIImage<Image, Mask>::image_const_traverser,
299 typename ROIImage<Image, Mask>::ImageConstAccessor>
302 return vigra::pair<typename ROIImage<Image,Mask>::image_const_traverser,
308 template <
class Image,
class Alpha>
309 inline vigra::triple<typename ROIImage<Image,Alpha>::image_traverser,
310 typename ROIImage<Image,Alpha>::image_traverser,
311 typename ROIImage<Image,Alpha>::ImageAccessor>
314 return vigra::triple<typename ROIImage<Image,Alpha>::image_traverser,
321 template <
class Image,
class Alpha>
322 inline vigra::pair<typename ROIImage<Image,Alpha>::image_traverser,
323 typename ROIImage<Image,Alpha>::ImageAccessor>
326 return vigra::pair<typename ROIImage<Image,Alpha>::image_traverser,
331 template <
class Image,
class Alpha>
332 inline vigra::triple<typename ROIImage<Image,Alpha>::mask_const_traverser,
333 typename ROIImage<Image,Alpha>::mask_const_traverser,
334 typename ROIImage<Image,Alpha>::MaskConstAccessor>
337 return vigra::triple<typename ROIImage<Image,Alpha>::mask_const_traverser,
344 template <
class Image,
class Alpha>
345 inline vigra::pair<typename ROIImage<Image,Alpha>::mask_const_traverser,
346 typename ROIImage<Image,Alpha>::MaskConstAccessor>
349 return vigra::pair<typename ROIImage<Image,Alpha>::mask_const_traverser,
354 template <
class Image,
class Alpha>
355 inline vigra::triple<typename ROIImage<Image,Alpha>::mask_traverser,
356 typename ROIImage<Image,Alpha>::mask_traverser,
357 typename ROIImage<Image,Alpha>::MaskAccessor>
360 return vigra::triple<typename ROIImage<Image,Alpha>::mask_traverser,
367 template <
class Image,
class Alpha>
368 inline vigra::pair<typename ROIImage<Image,Alpha>::mask_traverser,
369 typename ROIImage<Image,Alpha>::MaskAccessor>
372 return vigra::pair<typename ROIImage<Image,Alpha>::mask_traverser,
378 template <
class Image,
class Mask,
class Functor>
379 void inspectROIImages(std::vector<ROIImage<Image,Mask> *> imgs, Functor & f)
381 int nImg = imgs.size();
382 std::vector<typename Image::traverser> imgUL(nImg);
383 std::vector<typename Mask::traverser> maskUL(nImg);
384 std::vector<vigra::Rect2D> rois(nImg);
385 for (
unsigned i=0; i < nImg; i++) {
386 imgs[i] = imgs->upperLeft();
387 masks[i] = imgs->maskUpperLeft();
388 rois[i] = imgs->boundingBox();
398 template <
class ImgIter,
class ImgAcc,
class MaskIter,
class MaskAcc,
class Functor>
400 std::vector<MaskIter> masks,
401 std::vector<vigra::Rect2D> rois,
405 typedef typename ImgIter::value_type PixelType;
406 typedef typename MaskIter::value_type MaskType;
408 typedef typename ImgIter::row_iterator RowImgIter;
409 typedef typename MaskIter::row_iterator RowMaskIter;
411 int nImg = imgs.size();
413 vigra_precondition(nImg > 1,
"more than one image needed");
416 vigra::Rect2D maxRoi= rois[0];
417 for (
unsigned i=1; i < nImg; i++) {
421 for (
int k=0; k < nImg; k++) {
422 imgs[k].first.x += maxRoi.left();
423 imgs[k].first.y += maxRoi.top();
424 masks[k].first.x += maxRoi.left();
425 masks[k].first.y += maxRoi.top();
428 std::vector<RowImgIter> rowImgIter(nImg);
429 std::vector<RowMaskIter> rowMaskIter(nImg);
432 std::vector<PixelType> val(nImg);
433 std::vector<MaskType> mval(nImg);
434 for(p.y=maxRoi.top(); p.y < maxRoi.bottom(); ++p.y)
436 for (
int k=0; k < nImg; k++) {
437 rowImgIter[k] = imgs[k].first.rowIterator();
438 rowMaskIter[k] = masks[k].first.rowIterator();
441 for (p.x=maxRoi.left(); p.x < maxRoi.right(); ++p.x) {
442 for (
int k=0; k < nImg; k++) {
444 val[k] = *(rowImgIter[k]);
445 mval[k] = *(rowMaskIter[k]);
454 for (
int k=0; k < nImg; k++) {
456 ++(masks[k].first.y);
463 template<
class ROIIMG,
class DestIter,
class DestAccessor,
464 class MaskIter,
class MaskAccessor,
class FUNCTOR>
466 vigra::triple<DestIter, DestIter, DestAccessor> dest,
467 vigra::pair<MaskIter, MaskAccessor>
destMask,
470 typedef typename MaskAccessor::value_type MaskType;
472 unsigned int nImg = images.size();
474 vigra::Diff2D size = dest.second - dest.first;
478 for (
int y=0; y < size.y; y++) {
479 for (
int x=0; x < size.x; x++) {
482 for (
unsigned int i=0; i< nImg; i++) {
484 a = images[i]->getMask(x,y);
487 reduce(images[i]->
operator()(x,y), a);
490 dest.third.set(
reduce(), dest.first, vigra::Diff2D(x,y));
491 destMask.second.set(maskRes, destMask.first, vigra::Diff2D(x,y));
499 #endif // _ROIIMAGE_H
Mask m_mask
corresponding alpha channel
vigra::triple< ImgIter, ImgIter, ImgAcc > applyRect(vigra::Rect2D &r, vigra::triple< ImgIter, ImgIter, ImgAcc > img)
apply a roi to an image area
Mask::const_traverser mask_const_traverser
mask_traverser maskUpperLeft()
returns an traverser to the upper left of the image, this is usually outside of the rectangle...
mask_const_traverser maskLowerRight() const
vigra::pair< typename ROIImage< Image, Alpha >::mask_traverser, typename ROIImage< Image, Alpha >::MaskAccessor > destMask(ROIImage< Image, Alpha > &img)
void reduce(bool wraparound, SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor sa, AlphaIterator alpha_upperleft, AlphaAccessor aa, DestImageIterator dest_upperleft, DestImageIterator dest_lowerright, DestAccessor da, DestAlphaIterator dest_alpha_upperleft, DestAlphaIterator dest_alpha_lowerright, DestAlphaAccessor daa)
The Burt & Adelson Reduce operation.
Image::ConstAccessor ImageConstAccessor
#define DEBUG_ASSERT(cond)
vigra::pair< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImage(const ROIImage< Image, Mask > &img)
Image::Accessor ImageAccessor
mask_value_type getMask(const vigra::Diff2D &pos)
image_traverser lowerRight()
Mask::value_type mask_value_type
vigra::triple< typename ROIImage< Image, Alpha >::mask_traverser, typename ROIImage< Image, Alpha >::mask_traverser, typename ROIImage< Image, Alpha >::MaskAccessor > destMaskRange(ROIImage< Image, Alpha > &img)
vigra::Rect2D & boundingBox()
Mask::traverser mask_traverser
image_value_type operator()(int x, int y)
image_const_traverser upperLeft() const
Image m_image
remapped image
void inspectImagesIf(std::vector< ImgIter > imgs, std::vector< MaskIter > masks, std::vector< vigra::Rect2D > rois, Functor &f)
function to inspect a variable number of images.
image_const_traverser lowerRight() const
Image::value_type image_value_type
bool contains(const wxArrayString &stringArray, const wxString &string, bool caseInSensitive=true)
check if given string is in wxArrayString, do comparison case insentive or case sensitive ...
MaskAccessor maskAccessor()
return the accessor of the alpha channel
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
void reduceROIImages(std::vector< ROIIMG * > images, vigra::triple< DestIter, DestIter, DestAccessor > dest, vigra::pair< MaskIter, MaskAccessor > destMask, FUNCTOR &reduce)
algorithm to reduce a set of ROI images
mask_value_type getMask(int x, int y)
Mask::Accessor MaskAccessor
Mask::ConstAccessor MaskConstAccessor
vigra::triple< typename ROIImage< Image, Alpha >::mask_const_traverser, typename ROIImage< Image, Alpha >::mask_const_traverser, typename ROIImage< Image, Alpha >::MaskConstAccessor > srcMaskRange(const ROIImage< Image, Alpha > &img)
ImageAccessor accessor()
return the accessor of this image
vigra::pair< typename ROIImage< Image, Alpha >::mask_const_traverser, typename ROIImage< Image, Alpha >::MaskConstAccessor > srcMask(const ROIImage< Image, Alpha > &img)
vigra::triple< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImageRange(ROIImage< Image, Alpha > &img)
mask_traverser maskLowerRight()
image_traverser upperLeft()
returns an traverser to the upper left of the image, this is usually outside of the rectangle...
ImageConstAccessor accessor() const
MaskConstAccessor maskAccessor() const
Image::const_traverser image_const_traverser
Image::traverser image_traverser
mask_const_traverser maskUpperLeft() const
vigra::Rect2D m_region
bounding rectangle of the image
void resize(const vigra::Rect2D &rect)
resize the image
image_value_type operator[](vigra::Diff2D const &pos)