change padding

main
Xiao Song 3 years ago
parent 9c052a6c75
commit b8be350573

@ -35,7 +35,6 @@ message(STATUS "Found LIBRAW_LIBRARY to be ${LIBRAW_LIBRARY}" )
# Exiv2 # Exiv2
find_package(exiv2 REQUIRED CONFIG NAMES exiv2) find_package(exiv2 REQUIRED CONFIG NAMES exiv2)
link_libraries(exiv2lib)
message(STATUS "Found Exiv2 and linked") message(STATUS "Found Exiv2 and linked")
if(NOT APPLE) if(NOT APPLE)
@ -64,10 +63,11 @@ add_library(${PROJECT_NAME} SHARED ${src_files} )
# and link it # and link it
# https://cmake.org/cmake/help/v3.0/command/target_link_libraries.html # https://cmake.org/cmake/help/v3.0/command/target_link_libraries.html
# use public interace because our .h / .hpp file include opencv .h / .hpp file # use public because our .h / .hpp file include opencv .h / .hpp file
target_link_libraries(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC
${OpenCV_LIBS} ${OpenCV_LIBS}
${LIBRAW_LIBRARY} ) ${LIBRAW_LIBRARY}
exiv2lib )
# example # example
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin )

@ -31,7 +31,12 @@
${LIBRAW_LIBRARY}) ${LIBRAW_LIBRARY})
``` ```
3. Run CMake to build 3. Install `exiv2`
1. MacOS : `brew install exiv2` & `brew install libssh`
2. Ubuntu : `apt install libexiv2-dev`
4. Run CMake to build
```shell ```shell
mkdir build mkdir build
cd build cd build

@ -20,7 +20,14 @@ class burst
// Source bayer images & grayscale unpadded image // Source bayer images & grayscale unpadded image
std::vector<hdrplus::bayer_image> bayer_images; std::vector<hdrplus::bayer_image> bayer_images;
// Image padded to tile size // Image padded to upper level tile size (16*2)
// Use for alignment, merging, and finishing
std::vector<cv::Mat> bayer_images_pad;
// Padding information
std::vector<int> padding_info_bayer;
// Image padded to upper level tile size (16)
// Use for alignment, merging, and finishing // Use for alignment, merging, and finishing
std::vector<cv::Mat> grayscale_images_pad; std::vector<cv::Mat> grayscale_images_pad;

@ -52,14 +52,6 @@ bayer_image::bayer_image( const std::string& bayer_image_path )
black_level_per_channel.at(3) = exifData["Exif.Image.BlackLevel"].toLong(3); black_level_per_channel.at(3) = exifData["Exif.Image.BlackLevel"].toLong(3);
iso = exifData["Exif.Image.ISOSpeedRatings"].toLong(); iso = exifData["Exif.Image.ISOSpeedRatings"].toLong();
// white_level = int( libraw_processor->imgdata.rawdata.color.maximum );
// black_level_per_channel.resize( 4 );
// black_level_per_channel.at( 0 ) = int( libraw_processor->imgdata.rawdata.color.cblack[ 0 ] + libraw_processor->imgdata.rawdata.color.black );
// black_level_per_channel.at( 1 ) = int( libraw_processor->imgdata.rawdata.color.cblack[ 1 ] + libraw_processor->imgdata.rawdata.color.black );
// black_level_per_channel.at( 2 ) = int( libraw_processor->imgdata.rawdata.color.cblack[ 2 ] + libraw_processor->imgdata.rawdata.color.black );
// black_level_per_channel.at( 3 ) = int( libraw_processor->imgdata.rawdata.color.cblack[ 3 ] + libraw_processor->imgdata.rawdata.color.black );
// iso = float( libraw_processor->imgdata.other.iso_speed );
// Create CV mat // Create CV mat
// https://answers.opencv.org/question/105972/de-bayering-a-cr2-image/ // https://answers.opencv.org/question/105972/de-bayering-a-cr2-image/
// https://www.libraw.org/node/2141 // https://www.libraw.org/node/2141

@ -2,6 +2,7 @@
#include <string> #include <string>
#include <opencv2/opencv.hpp> // all opencv header #include <opencv2/opencv.hpp> // all opencv header
#include "hdrplus/burst.h" #include "hdrplus/burst.h"
#include "hdrplus/utility.h"
namespace hdrplus namespace hdrplus
{ {
@ -49,28 +50,39 @@ burst::burst( const std::string& burst_path, const std::string& reference_image_
bayer_images.emplace_back( bayer_image_path_i ); bayer_images.emplace_back( bayer_image_path_i );
} }
// Pad gray scale image // Pad information
int pad_height = bayer_images[ 0 ].height % 32; int tile_size_bayer = 32;
int pad_width = bayer_images[ 0 ].width % 32; int padding_top = tile_size_bayer / 2;
// https://docs.opencv.org/3.4/dc/da3/tutorial_copyMakeBorder.html int padding_bottom = tile_size_bayer / 2 + \
( bayer_images[ 0 ].height % tile_size_bayer == 0 ? \
0 : tile_size_bayer - bayer_images[ 0 ].height % tile_size_bayer );
int padding_left = tile_size_bayer / 2;
int padding_right = tile_size_bayer / 2 + \
( bayer_images[ 0 ].width % tile_size_bayer == 0 ? \
0 : tile_size_bayer - bayer_images[ 0 ].width % tile_size_bayer );
padding_info_bayer = std::vector<int>{ padding_top, padding_bottom, padding_left, padding_right };
// Pad bayer image
for ( const auto& bayer_image_i : bayer_images ) for ( const auto& bayer_image_i : bayer_images )
{ {
cv::Mat grayscale_image_pad_i; cv::Mat bayer_image_pad_i;
cv::copyMakeBorder( bayer_image_i.grayscale_image, \ cv::copyMakeBorder( bayer_image_i.raw_image, \
grayscale_image_pad_i, \ bayer_image_pad_i, \
0, pad_height, 0, pad_width, \ padding_top, padding_bottom, padding_left, padding_right, \
cv::BORDER_REFLECT ); cv::BORDER_REFLECT );
// cv::Mat use internal reference count // cv::Mat use internal reference count
grayscale_images_pad.emplace_back( grayscale_image_pad_i ); bayer_images_pad.emplace_back( bayer_image_pad_i );
grayscale_images_pad.emplace_back( box_filter_2x2<uint16_t>( bayer_image_pad_i ) );
} }
#ifndef NDEBUG #ifndef NDEBUG
printf("%s::%s Pad image from (%d, %d) -> (%d, %d)\n", \ printf("%s::%s Pad bayer image from (%d, %d) -> (%d, %d)\n", \
__FILE__, __func__, \ __FILE__, __func__, \
bayer_images[ 0 ].grayscale_image.size().height, \ bayer_images[ 0 ].height, \
bayer_images[ 0 ].grayscale_image.size().width, \ bayer_images[ 0 ].width, \
grayscale_images_pad[ 0 ].size().height, \ bayer_images_pad[ 0 ].size().height, \
grayscale_images_pad[ 0 ].size().width ); bayer_images_pad[ 0 ].size().width );
#endif #endif
} }

Loading…
Cancel
Save