Skip to content

Commit

Permalink
Merge branch 'master' into develop/update-externals
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Feb 2, 2022
2 parents 5de601b + 59640e1 commit 091a463
Show file tree
Hide file tree
Showing 24 changed files with 645 additions and 679 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Software source code previously released under an open source license and then m
copyrights of the non-government authors and must be released according to the terms of the original open source license.

### Contact
July 2020, Dan <dot> Smith <at> maxar.com
February 2022, Dan <dot> Smith <at> maxar <dot> <see><oh><em>
19 changes: 19 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
![alt tag](https://raw.github.com/ngageoint/six-library/master/docs/six_logo.png?raw=true)

# SIX Release Notes

## (WIP: Version 3.1.9); ????, ??, 2022
* replace KDTree *`std::complex<float>` -> AMP8I_PHS8I conversion* with a
["math based" approach](https://github.com/ngageoint/six-library/pull/537#issuecomment-1026453353).
* restore SIDD 2.0 `AngleMagnitudeType`, SIDD 3.0 is `AngleZeroToExclusive360MagnitudeType`

## Version 3.1.8; December 13, 2021
* [coda-oss](https://github.com/mdaus/coda-oss) version [2021-12-13](https://github.com/mdaus/coda-oss/releases/tag/2021-12-13)
* [nitro](https://github.com/mdaus/nitro) version [2.10.7](https://github.com/mdaus/nitro/releases/tag/NITRO-2.10.7)
* write [8AMPI_PHSI](https://github.com/ngageoint/six-library/tree/feature/8AMPI_PHSI) files
* update schema for [SIDD 3.0](https://github.com/ngageoint/six-library/tree/feature/SIDD-3.0)

-----

## Contact
February 2022, Dan <dot> Smith <at> Maxar <dot> <see><oh><em>
2 changes: 2 additions & 0 deletions six.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AD152C2-1F3D-4108-826C-79BA5011874F}"
ProjectSection(SolutionItems) = preProject
six\modules\c++\cpp_pch.h = six\modules\c++\cpp_pch.h
README.md = README.md
ReleaseNotes.md = ReleaseNotes.md
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "check_valid_six", "six\modules\c++\samples\check_valid_six.dir\check_valid_six.vcxproj", "{F0E2C8FF-57D4-4331-9BD2-76FF01CB54EB}"
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sicd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coda_add_module(
source/AreaPlaneUtility.cpp
source/ComplexData.cpp
source/ComplexDataBuilder.cpp
source/ComplexToAMP8IPHS8I.cpp
source/ComplexXMLControl.cpp
source/ComplexXMLParser.cpp
source/ComplexXMLParser040.cpp
Expand All @@ -22,7 +23,6 @@ coda_add_module(
source/Grid.cpp
source/ImageData.cpp
source/ImageFormation.cpp
source/KDTree.cpp
source/NITFReadComplexXMLControl.cpp
source/PFA.cpp
source/Position.cpp
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sicd/include/six/sicd/ComplexData.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct ComplexData: public Data
{
imageData->pixelType = pixelType;
}
bool convertPixels_(std::span<const std::byte>, std::span<std::byte>) const override;
bool convertPixels_(std::span<const std::byte>, std::span<std::byte>, ptrdiff_t cutoff) const override;

/*!
* Maps to: /SICD/ImageData/NumRows,
Expand Down
80 changes: 80 additions & 0 deletions six/modules/c++/six.sicd/include/six/sicd/ComplexToAMP8IPHS8I.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* =========================================================================
* This file is part of six.sicd-c++
* =========================================================================
*
* (C) Copyright 2021, Maxar Technologies, Inc.
*
* six.sicd-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SIX_six_sicd_ComplexToAMP8IPHS8I_h_INCLUDED_
#define SIX_six_sicd_ComplexToAMP8IPHS8I_h_INCLUDED_
#pragma once

#include <stdint.h>

#include <array>
#include <complex>
#include <memory>
#include <vector>

#include <six/sicd/ImageData.h>

namespace six
{
namespace sicd
{
namespace details
{
/*!
* \brief A utility that's used to convert complex values into 8-bit amplitude and phase values.
*/
class ComplexToAMP8IPHS8I final
{
/*!
* Create a lookup structure that converts from complex to amplitude and phase.
* @param pAmplitudeTable optional amplitude table.
*/
explicit ComplexToAMP8IPHS8I(const six::AmplitudeTable* pAmplitudeTable = nullptr);
public:
static const ComplexToAMP8IPHS8I* make(const six::AmplitudeTable* pAmplitudeTable, std::unique_ptr<ComplexToAMP8IPHS8I>&);

~ComplexToAMP8IPHS8I() = default;
ComplexToAMP8IPHS8I(const ComplexToAMP8IPHS8I&) = delete;
ComplexToAMP8IPHS8I& operator=(const ComplexToAMP8IPHS8I&) = delete;
ComplexToAMP8IPHS8I(ComplexToAMP8IPHS8I&&) = delete;
ComplexToAMP8IPHS8I& operator=(ComplexToAMP8IPHS8I&&) = delete;

/*!
* Get the nearest amplitude and phase value given a complex value
* @param v complex value to query with
* @return nearest amplitude and phase value
*/
AMP8I_PHS8I_t nearest_neighbor(const std::complex<float>& v) const;

private:
//! The sorted set of possible magnitudes order from small to large.
std::vector<long double> uncached_magnitudes; // Order is important! This must be ...
const std::vector<long double>& magnitudes; // ... before this.

//! The difference in phase angle between two UINT phase values.
long double phase_delta;
//! Unit vector rays that represent each direction that phase can point.
std::array<std::complex<long double>, UINT8_MAX + 1> phase_directions;
};
}
}
}
#endif // SIX_six_sicd_ComplexToAMP8IPHS8I_h_INCLUDED_
44 changes: 3 additions & 41 deletions six/modules/c++/six.sicd/include/six/sicd/ImageData.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace six
{
namespace sicd
{
using cx_float = std::complex<float>;
using AMP8I_PHS8I_t = std::pair<uint8_t, uint8_t>;

class GeoData;
/*!
Expand Down Expand Up @@ -96,49 +98,9 @@ struct ImageData

bool validate(const GeoData& geoData, logging::Logger& log) const;

using cx_float = std::complex<float>;
using AMP8I_PHS8I_t = std::pair<uint8_t, uint8_t>;
struct KDNode final
{
using value_type = typename cx_float::value_type;
cx_float result;
AMP8I_PHS8I_t amp_and_value;

value_type& index(size_t i)
{
assert(i <= 1);
// https://en.cppreference.com/w/cpp/numeric/complex
return reinterpret_cast<value_type(&)[2]>(result)[i];
}
const value_type& index(size_t i) const
{
assert(i <= 1);
// https://en.cppreference.com/w/cpp/numeric/complex
return reinterpret_cast<const value_type(&)[2]>(result)[i];
}

constexpr size_t size() const
{
return 2;
}

// Euklidean distance (L2 norm)
static KDNode::value_type coordinate_distance(const KDNode& p, const KDNode& q, size_t i)
{
const auto x = p.index(i);
const auto y = q.index(i);
return (x - y) * (x - y);
}
static KDNode::value_type distance(const KDNode& p, const KDNode& q)
{
assert(p.size() == q.size());
assert(p.size() == 2);
return coordinate_distance(p, q, 0) + coordinate_distance(p, q, 1);
}
};

// It would be nice to cache the results, but amplitudeTable could change at any time.
cx_float from_AMP8I_PHS8I(const AMP8I_PHS8I_t&) const; // for unit-tests
static void to_AMP8I_PHS8I(const AmplitudeTable*, std::span<const cx_float>, std::span<AMP8I_PHS8I_t>, ptrdiff_t cutoff = -1); // for unit-tests

void from_AMP8I_PHS8I(std::span<const AMP8I_PHS8I_t>, std::span<cx_float>, ptrdiff_t cutoff = -1) const;
void to_AMP8I_PHS8I(std::span<const cx_float>, std::span<AMP8I_PHS8I_t>, ptrdiff_t cutoff = -1) const;
Expand Down
56 changes: 0 additions & 56 deletions six/modules/c++/six.sicd/include/six/sicd/KDTree.h

This file was deleted.

5 changes: 2 additions & 3 deletions six/modules/c++/six.sicd/include/six/sicd/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ class Utilities
const std::vector<types::RowCol<double> >& opPixels,
std::vector<types::RowCol<double> >& spPixels);

// for unit-testing
static std::complex<float> from_AMP8I_PHS8I(uint8_t input_amplitude, uint8_t input_value, const six::AmplitudeTable*);
static std::complex<long double> from_AMP8I_PHS8I(uint8_t input_amplitude, uint8_t input_value, const six::AmplitudeTable*);
};


Expand All @@ -678,7 +677,7 @@ extern void writeAsNITF(const std::filesystem::path&, const std::vector<std::fil
namespace testing
{
extern std::vector<std::complex<float>> make_complex_image(const types::RowCol<size_t>&);
extern std::vector<std::byte> to_bytes(const ComplexImageResult&);
extern std::vector<std::byte> to_bytes(const ComplexImageResult&, ptrdiff_t cutoff=-1);
}

}
Expand Down
4 changes: 2 additions & 2 deletions six/modules/c++/six.sicd/six.sicd.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<ClInclude Include="include\six\sicd\ComplexClassification.h" />
<ClInclude Include="include\six\sicd\ComplexData.h" />
<ClInclude Include="include\six\sicd\ComplexDataBuilder.h" />
<ClInclude Include="include\six\sicd\ComplexToAMP8IPHS8I.h" />
<ClInclude Include="include\six\sicd\ComplexXMLControl.h" />
<ClInclude Include="include\six\sicd\ComplexXMLParser.h" />
<ClInclude Include="include\six\sicd\ComplexXMLParser040.h" />
Expand All @@ -123,7 +124,6 @@
<ClInclude Include="include\six\sicd\ImageCreation.h" />
<ClInclude Include="include\six\sicd\ImageData.h" />
<ClInclude Include="include\six\sicd\ImageFormation.h" />
<ClInclude Include="include\six\sicd\KDTree.h" />
<ClInclude Include="include\six\sicd\NITFReadComplexXMLControl.h" />
<ClInclude Include="include\six\sicd\PFA.h" />
<ClInclude Include="include\six\sicd\Position.h" />
Expand All @@ -149,6 +149,7 @@
<ClCompile Include="source\AreaPlaneUtility.cpp" />
<ClCompile Include="source\ComplexData.cpp" />
<ClCompile Include="source\ComplexDataBuilder.cpp" />
<ClCompile Include="source\ComplexToAMP8IPHS8I.cpp" />
<ClCompile Include="source\ComplexXMLControl.cpp" />
<ClCompile Include="source\ComplexXMLParser.cpp" />
<ClCompile Include="source\ComplexXMLParser040.cpp" />
Expand All @@ -165,7 +166,6 @@
<ClCompile Include="source\Grid.cpp" />
<ClCompile Include="source\ImageData.cpp" />
<ClCompile Include="source\ImageFormation.cpp" />
<ClCompile Include="source\KDTree.cpp" />
<ClCompile Include="source\NITFReadComplexXMLControl.cpp" />
<ClCompile Include="source\PFA.cpp" />
<ClCompile Include="source\Position.cpp" />
Expand Down
8 changes: 4 additions & 4 deletions six/modules/c++/six.sicd/six.sicd.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@
<ClInclude Include="include\six\sicd\Utilities.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\six\sicd\KDTree.h">
<ClInclude Include="include\six\sicd\NITFReadComplexXMLControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\six\sicd\NITFReadComplexXMLControl.h">
<ClInclude Include="include\six\sicd\ComplexToAMP8IPHS8I.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down Expand Up @@ -236,10 +236,10 @@
<ClCompile Include="source\Utilities.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KDTree.cpp">
<ClCompile Include="source\NITFReadComplexXMLControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NITFReadComplexXMLControl.cpp">
<ClCompile Include="source\ComplexToAMP8IPHS8I.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions six/modules/c++/six.sicd/source/ComplexData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,15 @@ inline std::span<T> make_span(std::span<U> bytes)
return std::span<T>(static_cast<T*>(cast_to_pvoid(bytes)), size);
}

bool six::sicd::ComplexData::convertPixels_(std::span<const std::byte> from_, std::span<std::byte> to_) const
bool six::sicd::ComplexData::convertPixels_(std::span<const std::byte> from_, std::span<std::byte> to_, ptrdiff_t cutoff) const
{
if (getPixelType() != PixelType::AMP8I_PHS8I)
{
return false; // no conversion done as there is nothing to convert
}

const auto from = make_span<const six::sicd::ImageData::cx_float>(from_);
const auto to = make_span<six::sicd::ImageData::AMP8I_PHS8I_t>(to_);
imageData->to_AMP8I_PHS8I(from, to);
const auto from = make_span<const six::sicd::cx_float>(from_);
const auto to = make_span<six::sicd::AMP8I_PHS8I_t>(to_);
imageData->to_AMP8I_PHS8I(from, to, cutoff);
return true; // converted
}
Loading

0 comments on commit 091a463

Please sign in to comment.