You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tf.image.cs 4.1 kB

6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*****************************************************************************
  2. Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ******************************************************************************/
  13. using System.Collections.Generic;
  14. using Tensorflow.IO;
  15. namespace Tensorflow
  16. {
  17. public partial class tensorflow
  18. {
  19. public image_internal image = new image_internal();
  20. public class image_internal
  21. {
  22. public Tensor decode_jpeg(Tensor contents,
  23. int channels = 0,
  24. int ratio = 1,
  25. bool fancy_upscaling = true,
  26. bool try_recover_truncated = false,
  27. float acceptable_fraction = 1,
  28. string dct_method = "",
  29. string name = null)
  30. => gen_image_ops.decode_jpeg(contents, channels: channels, ratio: ratio,
  31. fancy_upscaling: fancy_upscaling, try_recover_truncated: try_recover_truncated,
  32. acceptable_fraction: acceptable_fraction, dct_method: dct_method);
  33. public Tensor resize_bilinear(Tensor images, Tensor size, bool align_corners = false, string name = null)
  34. => gen_image_ops.resize_bilinear(images, size, align_corners: align_corners, name: name);
  35. public Tensor resize_images(Tensor images, Tensor size, ResizeMethod method = ResizeMethod.BILINEAR,
  36. bool align_corners = false, bool preserve_aspect_ratio = false, string name = null)
  37. => image_ops_impl.resize_images(images, size, method: method,
  38. align_corners: align_corners, preserve_aspect_ratio: preserve_aspect_ratio, name: name);
  39. public Tensor convert_image_dtype(Tensor image, TF_DataType dtype, bool saturate = false, string name = null)
  40. => gen_image_ops.convert_image_dtype(image, dtype, saturate: saturate, name: name);
  41. public Tensor decode_image(Tensor contents, int channels = 0, TF_DataType dtype = TF_DataType.TF_UINT8,
  42. string name = null, bool expand_animations = true)
  43. => image_ops_impl.decode_image(contents, channels: channels, dtype: dtype,
  44. name: name, expand_animations: expand_animations);
  45. /// <summary>
  46. /// Convenience function to check if the 'contents' encodes a JPEG image.
  47. /// </summary>
  48. /// <param name="contents"></param>
  49. /// <param name="name"></param>
  50. /// <returns></returns>
  51. public Tensor is_jpeg(Tensor contents, string name = null)
  52. => image_ops_impl.is_jpeg(contents, name: name);
  53. /// <summary>
  54. /// Resize `images` to `size` using nearest neighbor interpolation.
  55. /// </summary>
  56. /// <param name="images"></param>
  57. /// <param name="size"></param>
  58. /// <param name="align_corners"></param>
  59. /// <param name="name"></param>
  60. /// <param name="half_pixel_centers"></param>
  61. /// <returns></returns>
  62. public Tensor resize_nearest_neighbor<Tsize>(Tensor images, Tsize size, bool align_corners = false,
  63. string name = null, bool half_pixel_centers = false)
  64. => image_ops_impl.resize_nearest_neighbor(images, size, align_corners: align_corners,
  65. name: name, half_pixel_centers: half_pixel_centers);
  66. }
  67. }
  68. }