| 126 | |
| 127 | template <bool doR, bool doG, bool doB> |
| 128 | void |
| 129 | natronImageToLibMvFloatImageForChannels(const Image* source, |
| 130 | const RectI& roi, |
| 131 | MvFloatImage& mvImg) |
| 132 | { |
| 133 | //mvImg is expected to have its bounds equal to roi |
| 134 | |
| 135 | Image::ReadAccess racc(source); |
| 136 | unsigned int compsCount = source->getComponentsCount(); |
| 137 | |
| 138 | assert(compsCount == 3); |
| 139 | unsigned int srcRowElements = source->getRowElements(); |
| 140 | |
| 141 | assert( source->getBounds().contains(roi) ); |
| 142 | const float* src_pixels = (const float*)racc.pixelAt(roi.x1, roi.y1); |
| 143 | assert(src_pixels); |
| 144 | float* dst_pixels = mvImg.Data(); |
| 145 | assert(dst_pixels); |
| 146 | //LibMV images have their origin in the top left hand corner |
| 147 | |
| 148 | // It's important to rescale the resultappropriately so that e.g. if only |
| 149 | // blue is selected, it's not zeroed out. |
| 150 | float scale = (doR ? 0.2126f : 0.0f) + |
| 151 | (doG ? 0.7152f : 0.0f) + |
| 152 | (doB ? 0.0722f : 0.0f); |
| 153 | int h = roi.height(); |
| 154 | int w = roi.width(); |
| 155 | for ( int y = 0; y < h; ++y, |
| 156 | src_pixels += (srcRowElements - compsCount * w) ) { |
| 157 | for (int x = 0; x < w; ++x, |
| 158 | src_pixels += compsCount, |
| 159 | ++dst_pixels) { |
| 160 | /// Apply luminance conversion while we copy the image |
| 161 | /// This code is taken from DisableChannelsTransform::run in libmv/autotrack/autotrack.cc |
| 162 | *dst_pixels = ( 0.2126f * (doR ? src_pixels[0] : 0.0f) + |
| 163 | 0.7152f * (doG ? src_pixels[1] : 0.0f) + |
| 164 | 0.0722f * (doB ? src_pixels[2] : 0.0f) ) / scale; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | static void |
| 170 | natronImageToLibMvFloatImage(bool enabledChannels[3], |
nothing calls this directly
no test coverage detected