LABCOMデータ処理が扱うイメージタイプ
バイト長
TypeError
[説 明] イメージタイプから、その1サンプルのバイト長を算出する。
# File labcom/Labcom_m.rb, line 69 def to_bytes_per_sample( image_type ) return 2 if image_type == 'YUY2' pos = image_type.index('INT') pos = image_type.index('FLT') if nil == pos if nil != pos then val = image_type[3..-1].to_i else pos = image_type.index('GRAY') pos = image_type.index('GREY') if nil == pos if nil != pos then val = image_type[4..-1].to_i else if nil != image_type.index('YUV') then val = 16 end end end if nil == val then rgb_r = image_type.index('R') rgb_g = image_type.index('G') rgb_b = image_type.index('B') if nil != rgb_r and nil != rgb_g and nil != rgb_b then val = 32 end end if nil != val then return 1 if 9 > val return 2 if 17 > val return 4 if 33 > val return 8 if 65 > val end raise TypeError, 'Image type( ' + image_type + ' ) is unknown.' end
LABCOMデータ処理が扱うイメージタイプ
NArrayクラスが扱うデータタイプ
TypeError
[説 明] イメージタイプをNArrayクラスが扱うデータタイプに変換する。 INT64は未サポート(NArray)
# File labcom/Labcom_m.rb, line 20 def to_narray_type( image_type ) return NArray::BYTE if image_type == 'INT8' return NArray::SINT if image_type == 'INT16' return NArray::LINT if image_type == 'INT32' # return NArray::LLINT if image_type == 'INT64' return NArray::SFLOAT if image_type == 'FLT32' return NArray::DFLOAT if image_type == 'FLT64' return NArray::SINT if image_type == 'YUY2' pos = image_type.index('GRAY') pos = image_type.index('GREY') if nil == pos if nil != pos then val = image_type[4..-1].to_i else if nil != image_type.index('YUV') then val = 16 end end if nil == val then rgb_r = image_type.index('R') rgb_g = image_type.index('G') rgb_b = image_type.index('B') if nil != rgb_r and nil != rgb_g and nil != rgb_b then val = 32 end end if nil != val then return NArray::BYTE if 9 > val return NArray::SINT if 17 > val return NArray::LINT if 33 > val # return NArray::LLINT if 65 > val end raise TypeError, 'Image type( ' + image_type + ' ) is unknown.' end