当前位置: 首页>>代码示例>>Python>>正文


Python image_ops.hsv_to_rgb函数代码示例

本文整理汇总了Python中tensorflow.python.ops.image_ops.hsv_to_rgb函数的典型用法代码示例。如果您正苦于以下问题:Python hsv_to_rgb函数的具体用法?Python hsv_to_rgb怎么用?Python hsv_to_rgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hsv_to_rgb函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testBatch

  def testBatch(self):
    # Build an arbitrary RGB image
    np.random.seed(7)
    batch_size = 5
    shape = (batch_size, 2, 7, 3)

    for nptype in self.float_types:
      inp = GenerateNumpyRandomRGB(shape).astype(nptype)

      # Convert to HSV and back, as a batch and individually
      with self.test_session() as sess:
        batch0 = array_ops.placeholder(nptype, shape=shape)
        with self.test_scope():
          batch1 = image_ops.rgb_to_hsv(batch0)
          batch2 = image_ops.hsv_to_rgb(batch1)
        split0 = array_ops.unstack(batch0)
        with self.test_scope():
          split1 = list(map(image_ops.rgb_to_hsv, split0))
          split2 = list(map(image_ops.hsv_to_rgb, split1))
        join1 = array_ops.stack(split1)
        join2 = array_ops.stack(split2)
        batch1, batch2, join1, join2 = sess.run([batch1, batch2, join1, join2],
                                                {batch0: inp})

      # Verify that processing batch elements together is the same as separate
      self.assertAllClose(batch1, join1)
      self.assertAllClose(batch2, join2)
      self.assertAllCloseAccordingToType(
          batch2, inp, bfloat16_atol=0.03, half_rtol=0.02)
开发者ID:BhaskarNallani,项目名称:tensorflow,代码行数:29,代码来源:image_ops_test.py

示例2: testRGBToHSVRoundTrip

 def testRGBToHSVRoundTrip(self):
   data = [0, 5, 13, 54, 135, 226, 37, 8, 234, 90, 255, 1]
   rgb_np = np.array(data, dtype=np.float32).reshape([2, 2, 3]) / 255.
   for use_gpu in [True, False]:
     with self.test_session(use_gpu=use_gpu):
       hsv = image_ops.rgb_to_hsv(rgb_np)
       rgb = image_ops.hsv_to_rgb(hsv)
       rgb_tf = rgb.eval()
   self.assertAllClose(rgb_tf, rgb_np)
开发者ID:hbali-sara,项目名称:tensorflow,代码行数:9,代码来源:image_ops_test.py

示例3: testRGBToHSVRoundTrip

 def testRGBToHSVRoundTrip(self):
   data = [0, 5, 13, 54, 135, 226, 37, 8, 234, 90, 255, 1]
   for nptype in self.float_types:
     rgb_np = np.array(data, dtype=nptype).reshape([2, 2, 3]) / 255.
     with self.test_session():
       placeholder = array_ops.placeholder(nptype)
       with self.test_scope():
         hsv = image_ops.rgb_to_hsv(placeholder)
         rgb = image_ops.hsv_to_rgb(hsv)
       rgb_tf = rgb.eval(feed_dict={placeholder: rgb_np})
     self.assertAllCloseAccordingToType(rgb_tf, rgb_np, bfloat16_atol=0.03)
开发者ID:BhaskarNallani,项目名称:tensorflow,代码行数:11,代码来源:image_ops_test.py

示例4: testBatch

  def testBatch(self):
    # Build an arbitrary RGB image
    np.random.seed(7)
    batch_size = 5
    shape = (batch_size, 2, 7, 3)
    inp = np.random.rand(*shape).astype(np.float32)

    # Convert to HSV and back, as a batch and individually
    with self.test_session() as sess:
      batch0 = constant_op.constant(inp)
      batch1 = image_ops.rgb_to_hsv(batch0)
      batch2 = image_ops.hsv_to_rgb(batch1)
      split0 = array_ops.unpack(batch0)
      split1 = map(image_ops.rgb_to_hsv, split0)
      split2 = map(image_ops.hsv_to_rgb, split1)
      join1 = array_ops.pack(split1)
      join2 = array_ops.pack(split2)
      batch1, batch2, join1, join2 = sess.run([batch1, batch2, join1, join2])

    # Verify that processing batch elements together is the same as separate
    self.assertAllClose(batch1, join1)
    self.assertAllClose(batch2, join2)
    self.assertAllClose(batch2, inp)
开发者ID:hbali-sara,项目名称:tensorflow,代码行数:23,代码来源:image_ops_test.py


注:本文中的tensorflow.python.ops.image_ops.hsv_to_rgb函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。