|
From: | Peter Hillman |
Subject: | Re: [Openexr-user] Change Channel names |
Date: | Tue, 15 Dec 2015 20:03:39 +1300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
You could maybe extend the Image class using something
like this pseudocode. The ImageChannel class returns a slice() object that stores the image layout: you can use that to access the pixels. And by pseudocode I mean "untested C++": template <class T> void TypedImageChannel<T>::operator+=(const TypedImageChannel<T> &other) { assert(image() == other.image()); IMF::Slice outSlice = slice(); IMF::Slice inSlice = other.slice(); assert(outSlice.xSampling == 1); assert(outSlice.ySampling == 1); assert(inSlice.xSampling == 1); assert(inSlice.ySampling == 1); for ( int y = image().dataWindow().min.y ; y <= image().dataWindow().max.y ; ++y) { for( int x = image().dataWindow().min.x ; x <= image().dataWindow().max.x; ++x) { * (T*) (outSlice.base + y*outSlice.yStride + x*outSlice.xStride) += * (T*) (inSlice.base + y*inSlice.yStride + x*inSlice.xStride); } } } You should then be able to merge channels by doing image.typedChannel<half>(outChanName)+=image.typedChannel<half>(inChanName); for each channel inChanName you want to add into outChanName before you write out the image again, and assuming your channels are stored as half floats. I'm not sure if that's exactly what you need, but the nested 'for' loops should give you an idea how to iterate over the pixels. If you expect the tool to get more complex than this it may be worth using a generic image processing library which supports OpenEXR instead. On 14/12/15 23:47, Aaron Carlisle
wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |