Skip to content

Commit

Permalink
Sync from upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Jul 25, 2024
2 parents c1dd2da + f56c4c6 commit a013ef7
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ jobs:
lcov --list coverage.info
- name: Upload to Codecov
uses: codecov/codecov-action@v1.2.1
uses: codecov/codecov-action@v4
with:
files: ../boost-root/coverage.info
2 changes: 1 addition & 1 deletion doc/tutorial/histogram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tutorial: Histogram

This is a short tutorial presenting an example of a very simple sample of code
from an existing code base that calculates histogram of an image.
Next, the program is rewritten using GIL featres.
Next, the program is rewritten using GIL features.

Original implementation
-----------------------
Expand Down
4 changes: 2 additions & 2 deletions include/boost/gil/extension/io/jpeg/detail/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class writer< Device
, TRUE
);

// Needs to be done after jpeg_set_defaults() since it's overridding this value back to slow.
// Needs to be done after jpeg_set_defaults() since it's overriding this value back to slow.
this->get()->dct_method = this->_info._dct_method;


Expand Down Expand Up @@ -138,7 +138,7 @@ class writer< Device
};

///
/// JPEG Dyamic Image Writer
/// JPEG Dynamic Image Writer
///
template< typename Device >
class dynamic_image_writer< Device
Expand Down
2 changes: 1 addition & 1 deletion include/boost/gil/extension/io/tiff/detail/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class reader< Device

break;
}
case PHOTOMETRIC_SEPARATED: // CYMK
case PHOTOMETRIC_SEPARATED: // CMYK
{
switch( this->_info._bits_per_sample )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class scanline_reader< Device

break;
}
case PHOTOMETRIC_SEPARATED: // CYMK
case PHOTOMETRIC_SEPARATED: // CMYK
{
switch( this->_info._bits_per_sample )
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/gil/image_processing/convolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace boost { namespace gil {

// 2D spatial seperable convolutions and cross-correlations
// 2D spatial separable convolutions and cross-correlations

namespace detail {

Expand Down
4 changes: 2 additions & 2 deletions include/boost/gil/image_processing/histogram_matching.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace boost { namespace gil {
/// Algorithm :-
/// 1. Calculate histogram A(pixel) of input image and G(pixel) of reference image.
/// 2. Compute the normalized cumulative(CDF) histograms of A and G.
/// 3. Match the histograms using transofrmation => CDF(A(px)) = CDF(G(px'))
/// 3. Match the histograms using transformation => CDF(A(px)) = CDF(G(px'))
/// => px' = Inv-CDF (CDF(px))
///

Expand Down Expand Up @@ -73,7 +73,7 @@ auto histogram_matching(
std::is_integral<SrcKeyType>::value &&
std::is_integral<RefKeyType>::value &&
std::is_integral<DstKeyType>::value,
"Source, Refernce or Destination histogram type is not appropriate.");
"Source, Reference or Destination histogram type is not appropriate.");

using value_t = typename histogram<SrcKeyType>::value_type;
dst_hist.clear();
Expand Down
2 changes: 1 addition & 1 deletion include/boost/gil/image_processing/threshold.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void threshold_binary(

/// \ingroup ImageProcessing
/// \brief Applies truncating threshold to each pixel of image view.
/// Takes an image view and performs truncating threshold operation on each chennel.
/// Takes an image view and performs truncating threshold operation on each channel.
/// If mode is threshold and direction is regular:
/// values greater than threshold_value will be set to threshold_value else no change
/// If mode is threshold and direction is inverse:
Expand Down
1 change: 1 addition & 0 deletions test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ add_subdirectory(image_view)
add_subdirectory(algorithm)
add_subdirectory(image_processing)
add_subdirectory(histogram)
add_subdirectory(io)
1 change: 1 addition & 0 deletions test/core/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ build-project image_view ;
build-project algorithm ;
build-project image_processing ;
build-project histogram ;
build-project io ;
25 changes: 25 additions & 0 deletions test/core/io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2024 Dirk Stolle
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
foreach(_name
path_spec)
set(_test t_core_io_${_name})
set(_target test_core_io_${_name})

add_executable(${_target} "")
target_sources(${_target} PRIVATE ${_name}.cpp)
target_link_libraries(${_target}
PRIVATE
gil_compile_options
gil_include_directories
gil_dependencies)
add_test(NAME ${_test} COMMAND ${_target})

unset(_name)
unset(_target)
unset(_test)
endforeach()
13 changes: 13 additions & 0 deletions test/core/io/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Boost.GIL (Generic Image Library) - tests
#
# Copyright (c) 2024 Dirk Stolle
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# copy at http://www.boost.org/LICENSE_1_0.txt)

import testing ;

compile path_spec.cpp ;

run path_spec.cpp ;
59 changes: 59 additions & 0 deletions test/core/io/path_spec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Copyright 2024 Dirk Stolle
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/core/lightweight_test.hpp>
#include <boost/gil/io/path_spec.hpp>
#include <cstring>
#include <locale>
#include <string>

namespace gil = boost::gil;

void test_convert_to_string_from_wstring()
{
std::wstring const path = L"/some_path/傳/привет/qwerty";
std::string const expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty";

std::string string = gil::detail::convert_to_string(path);
BOOST_TEST_EQ( 34, string.size() );
BOOST_TEST_EQ( expected, string );
}

void test_convert_to_native_string_from_wchar_t_ptr()
{
wchar_t const* path = L"/some_path/傳/привет/qwerty";
char const* expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty";

char const* string = gil::detail::convert_to_native_string(path);
BOOST_TEST_EQ( 34, strlen(string) );
BOOST_TEST_EQ( 0, std::strcmp(expected, string) );
delete[] string;
}

void test_convert_to_native_string_from_wstring()
{
std::wstring const path = L"/some_path/傳/привет/qwerty";
char const* expected = "/some_path/\xE5\x82\xB3/\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82/qwerty";

char const* string = gil::detail::convert_to_native_string(path);
BOOST_TEST_EQ( 34, strlen(string) );
BOOST_TEST_EQ( 0, std::strcmp(expected, string) );
delete[] string;
}

int main()
{
// Set global locale to one that uses UTF-8. Could be "en_US.UTF-8" or
// "C.UTF-8" or something similar, as long as it exists on the system.
std::locale::global(std::locale("C.UTF-8"));

test_convert_to_string_from_wstring();
test_convert_to_native_string_from_wchar_t_ptr();
test_convert_to_native_string_from_wstring();

return boost::report_errors();
}
54 changes: 27 additions & 27 deletions test/extension/io/tiff/tiff_file_format_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ void test_thirty_two_bit_contiguous_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-02.tif 73x43 2-bit seperated RGB image
void test_two_bit_seperated_rgb_image()
// flower-rgb-planar-02.tif 73x43 2-bit separated RGB image
void test_two_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-02.tif");

Expand All @@ -360,8 +360,8 @@ void test_two_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-04.tif 73x43 4-bit seperated RGB image
void test_four_bit_seperated_rgb_image()
// flower-rgb-planar-04.tif 73x43 4-bit separated RGB image
void test_four_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-04.tif");

Expand All @@ -374,8 +374,8 @@ void test_four_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-08.tif 73x43 8-bit seperated RGB image
void test_eight_bit_seperated_rgb_image()
// flower-rgb-planar-08.tif 73x43 8-bit separated RGB image
void test_eight_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-08.tif");

Expand All @@ -388,8 +388,8 @@ void test_eight_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-10.tif 73x43 10-bit seperated RGB image
void test_ten_bit_seperated_rgb_image()
// flower-rgb-planar-10.tif 73x43 10-bit separated RGB image
void test_ten_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-10.tif");

Expand All @@ -402,8 +402,8 @@ void test_ten_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-12.tif 73x43 12-bit seperated RGB image
void test_twelve_bit_seperated_rgb_image()
// flower-rgb-planar-12.tif 73x43 12-bit separated RGB image
void test_twelve_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-12.tif");

Expand All @@ -416,8 +416,8 @@ void test_twelve_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-14.tif 73x43 14-bit seperated RGB image
void test_fourteen_bit_seperated_rgb_image()
// flower-rgb-planar-14.tif 73x43 14-bit separated RGB image
void test_fourteen_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-14.tif");

Expand All @@ -430,8 +430,8 @@ void test_fourteen_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-16.tif 73x43 16-bit seperated RGB image
void test_sixteen_bit_seperated_rgb_image()
// flower-rgb-planar-16.tif 73x43 16-bit separated RGB image
void test_sixteen_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-16.tif");

Expand All @@ -444,8 +444,8 @@ void test_sixteen_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-24.tif 73x43 24-bit seperated RGB image
void test_twenty_four_bit_seperated_rgb_image()
// flower-rgb-planar-24.tif 73x43 24-bit separated RGB image
void test_twenty_four_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-24.tif");

Expand All @@ -458,8 +458,8 @@ void test_twenty_four_bit_seperated_rgb_image()
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

// flower-rgb-planar-32.tif 73x43 32-bit seperated RGB image
void test_thirty_two_bit_seperated_rgb_image()
// flower-rgb-planar-32.tif 73x43 32-bit separated RGB image
void test_thirty_two_bit_separated_rgb_image()
{
std::string filename(tiff_in + "libtiffpic/depth/flower-rgb-planar-32.tif");

Expand Down Expand Up @@ -609,15 +609,15 @@ int main()
test_sixteen_bit_contiguous_rgb_image();
test_twenty_four_bit_contiguous_rgb_image();
test_thirty_two_bit_contiguous_rgb_image();
test_two_bit_seperated_rgb_image();
test_four_bit_seperated_rgb_image();
test_eight_bit_seperated_rgb_image();
test_ten_bit_seperated_rgb_image();
test_twelve_bit_seperated_rgb_image();
test_fourteen_bit_seperated_rgb_image();
test_sixteen_bit_seperated_rgb_image();
test_twenty_four_bit_seperated_rgb_image();
test_thirty_two_bit_seperated_rgb_image();
test_two_bit_separated_rgb_image();
test_four_bit_separated_rgb_image();
test_eight_bit_separated_rgb_image();
test_ten_bit_separated_rgb_image();
test_twelve_bit_separated_rgb_image();
test_fourteen_bit_separated_rgb_image();
test_sixteen_bit_separated_rgb_image();
test_twenty_four_bit_separated_rgb_image();
test_thirty_two_bit_separated_rgb_image();
test_eight_bit_contiguous_cmyk_image();
test_sixteen_bit_contiguous_cmyk_image();
test_eight_bit_separated_cmyk_image();
Expand Down

0 comments on commit a013ef7

Please sign in to comment.