RGBからHSV色空間に変換後、すべて青で表現される。

前提

TensorflowでHSV色空間を利用して、画像分類を勉強しています。
tf.image.rgb_to_hsv()で、rgbからhsvに変換後、画像を出力したのですが、画像がすべて青で表現されています。HSV色空間ではこれが普通なのでしょうか?
私の知識ですと、各ピクセルごとにHSVの要素が組まれていると認識しているのですが、すべて青になる理由がありましたら、教えていただきたいです。

実現したいこと

原因の解明

該当のソースコード

import tensorflow as tf from tensorflow import keras import cv2 as cv import numpy as np import matplotlib.pyplot as plt import glob import os x_train = [] #訓練用のimage y_train = [] #訓練用のlabels  x_test = [] #テスト用のimage y_test = [] #テスト用のimage #画像の読み込み for f in glob.glob(".\image1\*\*\*.jpg"): img_data = tf.io.read_file(f) img_data = tf.io.decode_jpeg(img_data, channels=3, ratio=2) img_data = tf.image.resize(img_data,[150,100])  #縦,横 img_data = tf.image.rgb_to_hsv(img_data)     #hsv変換 #各配列に振り分け if f.split("\\")[2] == "train": x_train.append(img_data) y_train.append(int(f.split("\\")[3].split("_")[0])) elif f.split("\\")[2] =="test": x_test.append(img_data) y_test.append(int(f.split("\\")[3].split("_")[0])) #正規化 x_train = np.array(x_train) / 255.0 y_train = np.array(y_train) x_test = np.array(x_test) / 255.0 y_test = np.array(y_test) print("要素数, x, y, チャンネル数") print("x_train(訓練データ): "+str(x_train.shape)) print("y_train(訓練データラベル): "+str(y_train.shape)) print("x_test(テストデータ): "+str(x_test.shape)) print("y_test(テストデータラベル): "+str(y_test.shape))

イメージ説明
イメージ説明
このように全体的に青で表示される。

コメントを投稿

0 コメント