2017-01-02 3 views
-2

私のアルゴリズムでは、resize_imagesは画像の色を何か変えてしまいます。どうして ?私のイメージでは、それは私のポストはほとんどのコードであるように私のポストは、ほとんどのコードであるようなので、私はいくつかの詳細を追加し、それは私が私のポストはほとんどがあるようないくつかのより多くのdetailsitが見え追加見え見えテンソルフローリサイズ画像の色が変わります

# Typical setup to include TensorFlow. 
import tensorflow as tf 
import matplotlib.pyplot as plt 

# Make a queue of file names including all the JPEG images files in the relative 
# image directory. 
filename_queue = tf.train.string_input_producer(
    tf.train.match_filenames_once("./MNIST_data/*.png")) 

reader = tf.WholeFileReader() 
key, value = reader.read(filename_queue) 

image_f = tf.image.decode_png(value) # use png or jpg decoder based on your files. 
image = tf.image.resize_images(image_f, [375, 1242]) 

#Generate batch 
# num_preprocess_threads = 1 
# min_queue_examples = 256 
# batch_size=2; 
# images = tf.train.shuffle_batch(
    # [image], 
    # batch_size=batch_size, 
    # num_threads=num_preprocess_threads, 
    # capacity=min_queue_examples + 3 * batch_size, 
    # min_after_dequeue=min_queue_examples) 

init_op = tf.initialize_all_variables() 

with tf.Session() as sess: 
    sess.run(init_op) 

    # Start populating the filename queue. 
    coord = tf.train.Coordinator() 
    threads = tf.train.start_queue_runners(coord=coord) 
    my_image = image.eval() #here is your image Tensor :) 
    print(my_image.shape) 
    fig = plt.figure() 
    plt.imshow(my_image) 
    plt.show() 

    coord.request_stop() 
    coord.join(threads) 

375行1242 colum 3チャンネルでありますコードは、私は、私はいくつかのより多くのdetailsitは私のポストは、コードの大部分があるようなので、私はいくつかの詳細tf.resize_imagesの文書から引用

+1

StackOverflowはいくつかのコーディングサービスですか?これは、あなたが2日で尋ねた6番目の質問です! – martianwars

答えて

1

追加になります追加して私のポストは、コードの大部分があるようないくつかのより多くのdetailsitが見え追加

サイズ変更された画像は、元のASP比はサイズと同じではありません。歪みを避けるには、resize_image_with_crop_or_padを参照してください。

アスペクト比が正しくないため、画像の色がゆがんでいるために変更されているようです。これが発生しないようにするには、resize_image_with_crop_or_padを使用してください。


文書を読み始めてください。彼らはあなたの質問の半分以上に答えます。

関連する問題