Skip to content

Commit

Permalink
Added missing methods to Sel. Other little fixes and addition.
Browse files Browse the repository at this point in the history
  • Loading branch information
horndude77 committed Jan 24, 2009
1 parent 9d03451 commit 856356a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/leptonica.rb
Expand Up @@ -284,6 +284,10 @@ def estimate_global_threshold
threshold_pointer.get_int32(0)
end

def rgb_to_gray
Pix.new(LeptonicaFFI.pixConvertRGBToLuminance(pointer))
end

###
# Skew
###
Expand Down Expand Up @@ -327,6 +331,11 @@ def clip(box)
Pix.new(LeptonicaFFI.pixClipRectangle(pointer, box.pointer, nil))
end

def crop(x, y, w, h)
box = Box.create(x, y, w, h)
clip(box)
end

###
# Borders
###
Expand Down Expand Up @@ -445,7 +454,7 @@ def draw_line(x1, y1, x2, y2, width = 2)
# Morph app
###

def remove_matched_pattern!(pattern, erosion, cx, cy, pixels_to_remove=0)
def remove_matched_pattern!(pattern, erosion, cx, cy, pixels_to_remove=1)
LeptonicaFFI.pixRemoveMatchedPattern(pointer, pattern.pointer, erosion.pointer, cx, cy, pixels_to_remove)
self
end
Expand Down Expand Up @@ -522,6 +531,18 @@ def set_origin(y, x)
LeptonicaFFI.selSetOrigin(pointer, y, x)
end

def height
int_pointer = MemoryPointer.new :int32
LeptonicaFFI.selGetParameters(pointer, int_pointer, nil, nil, nil)
int_pointer.get_int32(0)
end

def width
int_pointer = MemoryPointer.new :int32
LeptonicaFFI.selGetParameters(pointer, nil, int_pointer, nil, nil)
int_pointer.get_int32(0)
end

def cy
int_pointer = MemoryPointer.new :int32
LeptonicaFFI.selGetParameters(pointer, nil, nil, int_pointer, nil)
Expand Down

0 comments on commit 856356a

Please sign in to comment.