• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 <vector>
21 #include <string>
22 
23 #include "minddata/dataset/kernels/image/sharpness_op.h"
24 #include "minddata/dataset/util/status.h"
25 
26 namespace mindspore {
27 namespace dataset {
28 
29 class RandomSharpnessOp : public SharpnessOp {
30  public:
31   static const float kDefStartDegree;
32   static const float kDefEndDegree;
33 
34   /// Adjust the sharpness of the input image by a random degree within the given range.
35   /// \@param[in] start_degree A float indicating the beginning of the range.
36   /// \@param[in] end_degree A float indicating the end of the range.
37 
38   explicit RandomSharpnessOp(float start_degree = kDefStartDegree, float end_degree = kDefEndDegree);
39   ~RandomSharpnessOp() override = default;
Print(std::ostream & out)40   void Print(std::ostream &out) const override { out << Name(); }
41 
42   Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
43 
Name()44   std::string Name() const override { return kRandomSharpnessOp; }
45 
46  protected:
47   float start_degree_;
48   float end_degree_;
49   std::uniform_real_distribution<float> distribution_{-1.0, 1.0};
50   std::mt19937 rnd_;
51 };
52 
53 }  // namespace dataset
54 }  // namespace mindspore
55 
56 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_RANDOM_SHARPNESS_OP_H_
57