imagetooth 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +339 -0
- data/README +1 -339
- data/README~ +0 -0
- data/TODO +0 -0
- data/bin/imagetooth +0 -1
- data/doc/classes/ImageTooth.html +390 -0
- data/doc/classes/ImageTooth.src/M000001.html +20 -0
- data/doc/classes/ImageTooth.src/M000002.html +18 -0
- data/doc/classes/ImageTooth.src/M000003.html +18 -0
- data/doc/classes/ImageTooth.src/M000004.html +29 -0
- data/doc/classes/ImageTooth.src/M000005.html +51 -0
- data/doc/classes/ImageTooth.src/M000006.html +32 -0
- data/doc/classes/ImageTooth.src/M000007.html +25 -0
- data/doc/classes/ImageTooth.src/M000008.html +31 -0
- data/doc/classes/ImageTooth.src/M000009.html +36 -0
- data/doc/classes/ImageTooth.src/M000010.html +18 -0
- data/doc/classes/ImageTooth.src/M000011.html +18 -0
- data/doc/classes/ImageTooth.src/M000012.html +24 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/image_tooth_rb.html +135 -0
- data/doc/fr_class_index.html +27 -0
- data/doc/fr_file_index.html +27 -0
- data/doc/fr_method_index.html +38 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/imagetooth.gemspec +2 -2
- data/lib/image_tooth.rb +77 -3
- data/spec/wrrgw.png +0 -0
- data.tar.gz.sig +0 -0
- metadata +32 -4
- metadata.gz.sig +0 -0
- data/imagetooth-0.0.5.gem +0 -0
data/lib/image_tooth.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
##########################################################################
|
3
|
-
# Copyright (C) 2007 Ramos,
|
3
|
+
# Copyright (C) 2007 Ramos, Gaston - ramos.gaston@gmail.com
|
4
4
|
#
|
5
5
|
# This program is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
@@ -39,6 +39,10 @@ class ImageTooth
|
|
39
39
|
@@colors.keys
|
40
40
|
end
|
41
41
|
|
42
|
+
|
43
|
+
# Generate the base tooth image, with all faces in white color.
|
44
|
+
# This are store in root_path/base_path.png
|
45
|
+
|
42
46
|
def graph_base file = @file_name_base
|
43
47
|
background = Image.new(25, 35)
|
44
48
|
gc = Draw.new
|
@@ -54,6 +58,19 @@ class ImageTooth
|
|
54
58
|
background.write( "#{root_path}/#{file}" )
|
55
59
|
end
|
56
60
|
|
61
|
+
# Paints the faces of the tooth image on hash colors based.
|
62
|
+
# The tooth's filename represents the faces painted,
|
63
|
+
# The filename's characters are:
|
64
|
+
# * w - White
|
65
|
+
# * g - Green
|
66
|
+
# * b - Blue
|
67
|
+
# * n - Black
|
68
|
+
# * r - Red
|
69
|
+
# * t - To extract
|
70
|
+
# * x - Extracted
|
71
|
+
# and are ordered, begining on the upper face of the
|
72
|
+
# the tooth and moving clockwise ending on the center face.
|
73
|
+
# Example: wrrgw.png
|
57
74
|
def paint hash_faces, name_file
|
58
75
|
# FIXME
|
59
76
|
self.graph_base
|
@@ -88,8 +105,30 @@ class ImageTooth
|
|
88
105
|
|
89
106
|
gc.draw(tooth)
|
90
107
|
tooth.write("#{self.root_path}/#{name_file}")
|
108
|
+
File.delete("#{self.root_path}/#{@file_name_base}")
|
91
109
|
end
|
92
110
|
|
111
|
+
def paint_extract color, filename
|
112
|
+
self.graph_base
|
113
|
+
|
114
|
+
tooth = Magick::Image.read("#{@root_path}/#{@file_name_base}").first
|
115
|
+
gc = Draw.new
|
116
|
+
|
117
|
+
x = 4
|
118
|
+
y = 10
|
119
|
+
gc.stroke(color)
|
120
|
+
gc.stroke_width(3)
|
121
|
+
gc.line(x, y, x+19, y+15)
|
122
|
+
gc.line(x + 18, y, x, y+16)
|
123
|
+
|
124
|
+
gc.draw(tooth)
|
125
|
+
tooth.write("#{self.root_path}/#{filename}#{@extension}")
|
126
|
+
File.delete("#{self.root_path}/#{@file_name_base}")
|
127
|
+
end
|
128
|
+
|
129
|
+
# Generates a hash based on tooth's file name, where keys are the tooth's
|
130
|
+
# faces and value is the colour to painted.
|
131
|
+
|
93
132
|
def file_name2hash_faces file_name
|
94
133
|
desc = file_name.split('.').first
|
95
134
|
hash = Hash.new
|
@@ -101,23 +140,55 @@ class ImageTooth
|
|
101
140
|
hash
|
102
141
|
end
|
103
142
|
|
143
|
+
# Generates all tooth's images in a folder structure like this:
|
144
|
+
# b/ w/ n/ r/ g/
|
145
|
+
#
|
146
|
+
# * b/ - Blue (those wich it's top face is blue)
|
147
|
+
# * w/ - White (those wich it's top face is white)
|
148
|
+
# * n/ - Black (those wich it's top face is Black)
|
149
|
+
# * g/ - Green (those wich it's top face is Green)
|
150
|
+
# * t/ - To extrate (this will be extracted)
|
151
|
+
# * x/ - Extracted (this was extracted)
|
104
152
|
def gen_all
|
105
153
|
root_path_aux = self.root_path
|
106
154
|
self.permut.each{|i|
|
107
155
|
self.root_path = "#{root_path_aux}/#{i[0].chr}"
|
108
156
|
self.paint_img i
|
109
157
|
}
|
158
|
+
|
159
|
+
#Generate the 2 extractions marcs
|
160
|
+
self.root_path = "#{root_path_aux}/t"
|
161
|
+
self.paint2extract
|
162
|
+
self.root_path = "#{root_path_aux}/x"
|
163
|
+
|
164
|
+
self.paint_extracted
|
165
|
+
|
110
166
|
self.root_path = root_path_aux
|
111
167
|
end
|
112
168
|
|
113
169
|
def method_missing(method_name, *args)
|
114
|
-
|
115
|
-
|
170
|
+
|
171
|
+
case method_name.to_s
|
172
|
+
when /paint_img/
|
173
|
+
case args[0]
|
174
|
+
when /^ttttt/
|
175
|
+
self.paint2extract
|
176
|
+
when /^xxxxx/
|
177
|
+
self.paint_extracted
|
178
|
+
else
|
179
|
+
self.paint(file_name2hash_faces(args[0]), args[0])
|
180
|
+
end
|
181
|
+
when /paint2extract/
|
182
|
+
self.paint_extract 'blue', 'ttttt'
|
183
|
+
when /paint_extracted/
|
184
|
+
self.paint_extract 'red', 'xxxxx'
|
116
185
|
else
|
117
186
|
super.method_missing
|
118
187
|
end
|
188
|
+
|
119
189
|
end
|
120
190
|
|
191
|
+
# Generates all permutations tooth's filenames.
|
121
192
|
def permut
|
122
193
|
@@colors.keys.permut(5).collect{ |v| v.join('') + @extension}
|
123
194
|
end
|
@@ -126,12 +197,15 @@ class ImageTooth
|
|
126
197
|
@@colors[char_color]
|
127
198
|
end
|
128
199
|
|
200
|
+
# Create all folders ones for each color and 2 more for extractions (x/ and t/)
|
129
201
|
def create_folders
|
130
202
|
#FIXME
|
131
203
|
Dir.mkdir(@root_path) if not File.exist?(@root_path)
|
132
204
|
ImageTooth.chars_colors.each { |f|
|
133
205
|
Dir.mkdir("#{@root_path}/#{f}") if not File.exist?("#{@root_path}/#{f}")
|
134
206
|
}
|
207
|
+
Dir.mkdir("#{@root_path}/t")
|
208
|
+
Dir.mkdir("#{@root_path}/x")
|
135
209
|
end
|
136
210
|
|
137
211
|
end
|
data/spec/wrrgw.png
ADDED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: imagetooth
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-08-23 00:00:00 -04:00
|
8
8
|
summary: This library allows to generate images of teeth for odontograms with tooth faces painted in a color (red, green, blue, white or black for example). This is very usefull for dental applications..
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -17,7 +17,7 @@ description: This library allows to generate images of teeth for odontograms wit
|
|
17
17
|
autorequire: image_tooth
|
18
18
|
default_executable: imagetooth
|
19
19
|
bindir: bin
|
20
|
-
has_rdoc:
|
20
|
+
has_rdoc: true
|
21
21
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
@@ -59,12 +59,40 @@ files:
|
|
59
59
|
- lib/array_adds.rb
|
60
60
|
- bin
|
61
61
|
- bin/imagetooth
|
62
|
+
- TODO
|
62
63
|
- images
|
63
64
|
- spec
|
64
65
|
- spec/array_spec.rb
|
65
66
|
- spec/image_tooth_spec.rb
|
67
|
+
- spec/wrrgw.png
|
66
68
|
- imagetooth.gemspec
|
67
|
-
-
|
69
|
+
- LICENSE
|
70
|
+
- doc
|
71
|
+
- doc/rdoc-style.css
|
72
|
+
- doc/files
|
73
|
+
- doc/files/lib
|
74
|
+
- doc/files/lib/image_tooth_rb.html
|
75
|
+
- doc/classes
|
76
|
+
- doc/classes/ImageTooth.src
|
77
|
+
- doc/classes/ImageTooth.src/M000001.html
|
78
|
+
- doc/classes/ImageTooth.src/M000002.html
|
79
|
+
- doc/classes/ImageTooth.src/M000003.html
|
80
|
+
- doc/classes/ImageTooth.src/M000004.html
|
81
|
+
- doc/classes/ImageTooth.src/M000005.html
|
82
|
+
- doc/classes/ImageTooth.src/M000006.html
|
83
|
+
- doc/classes/ImageTooth.src/M000007.html
|
84
|
+
- doc/classes/ImageTooth.src/M000008.html
|
85
|
+
- doc/classes/ImageTooth.src/M000009.html
|
86
|
+
- doc/classes/ImageTooth.src/M000010.html
|
87
|
+
- doc/classes/ImageTooth.src/M000011.html
|
88
|
+
- doc/classes/ImageTooth.src/M000012.html
|
89
|
+
- doc/classes/ImageTooth.html
|
90
|
+
- doc/fr_file_index.html
|
91
|
+
- doc/fr_class_index.html
|
92
|
+
- doc/fr_method_index.html
|
93
|
+
- doc/index.html
|
94
|
+
- doc/created.rid
|
95
|
+
- README~
|
68
96
|
test_files: []
|
69
97
|
|
70
98
|
rdoc_options: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/imagetooth-0.0.5.gem
DELETED
Binary file
|