| 186 | } |
| 187 | |
| 188 | void initAlbedo(image::Image<image::RGBfColor>& albedo, |
| 189 | const image::Image<image::RGBfColor>& picture, |
| 190 | EAlbedoEstimation albedoEstimationMethod, |
| 191 | int albedoEstimationFilterSize, |
| 192 | const std::string& outputFolder, |
| 193 | IndexT viewId) |
| 194 | { |
| 195 | switch (albedoEstimationMethod) |
| 196 | { |
| 197 | case EAlbedoEstimation::CONSTANT: |
| 198 | { |
| 199 | albedo.resize(picture.width(), picture.height()); |
| 200 | albedo.fill(image::RGBfColor(.5f, .5f, .5f)); |
| 201 | } |
| 202 | break; |
| 203 | case EAlbedoEstimation::PICTURE: |
| 204 | { |
| 205 | albedo = picture; |
| 206 | } |
| 207 | break; |
| 208 | case EAlbedoEstimation::MEDIAN_FILTER: |
| 209 | { |
| 210 | albedo.resize(picture.width(), picture.height()); |
| 211 | const oiio::ImageBuf pictureBuf(oiio::ImageSpec(picture.width(), picture.height(), 3, oiio::TypeDesc::FLOAT), |
| 212 | const_cast<void*>((void*)&picture(0, 0)(0))); |
| 213 | oiio::ImageBuf albedoBuf(oiio::ImageSpec(picture.width(), picture.height(), 3, oiio::TypeDesc::FLOAT), albedo.data()); |
| 214 | oiio::ImageBufAlgo::median_filter(albedoBuf, pictureBuf, albedoEstimationFilterSize, albedoEstimationFilterSize); |
| 215 | image::writeImage((fs::path(outputFolder) / (std::to_string(viewId) + "_albedo.jpg")).string(), albedo, image::ImageWriteOptions()); |
| 216 | } |
| 217 | break; |
| 218 | case EAlbedoEstimation::BLUR_FILTER: |
| 219 | { |
| 220 | albedo.resize(picture.width(), picture.height()); |
| 221 | const oiio::ImageBuf pictureBuf(oiio::ImageSpec(picture.width(), picture.height(), 3, oiio::TypeDesc::FLOAT), |
| 222 | const_cast<void*>((void*)&picture(0, 0)(0))); |
| 223 | oiio::ImageBuf albedoBuf(oiio::ImageSpec(picture.width(), picture.height(), 3, oiio::TypeDesc::FLOAT), albedo.data()); |
| 224 | oiio::ImageBuf K = oiio::ImageBufAlgo::make_kernel("gaussian", albedoEstimationFilterSize, albedoEstimationFilterSize); |
| 225 | oiio::ImageBufAlgo::convolve(albedoBuf, pictureBuf, K); |
| 226 | image::writeImage((fs::path(outputFolder) / (std::to_string(viewId) + "_albedo.jpg")).string(), albedo, image::ImageWriteOptions()); |
| 227 | } |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | void initAlbedo(image::Image<float>& albedo, |
| 233 | const image::Image<float>& picture, |
no test coverage detected