Skip to content

Implement AddBorder #206

@morousg

Description

@morousg

Simply, add a border defined by 4 int numbers, top, bottom, left and right, that will define how many pixell we need to add on each direction.

General Structure:

Builder -> struct AddBorder;
Incomplete -> template <AddBorderType ABT> struct AddBorderIncomplete;
Complete -> template <AddBorderType ABT, typename BackIOp> struct AddBorderComplete;

File add_border_complete.h

enum class AddBorderType { CONSTANT, BORDER_READER };

template <AddBorderType ABT, typename T = void>
struct AddBorderParams;

template <>
struct AddBorderParams<AddBorderType::BODER_READER, void> {
    int top, bottom, left, right;
};

template <typename T>
struct AddBorderParams<AddBorderType::CONSTANT, T> {
    int top, bottom, left, right;
    T borderValue;
};

template <AddBorderType ABT, typename BackIOp_>
struct AddBorderComplete;

template <typename BackIOp_>
struct AddBorderComplete<AddBorderType::CONSTANT, BackIOp_> {
    using ParamsType = AddBorderParams<AddBorderType::CONSTANT>;
    using BackIOp = BackIOp_;
};

template <typename BackIOp_>
struct AddBorderComplete<AddBorderType::BODER_READER, BackIOp_> {
    using ParamsType =  AddBorderParams<AddBorderType::BODER_READER, typename BackIOp::Operation::OutputType>;
    using BackIOp = BackIOp_;
};

File add_border.h

// Incomplete
template <AddBorderType ABT>
struct AddBorderIncomplete {
    template <typename NewBackIOp>
    FK_HOST_FUSE auto build(const NewBackIOp& backIOp, const InstantiableType& selfIOp);
};

// Builder
struct AddBorder {
    template <typename T, typename BackIOp>
    FK_HOST_FUSE auto build(const int top, const int bottom, const int left, const int right, const T borderValue, const BackIOp& iOp);
    template <typename BackIOp>
    FK_HOST_FUSE auto build(const int top, const int bottom, const int left, const int right, const BackIOp& iOp);
    template <typename T>
    FK_HOST_FUSE auto build(const int top, const int bottom, const int left, const int right, const T borderValue);
    FK_HOST_FUSE auto build(const int top, const int bottom, const int left, const int right);
};

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions