Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding of a little more genericity in ImageHelper.h #1001

Merged
merged 4 commits into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
Levall1ois [#935](https://github.com/DGtal-team/DGtal/pull/935),
backport from imagene)

- *Image Package*
- Adding copy between images of different types. (Roland Denis [#1001]
(https://github.com/DGtal-team/DGtal/pull/1001))

- *IO Package*
- Limited interaction added to QGLViewer Viewer3D class. The user
may assign integer identifiers (OpenGL names) to surfels and
Expand Down
13 changes: 7 additions & 6 deletions src/DGtal/images/ImageHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ namespace DGtal
* @param aImg1 the image to fill
* @param aImg2 the image to copy
*
* @tparam I any model of CImage
* @tparam I1 any model of CImage
* @tparam I2 any model of CConstImage
*/
template<typename I>
void imageFromImage(I& aImg1, const I& aImg2);
template<typename I1, typename I2>
void imageFromImage(I1& aImg1, const I2& aImg2);

/**
* Insert @a aPoint in @a aSet and if (and only if)
Expand Down Expand Up @@ -310,7 +311,7 @@ namespace DGtal
* @return 'true' if a new point is found and the value read
* but 'false' otherwise
*
* @tparam I any model of CImage
* @tparam I any model of CConstImage
* @tparam S any model of CDigitalSet
*
* The general behavior is like:
Expand Down Expand Up @@ -350,7 +351,7 @@ namespace DGtal
typedef typename Image::Point Point;
typedef TValue Value;

BOOST_CONCEPT_ASSERT(( concepts::CImage<Image> ));
BOOST_CONCEPT_ASSERT(( concepts::CConstImage<Image> ));
BOOST_CONCEPT_ASSERT(( concepts::CPointPredicate<PointPredicate> ));
BOOST_CONCEPT_ASSERT(( CQuantity<Value> ));

Expand Down Expand Up @@ -385,7 +386,7 @@ namespace DGtal
*
* @return val between _ZERO_ or aVal
*/
Value operator()( const Point &aPoint )
Value operator()( const Point &aPoint ) const
{
if ((myImage->domain().isInside(aPoint)))
{
Expand Down
11 changes: 6 additions & 5 deletions src/DGtal/images/ImageHelper.ih
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@ DGtal::imageFromFunctor(I& aImg, const F& aFun)
}

//------------------------------------------------------------------------------
template<typename I>
template<typename I1, typename I2>
inline
void
DGtal::imageFromImage(I& aImg1, const I& aImg2)
DGtal::imageFromImage(I1& aImg1, const I2& aImg2)
{
BOOST_CONCEPT_ASSERT(( concepts::CImage<I> ));
BOOST_CONCEPT_ASSERT(( concepts::CImage<I1> ));
BOOST_CONCEPT_ASSERT(( concepts::CConstImage<I2> ));

typename I::ConstRange r = aImg2.constRange();
typename I2::ConstRange r = aImg2.constRange();
std::copy( r.begin(), r.end(), aImg1.range().outputIterator() );
}

Expand Down Expand Up @@ -341,7 +342,7 @@ DGtal::findAndGetValue(const I& aImg, const S& aSet,
typename I::Value& aValue )
{

BOOST_CONCEPT_ASSERT(( concepts::CImage<I> ));
BOOST_CONCEPT_ASSERT(( concepts::CConstImage<I> ));
BOOST_CONCEPT_ASSERT(( concepts::CDigitalSet<S> ));
BOOST_STATIC_ASSERT(( boost::is_same< typename I::Point, typename S::Point >::value ));

Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/testImagesSetsUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool testImageFromSet()

Image image3 = image;
//fill image3 from image2
imageFromImage(image3, image2);
imageFromImage(image3, const_cast<Image const&>(image2));
//image2 and image3 should be equal,
//but both different from image
Image::ConstRange rimg = image.constRange();
Expand Down