Class: Naiso::RowAnalyzer
- Inherits:
-
Object
- Object
- Naiso::RowAnalyzer
- Defined in:
- lib/naiso/row_analyzer.rb
Overview
이미지 행 분석기
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#complexity ⇒ Object
각 행의 콘텐츠 복잡도 (지연 계산).
-
#img_array ⇒ Object
이미지를 Numo::NArray로 변환 (지연 로딩).
-
#initialize(image) ⇒ RowAnalyzer
constructor
A new instance of RowAnalyzer.
-
#variance ⇒ Object
각 행의 색상 분산 (지연 계산).
Constructor Details
#initialize(image) ⇒ RowAnalyzer
Returns a new instance of RowAnalyzer.
11 12 13 14 15 16 17 18 |
# File 'lib/naiso/row_analyzer.rb', line 11 def initialize(image) @image = image @width = image.width @height = image.height @variance = nil @complexity = nil @img_array = nil end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
9 10 11 |
# File 'lib/naiso/row_analyzer.rb', line 9 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
9 10 11 |
# File 'lib/naiso/row_analyzer.rb', line 9 def width @width end |
Instance Method Details
#complexity ⇒ Object
각 행의 콘텐츠 복잡도 (지연 계산)
39 40 41 |
# File 'lib/naiso/row_analyzer.rb', line 39 def complexity @complexity ||= calculate_complexity end |
#img_array ⇒ Object
이미지를 Numo::NArray로 변환 (지연 로딩)
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/naiso/row_analyzer.rb', line 21 def img_array @img_array ||= begin # Vips 이미지를 메모리 배열로 변환 bands = @image.bands data = @image.write_to_memory # 바이트 배열을 NArray로 변환 arr = Numo::UInt8.from_binary(data) arr.reshape(@height, @width, bands) end end |
#variance ⇒ Object
각 행의 색상 분산 (지연 계산)
34 35 36 |
# File 'lib/naiso/row_analyzer.rb', line 34 def variance @variance ||= calculate_variance end |