Home | History | Annotate | Download | only in ops
      1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #include "tensorflow/core/framework/common_shape_fns.h"
     17 #include "tensorflow/core/framework/op.h"
     18 #include "tensorflow/core/framework/shape_inference.h"
     19 
     20 namespace tensorflow {
     21 
     22 using shape_inference::InferenceContext;
     23 
     24 // --------------------------------------------------------------------------
     25 REGISTER_OP("AdjustHsvInYiq")
     26     .Input("images: T")
     27     .Input("delta_h: float")
     28     .Input("scale_s: float")
     29     .Input("scale_v: float")
     30     .Output("output: T")
     31     .Attr("T: {uint8, int8, int16, int32, int64, half, float, double}")
     32     .SetShapeFn([](InferenceContext* c) {
     33       return shape_inference::UnchangedShapeWithRankAtLeast(c, 3);
     34     })
     35     .Doc(R"Doc(
     36 Adjust the YIQ hue of one or more images.
     37 
     38 `images` is a tensor of at least 3 dimensions.  The last dimension is
     39 interpretted as channels, and must be three.
     40 
     41 We used linear transfomation described in:
     42  beesbuzz.biz/code/hsv_color_transforms.php
     43 The input image is considered in the RGB colorspace. Conceptually, the RGB
     44 colors are first mapped into YIQ space, rotated around the Y channel by
     45 delta_h in radians, multiplying the chrominance channels (I, Q)  by scale_s,
     46 multiplying all channels (Y, I, Q)  by scale_v, and then remapped back to RGB
     47 colorspace. Each operation described above is a linear transformation.
     48 
     49 images: Images to adjust.  At least 3-D.
     50 delta_h: A float scale that represents the hue rotation amount, in radians.
     51          Although delta_h can be any float value.
     52 scale_s: A float scale that represents the factor to multiply the saturation by.
     53          scale_s needs to be non-negative.
     54 scale_v: A float scale that represents the factor to multiply the value by.
     55          scale_v needs to be non-negative.
     56 output: The hsv-adjusted image or images. No clipping will be done in this op.
     57         The client can clip them using additional ops in their graph.
     58 )Doc");
     59 
     60 }  // namespace tensorflow
     61