1 /** 2 * Copyright 2020-2023 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RANDOM_SHARPNESS_OP_H_ 17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RANDOM_SHARPNESS_OP_H_ 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "minddata/dataset/kernels/tensor_op.h" 24 #include "minddata/dataset/util/status.h" 25 26 namespace mindspore { 27 namespace dataset { 28 class RandomSharpnessOp : public RandomTensorOp { 29 public: 30 /// Adjust the sharpness of the input image by a random degree within the given range. 31 /// \@param[in] start_degree A float indicating the beginning of the range. 32 /// \@param[in] end_degree A float indicating the end of the range. 33 explicit RandomSharpnessOp(float start_degree, float end_degree); 34 35 ~RandomSharpnessOp() override = default; 36 Print(std::ostream & out)37 void Print(std::ostream &out) const override { out << Name(); } 38 39 Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override; 40 Name()41 std::string Name() const override { return kRandomSharpnessOp; } 42 43 protected: 44 float start_degree_; 45 float end_degree_; 46 std::uniform_real_distribution<float> distribution_{-1.0, 1.0}; 47 }; 48 } // namespace dataset 49 } // namespace mindspore 50 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RANDOM_SHARPNESS_OP_H_ 51