• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 #include "include/api/status.h"
27 #include "include/dataset/constants.h"
28 #include "include/dataset/transforms.h"
29 
30 namespace mindspore {
31 namespace dataset {
32 // Transform operations for performing computer vision.
33 namespace vision {
34 // Forward Declarations
35 class RotateOperation;
36 
37 /// \brief Apply affine transform on the input image.
38 class DATASET_API Affine final : public TensorTransform {
39  public:
40   /// \brief Constructor.
41   /// \param[in] degrees The degrees to rotate the image.
42   /// \param[in] translation The values representing vertical and horizontal translation (default = {0.0, 0.0}).
43   ///     The first value represents the x axis translation while the second represents the y axis translation.
44   /// \param[in] scale The scaling factor for the image (default = 0.0).
45   /// \param[in] shear A float vector of size 2, representing the shear degrees (default = {0.0, 0.0}).
46   /// \param[in] interpolation An enum for the mode of interpolation.
47   ///   - InterpolationMode::kLinear, Interpolation method is blinear interpolation (Only supports this mode in Lite).
48   ///   - InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.
49   ///   - InterpolationMode::kCubic, Interpolation method is bicubic interpolation.
50   ///   - InterpolationMode::kArea, Interpolation method is pixel area interpolation.
51   /// \param[in] fill_value A vector representing the value to fill the area outside the transformation
52   ///    in the output image. If 1 value is provided, it is used for all RGB channels.
53   ///    If 3 values are provided, it is used to fill R, G, B channels respectively.
54   /// \par Example
55   /// \code
56   ///     /* Define operations */
57   ///     auto decode_op = vision::Decode();
58   ///     auto affine_op = vision::Affine(30, {0.0, 0.0}, 0.8);
59   ///
60   ///     /* dataset is an instance of Dataset object */
61   ///     dataset = dataset->Map({decode_op, affine_op},  // operations
62   ///                            {"image"});              // input columns
63   /// \endcode
64   explicit Affine(float_t degrees, const std::vector<float> &translation = {0.0, 0.0}, float scale = 0.0,
65                   const std::vector<float> &shear = {0.0, 0.0},
66                   InterpolationMode interpolation = InterpolationMode::kNearestNeighbour,
67                   const std::vector<uint8_t> &fill_value = {0, 0, 0});
68 
69   /// \brief Destructor.
70   ~Affine() override = default;
71 
72   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
73   /// \return Shared pointer to TensorOperation object.
74   std::shared_ptr<TensorOperation> Parse() override;
75 
76  private:
77   struct Data;
78   std::shared_ptr<Data> data_;
79 };
80 
81 /// \brief Crop the input image at the center to the given size.
82 class DATASET_API CenterCrop final : public TensorTransform {
83  public:
84   /// \brief Constructor.
85   /// \param[in] size A vector representing the output size of the cropped image.
86   ///     If the size is a single value, a squared crop of size (size, size) is returned.
87   ///     If the size has 2 values, it should be (height, width).
88   /// \par Example
89   /// \code
90   ///     /* Define operations */
91   ///     auto decode_op = vision::Decode();
92   ///     auto crop_op = vision::CenterCrop({32, 32});
93   ///
94   ///     /* dataset is an instance of Dataset object */
95   ///     dataset = dataset->Map({decode_op, crop_op},  // operations
96   ///                            {"image"});            // input columns
97   /// \endcode
98   explicit CenterCrop(const std::vector<int32_t> &size);
99 
100   /// \brief Destructor.
101   ~CenterCrop() override = default;
102 
103  protected:
104   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
105   /// \return Shared pointer to TensorOperation object.
106   std::shared_ptr<TensorOperation> Parse() override;
107 
108   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
109 
110  private:
111   struct Data;
112   std::shared_ptr<Data> data_;
113 };
114 
115 /// \brief Crop an image based on location and crop size.
116 class DATASET_API Crop final : public TensorTransform {
117  public:
118   /// \brief Constructor.
119   /// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}.
120   /// \param[in] size Size of the cropped area.
121   ///     If the size is a single value, a squared crop of size (size, size) is returned.
122   ///     If the size has 2 values, it should be (height, width).
123   /// \par Example
124   /// \code
125   ///     /* Define operations */
126   ///     auto decode_op = vision::Decode();
127   ///     auto crop_op = vision::Crop({0, 0}, {32, 32});
128   ///
129   ///     /* dataset is an instance of Dataset object */
130   ///     dataset = dataset->Map({decode_op, crop_op},  // operations
131   ///                            {"image"});            // input columns
132   /// \endcode
133   Crop(const std::vector<int32_t> &coordinates, const std::vector<int32_t> &size);
134 
135   /// \brief Destructor.
136   ~Crop() override = default;
137 
138  protected:
139   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
140   /// \return Shared pointer to TensorOperation object.
141   std::shared_ptr<TensorOperation> Parse() override;
142 
143  private:
144   struct Data;
145   std::shared_ptr<Data> data_;
146 };
147 
148 /// \brief Decode the input image in RGB mode.
149 class DATASET_API Decode final : public TensorTransform {
150  public:
151   /// \brief Constructor.
152   /// \param[in] rgb A boolean indicating whether to decode the image in RGB mode or not.
153   /// \par Example
154   /// \code
155   ///     /* Define operations */
156   ///     auto decode_op = vision::Decode();
157   ///
158   ///     /* dataset is an instance of Dataset object */
159   ///     dataset = dataset->Map({decode_op},  // operations
160   ///                            {"image"});   // input columns
161   /// \endcode
162   explicit Decode(bool rgb = true);
163 
164   /// \brief Destructor.
165   ~Decode() override = default;
166 
167  protected:
168   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
169   /// \return Shared pointer to TensorOperation object.
170   std::shared_ptr<TensorOperation> Parse() override;
171 
172   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
173 
174  private:
175   struct Data;
176   std::shared_ptr<Data> data_;
177 };
178 
179 /// \brief Blur the input image with the specified Gaussian kernel.
180 class DATASET_API GaussianBlur final : public TensorTransform {
181  public:
182   /// \brief Constructor.
183   /// \param[in] kernel_size A vector of Gaussian kernel size for width and height. The value must be positive and odd.
184   /// \param[in] sigma A vector of Gaussian kernel standard deviation sigma for width and height. The values must be
185   ///     positive. Using default value 0 means to calculate the sigma according to the kernel size.
186   /// \par Example
187   /// \code
188   ///     /* Define operations */
189   ///     auto decode_op = vision::Decode();
190   ///     auto gaussian_op = vision::GaussianBlur({7, 7});
191   ///
192   ///     /* dataset is an instance of Dataset object */
193   ///     dataset = dataset->Map({decode_op, gaussian_op},  // operations
194   ///                            {"image"});                // input columns
195   /// \endcode
196   explicit GaussianBlur(const std::vector<int32_t> &kernel_size, const std::vector<float> &sigma = {0., 0.});
197 
198   /// \brief Destructor.
199   ~GaussianBlur() override = default;
200 
201  protected:
202   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
203   /// \return Shared pointer to TensorOperation object.
204   std::shared_ptr<TensorOperation> Parse() override;
205 
206  private:
207   struct Data;
208   std::shared_ptr<Data> data_;
209 };
210 
211 /// \brief Transpose the input image; shape (H, W, C) to shape (C, H, W).
212 class DATASET_API HWC2CHW final : public TensorTransform {
213  public:
214   /// \brief Constructor.
215   /// \par Example
216   /// \code
217   ///     /* dataset is an instance of Dataset object */
218   ///     dataset = dataset->Map({std::make_shared<vision::Decode>(),
219   ///                             std::make_shared<vision::HWC2CHW>()}, // operations
220   ///                            {"image"});                            // input columns
221   /// \endcode
222   HWC2CHW();
223 
224   /// \brief Destructor.
225   ~HWC2CHW() override = default;
226 
227  protected:
228   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
229   /// \return Shared pointer to TensorOperation object.
230   std::shared_ptr<TensorOperation> Parse() override;
231 };
232 
233 /// \brief Normalize the input image with respect to mean and standard deviation.
234 class DATASET_API Normalize final : public TensorTransform {
235  public:
236   /// \brief Constructor.
237   /// \param[in] mean A vector of mean values for each channel, with respect to channel order.
238   ///     The mean values must be in range [0.0, 255.0].
239   /// \param[in] std A vector of standard deviations for each channel, with respect to channel order.
240   ///     The standard deviation values must be in range (0.0, 255.0].
241   /// \param[in] is_hwc A boolean to indicate whether the input image is in HWC format (true) or CHW
242   ///     format (false) (Lite only supports true) (default = true).
243 
244   /// \par Example
245   /// \code
246   ///     /* Define operations */
247   ///     auto decode_op = vision::Decode();
248   ///     auto normalize_op = vision::Normalize({128, 128, 128}, {1.0, 1.0, 1.0});
249   ///
250   ///     /* dataset is an instance of Dataset object */
251   ///     dataset = dataset->Map({decode_op, normalize_op},  // operations
252   ///                            {"image"});                 // input columns
253   /// \endcode
254   Normalize(const std::vector<float> &mean, const std::vector<float> &std, bool is_hwc = true);
255 
256   /// \brief Destructor.
257   ~Normalize() override = default;
258 
259  protected:
260   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
261   /// \return Shared pointer to TensorOperation object.
262   std::shared_ptr<TensorOperation> Parse() override;
263 
264   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
265 
266  private:
267   struct Data;
268   std::shared_ptr<Data> data_;
269 };
270 
271 /// \brief Pad the image according to padding parameters.
272 class DATASET_API Pad final : public TensorTransform {
273  public:
274   /// \brief Constructor.
275   /// \param[in] padding A vector representing the number of pixels to pad the image.
276   ///    If the vector has one value, it pads all sides of the image with that value.
277   ///    If the vector has two values, it pads left and right with the first and
278   ///    top and bottom with the second value.
279   ///    If the vector has four values, it pads left, top, right, and bottom with
280   ///    those values respectively.
281   /// \param[in] fill_value A vector representing the pixel intensity of the borders. Only valid if the
282   ///    padding_mode is BorderType.kConstant. If 1 value is provided, it is used for all RGB channels.
283   ///    If 3 values are provided, it is used to fill R, G, B channels respectively.
284   /// \param[in] padding_mode The method of padding (default=BorderType.kConstant).
285   ///    Can be any of
286   ///    [BorderType.kConstant, BorderType.kEdge, BorderType.kReflect, BorderType.kSymmetric]
287   ///    - BorderType.kConstant, means it fills the border with constant values
288   ///    - BorderType.kEdge, means it pads with the last value on the edge
289   ///    - BorderType.kReflect, means it reflects the values on the edge omitting the last value of edge
290   ///    - BorderType.kSymmetric, means it reflects the values on the edge repeating the last value of edge
291   /// \par Example
292   /// \code
293   ///     /* Define operations */
294   ///     auto decode_op = vision::Decode();
295   ///     auto pad_op = vision::Pad({10, 10, 10, 10}, {255, 255, 255});
296   ///
297   ///     /* dataset is an instance of Dataset object */
298   ///     dataset = dataset->Map({decode_op, pad_op},  // operations
299   ///                            {"image"});           // input columns
300   /// \endcode
301   explicit Pad(const std::vector<int32_t> &padding, const std::vector<uint8_t> &fill_value = {0},
302                BorderType padding_mode = BorderType::kConstant);
303 
304   /// \brief Destructor.
305   ~Pad() override = default;
306 
307  protected:
308   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
309   /// \return Shared pointer to TensorOperation object.
310   std::shared_ptr<TensorOperation> Parse() override;
311 
312  private:
313   struct Data;
314   std::shared_ptr<Data> data_;
315 };
316 
317 /// \brief Apply a Random Affine transformation on the input image in RGB or Greyscale mode.
318 class DATASET_API RandomAffine final : public TensorTransform {
319  public:
320   /// \brief Constructor.
321   /// \param[in] degrees A float vector of size 2, representing the starting and ending degree.
322   /// \param[in] translate_range A float vector of size 2 or 4, representing percentages of translation on x and y axes.
323   ///    If the size is 2, (min_dx, max_dx, 0, 0).
324   ///    If the size is 4, (min_dx, max_dx, min_dy, max_dy),
325   ///    all values are in range [-1, 1].
326   /// \param[in] scale_range A float vector of size 2, representing the starting and ending scales in the range.
327   /// \param[in] shear_ranges A float vector of size 2 or 4, representing the starting and ending shear degrees
328   ///    vertically and horizontally.
329   ///    If the size is 2, (min_shear_x, max_shear_x, 0, 0),
330   ///    if the size is 4, (min_shear_x, max_shear_x, min_shear_y, max_shear_y).
331   /// \param[in] interpolation An enum for the mode of interpolation.
332   ///   - InterpolationMode::kLinear, Interpolation method is blinear interpolation (Only supports this mode in Lite).
333   ///   - InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.
334   ///   - InterpolationMode::kCubic, Interpolation method is bicubic interpolation.
335   ///   - InterpolationMode::kArea, Interpolation method is pixel area interpolation.
336   /// \param[in] fill_value A vector representing the value to fill the area outside the transform
337   ///    in the output image. If 1 value is provided, it is used for all RGB channels.
338   ///    If 3 values are provided, it is used to fill R, G and B channels respectively.
339   /// \par Example
340   /// \code
341   ///     /* Define operations */
342   ///     auto decode_op = vision::Decode();
343   ///     auto random_op = vision::RandomAffine({45, 90});
344   ///
345   ///     /* dataset is an instance of Dataset object */
346   ///     dataset = dataset->Map({decode_op, random_op},  // operations
347   ///                            {"image"});              // input columns
348   /// \endcode
349   explicit RandomAffine(const std::vector<float_t> &degrees,
350                         const std::vector<float_t> &translate_range = {0.0, 0.0, 0.0, 0.0},
351                         const std::vector<float_t> &scale_range = {1.0, 1.0},
352                         const std::vector<float_t> &shear_ranges = {0.0, 0.0, 0.0, 0.0},
353                         InterpolationMode interpolation = InterpolationMode::kNearestNeighbour,
354                         const std::vector<uint8_t> &fill_value = {0, 0, 0});
355 
356   /// \brief Destructor.
357   ~RandomAffine() override = default;
358 
359   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
360   /// \return Shared pointer to TensorOperation object.
361   std::shared_ptr<TensorOperation> Parse() override;
362 
363  private:
364   struct Data;
365   std::shared_ptr<Data> data_;
366 };
367 
368 /// \brief Rescale the pixel value of input image.
369 class DATASET_API Rescale final : public TensorTransform {
370  public:
371   /// \brief Constructor.
372   /// \param[in] rescale Rescale factor.
373   /// \param[in] shift Shift factor.
374   /// \par Example
375   /// \code
376   ///     /* Define operations */
377   ///     auto decode_op = vision::Decode();
378   ///     auto rescale_op = vision::Rescale(1.0, 0.0);
379   ///
380   ///     /* dataset is an instance of Dataset object */
381   ///     dataset = dataset->Map({decode_op, rescale_op},  // operations
382   ///                            {"image"});               // input columns
383   /// \endcode
384   Rescale(float rescale, float shift);
385 
386   /// \brief Destructor.
387   ~Rescale() override = default;
388 
389  protected:
390   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
391   /// \return Shared pointer to TensorOperation object.
392   std::shared_ptr<TensorOperation> Parse() override;
393 
394  private:
395   struct Data;
396   std::shared_ptr<Data> data_;
397 };
398 
399 /// \brief Resize the input image to the given size.
400 class DATASET_API Resize final : public TensorTransform {
401  public:
402   /// \brief Constructor.
403   /// \param[in] size A vector representing the output size of the resized image.
404   ///     If the size is a single value, the image will be resized to this value with
405   ///     the same image aspect ratio. If the size has 2 values, it should be (height, width).
406   /// \param[in] interpolation An enum for the mode of interpolation.
407   ///   - InterpolationMode::kLinear, Interpolation method is blinear interpolation (Only supports this mode in Lite).
408   ///   - InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.
409   ///   - InterpolationMode::kCubic, Interpolation method is bicubic interpolation.
410   ///   - InterpolationMode::kArea, Interpolation method is pixel area interpolation.
411   ///   - InterpolationMode::kCubicPil, Interpolation method is bicubic interpolation like implemented in pillow.
412   /// \par Example
413   /// \code
414   ///     /* Define operations */
415   ///     auto decode_op = vision::Decode();
416   ///     auto resize_op = vision::Resize({224, 224}, InterpolationMode::kLinear);
417   ///
418   ///     /* dataset is an instance of Dataset object */
419   ///     dataset = dataset->Map({decode_op, resize_op},  // operations
420   ///                            {"image"});              // input columns
421   /// \endcode
422   explicit Resize(const std::vector<int32_t> &size, InterpolationMode interpolation = InterpolationMode::kLinear);
423 
424   /// \brief Destructor.
425   ~Resize() override = default;
426 
427  protected:
428   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
429   /// \return Shared pointer to TensorOperation object.
430   std::shared_ptr<TensorOperation> Parse() override;
431 
432   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
433 
434  private:
435   struct Data;
436   std::shared_ptr<Data> data_;
437 };
438 
439 /// \brief Keep the original picture ratio and fills the rest.
440 class DATASET_API ResizePreserveAR final : public TensorTransform {
441  public:
442   /// \brief Constructor.
443   /// \param[in] height The height of image output value after resizing.
444   /// \param[in] width The width of image output value after resizing.
445   /// \param[in] img_orientation optional rotation angle.
446   ///     - img_orientation = 1, Rotate 0 degree.
447   ///     - img_orientation = 2, Rotate 0 degree and apply horizontal flip.
448   ///     - img_orientation = 3, Rotate 180 degree.
449   ///     - img_orientation = 4, Rotate 180 degree and apply horizontal flip.
450   ///     - img_orientation = 5, Rotate 90 degree and apply horizontal flip.
451   ///     - img_orientation = 6, Rotate 90 degree.
452   ///     - img_orientation = 7, Rotate 270 degree and apply horizontal flip.
453   ///     - img_orientation = 8, Rotate 270 degree.
454   /// \par Example
455   /// \code
456   ///     /* Define operations */
457   ///     auto decode_op = vision::Decode();
458   ///     auto resize_op = vision::ResizePreserveAR(224, 224);
459   ///
460   ///     /* dataset is an instance of Dataset object */
461   ///     dataset = dataset->Map({decode_op, resize_op},  // operations
462   ///                            {"image"});              // input columns
463   /// \endcode
464   ResizePreserveAR(int32_t height, int32_t width, int32_t img_orientation = 0);
465 
466   /// \brief Destructor.
467   ~ResizePreserveAR() override = default;
468 
469  protected:
470   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
471   /// \return Shared pointer to TensorOperation object.
472   std::shared_ptr<TensorOperation> Parse() override;
473 
474  private:
475   struct Data;
476   std::shared_ptr<Data> data_;
477 };
478 
479 /// \brief RGB2BGR TensorTransform.
480 /// \note Convert the format of input image from RGB to BGR.
481 class DATASET_API RGB2BGR final : public TensorTransform {
482  public:
483   /// \brief Constructor.
484   /// \par Example
485   /// \code
486   ///     /* Define operations */
487   ///     auto decode_op = vision::Decode();
488   ///     auto rgb2bgr_op = vision::RGB2BGR();
489   ///
490   ///     /* dataset is an instance of Dataset object */
491   ///     dataset = dataset->Map({decode_op, rgb2bgr_op},  // operations
492   ///                            {"image"});               // input columns
493   /// \endcode
494   RGB2BGR() = default;
495 
496   /// \brief Destructor.
497   ~RGB2BGR() override = default;
498 
499  protected:
500   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
501   /// \return Shared pointer to TensorOperation object.
502   std::shared_ptr<TensorOperation> Parse() override;
503 };
504 
505 /// \brief RGB2GRAY TensorTransform.
506 /// \note Convert RGB image or color image to grayscale image.
507 /// \brief Convert a RGB image or color image to a grayscale one.
508 class DATASET_API RGB2GRAY final : public TensorTransform {
509  public:
510   /// \brief Constructor.
511   /// \par Example
512   /// \code
513   ///     /* Define operations */
514   ///     auto decode_op = vision::Decode();
515   ///     auto rgb2gray_op = vision::RGB2GRAY();
516   ///
517   ///     /* dataset is an instance of Dataset object */
518   ///     dataset = dataset->Map({decode_op, rgb2gray_op},  // operations
519   ///                            {"image"});                // input columns
520   /// \endcode
521   RGB2GRAY() = default;
522 
523   /// \brief Destructor.
524   ~RGB2GRAY() override = default;
525 
526  protected:
527   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
528   /// \return Shared pointer to TensorOperation object.
529   std::shared_ptr<TensorOperation> Parse() override;
530 };
531 
532 /// \brief Rotate the input image according to parameters.
533 class DATASET_API Rotate final : public TensorTransform {
534  public:
535   /// \brief Constructor.
536   /// \note This api is only used in Lite, the interpolation mode is bilinear.
537   /// \param[in] angle_id The fix rotation angle.
538   ///     - FixRotationAngle::k0Degree = 1, Rotate 0 degree.
539   ///     - FixRotationAngle::k0DegreeAndMirror = 2, Rotate 0 degree and apply horizontal flip.
540   ///     - FixRotationAngle::k180Degree = 3, Rotate 180 degree.
541   ///     - FixRotationAngle::k180DegreeAndMirror = 4, Rotate 180 degree and apply horizontal flip.
542   ///     - FixRotationAngle::k90DegreeAndMirror = 5, Rotate 90 degree and apply horizontal flip.
543   ///     - FixRotationAngle::k90Degree = 6, Rotate 90 degree.
544   ///     - FixRotationAngle::k270DegreeAndMirror = 7, Rotate 270 degree and apply horizontal flip.
545   ///     - FixRotationAngle::k270Degree = 8, Rotate 270 degree.
546   /// \par Example
547   /// \code
548   ///     /* Define operations */
549   ///     auto decode_op = vision::Decode();
550   ///     auto rotate_op = vision::Rotate(FixRotationAngle::k90Degree);
551   ///
552   ///     /* dataset is an instance of Dataset object */
553   ///     dataset = dataset->Map({decode_op, rotate_op},  // operations
554   ///                            {"image"});              // input columns
555   /// \endcode
556   explicit Rotate(FixRotationAngle angle_id = FixRotationAngle::k0Degree);
557 
558   /// \brief Constructor.
559   /// \param[in] degrees A float value, representing the rotation degrees.
560   /// \param[in] resample An enum for the mode of interpolation.
561   ///   - InterpolationMode::kLinear, Interpolation method is blinear interpolation.
562   ///   - InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.
563   ///   - InterpolationMode::kCubic, Interpolation method is bicubic interpolation.
564   ///   - InterpolationMode::kArea, Interpolation method is pixel area interpolation.
565   /// \param[in] expand A boolean representing whether the image is expanded after rotation.
566   /// \param[in] center A float vector of size 2 or empty, representing the x and y center of rotation
567   ///     or the center of the image.
568   /// \param[in] fill_value A vector representing the value to fill the area outside the transform
569   ///    in the output image. If 1 value is provided, it is used for all RGB channels.
570   ///    If 3 values are provided, it is used to fill R, G, B channels respectively.
571   /// \par Example
572   /// \code
573   ///     /* Define operations */
574   ///     auto decode_op = vision::Decode();
575   ///     auto rotate_op = vision::Rotate(90);
576   ///
577   ///     /* dataset is an instance of Dataset object */
578   ///     dataset = dataset->Map({decode_op, rotate_op},  // operations
579   ///                            {"image"});              // input columns
580   /// \endcode
581   explicit Rotate(float degrees, InterpolationMode resample = InterpolationMode::kNearestNeighbour, bool expand = false,
582                   const std::vector<float> &center = {}, const std::vector<uint8_t> &fill_value = {0, 0, 0});
583 
584   /// \brief Destructor.
585   ~Rotate() override = default;
586 
587  protected:
588   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
589   /// \return Shared pointer to TensorOperation object.
590   std::shared_ptr<TensorOperation> Parse() override;
591 
592  private:
593   std::shared_ptr<RotateOperation> op_;
594   struct Data;
595   std::shared_ptr<Data> data_;
596 };
597 
598 /// \brief Swap the red and blue channels of the input image.
599 class DATASET_API SwapRedBlue final : public TensorTransform {
600  public:
601   /// \brief Constructor.
602   /// \par Example
603   /// \code
604   ///     /* Define operations */
605   ///     auto decode_op = vision::Decode();
606   ///     auto swap_red_blue_op = vision::SwapRedBlue();
607   ///
608   ///     /* dataset is an instance of Dataset object */
609   ///     dataset = dataset->Map({decode_op, swap_red_blue_op},  // operations
610   ///                            {"image"});                     // input columns
611   /// \endcode
612   SwapRedBlue();
613 
614   /// \brief Destructor.
615   ~SwapRedBlue() override = default;
616 
617  protected:
618   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
619   /// \return Shared pointer to TensorOperation object.
620   std::shared_ptr<TensorOperation> Parse() override;
621 };
622 }  // namespace vision
623 }  // namespace dataset
624 }  // namespace mindspore
625 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_LITE_H_
626