rimageanalysistools 5.1.3.1-java → 5.1.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/extlib/ImageAnalysisTools.jar +0 -0
- data/lib/rimageanalysistools/centroids.rb +14 -2
- data/lib/rimageanalysistools/create_parameters.rb +22 -1
- data/lib/rimageanalysistools/drawing.rb +66 -0
- data/lib/rimageanalysistools/get_image.rb +10 -2
- data/lib/rimageanalysistools/image/io/url_image_reader.rb +61 -0
- metadata +19 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4c7d48f0ed9ddeb04036796490373e3ba01b4801
|
4
|
+
data.tar.gz: 902959cd4e6552ab1fc53c3d9fa229f3d254085a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e0058d24160cfbd535afbe59f08a872eb6f57e4958d10292918158e2eb9e925ef729c0ab2dc6379db5ec5e0f4cc461c1337d746a47d6001623513fdea42e552
|
7
|
+
data.tar.gz: d1fc10d700d36f01093b2891cbd2db43af8ff9184cb7c76d853c57f55de171473d7e8cb02c9b5ec21e36c2bbf2046a273421b74ac7bd8e5c5d8f3ab283f49cb6
|
Binary file
|
@@ -31,8 +31,20 @@ java_import Java::edu.stanford.cfuller.imageanalysistools.image.ImageCoordinate
|
|
31
31
|
|
32
32
|
module RImageAnalysisTools
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
##
|
35
|
+
# Methods for calculating the geometric centroids of regions in an image
|
36
|
+
#
|
37
|
+
module Centroids
|
38
|
+
|
39
|
+
##
|
40
|
+
# Calculates the centroid of all 2d regions in a mask. A region is
|
41
|
+
# defined as all pixels having the same nonzero greylevel in an image.
|
42
|
+
#
|
43
|
+
# @param [Image] mask the mask containing the regions
|
44
|
+
#
|
45
|
+
# @return [Hash] a hash mapping the greylevel of each region to its
|
46
|
+
# 2d centroid stored as an array [x,y]
|
47
|
+
#
|
36
48
|
def self.calculate_centroids_2d(mask)
|
37
49
|
|
38
50
|
centroids = {}
|
@@ -30,10 +30,25 @@ java_import Java::edu.stanford.cfuller.imageanalysistools.meta.parameters.Parame
|
|
30
30
|
|
31
31
|
class ParameterDictionary
|
32
32
|
|
33
|
+
##
|
34
|
+
# Adds hash-like getter access to ParameterDictionary objects
|
35
|
+
#
|
36
|
+
# @param key an object whose to_s method returns the name of a parameter
|
37
|
+
#
|
38
|
+
# @return [String] the value of the parameter as returned by ParameterDictionary#getValueForKey
|
39
|
+
#
|
33
40
|
def [](key)
|
34
41
|
getValueForKey(key.to_s)
|
35
42
|
end
|
36
43
|
|
44
|
+
##
|
45
|
+
# Adds hash-like setter access to ParameterDictionary objects
|
46
|
+
#
|
47
|
+
# @param key an object whose to_s method returns the name of a parameter
|
48
|
+
# @param value an object whose to_s method returns the parameter value being set
|
49
|
+
#
|
50
|
+
# @return [void]
|
51
|
+
#
|
37
52
|
def []=(key, value)
|
38
53
|
setValueForKey(key.to_s, value.to_s)
|
39
54
|
end
|
@@ -42,7 +57,13 @@ end
|
|
42
57
|
|
43
58
|
module RImageAnalysisTools
|
44
59
|
|
45
|
-
|
60
|
+
##
|
61
|
+
# Creates a ParameterDictionary from a hash of parameters.
|
62
|
+
#
|
63
|
+
# @param [Hash] parameter_hash a hash mapping parameters to values
|
64
|
+
#
|
65
|
+
# @return [ParameterDictionary] a parameter dictionary now containing the specified parameters
|
66
|
+
#
|
46
67
|
def self.create_parameter_dictionary(parameter_hash)
|
47
68
|
|
48
69
|
p = ParameterDictionary.emptyDictionary
|
@@ -31,6 +31,21 @@ java_import Java::edu.stanford.cfuller.imageanalysistools.image.ReadOnlyImageImp
|
|
31
31
|
|
32
32
|
class ReadOnlyImageImpl
|
33
33
|
|
34
|
+
##
|
35
|
+
# Allows setting a region of interest of an image along only some dimenions, preserving any
|
36
|
+
# current region of interest along other dimenions.
|
37
|
+
#
|
38
|
+
# @param [Hash, ImageCoordinate] lower a hash or ImageCoordinate mapping dimensions to the lower
|
39
|
+
# bound of the box (inclusive) along the specified dimensions. Can contain extra dimenions not boxed;
|
40
|
+
# only the boxing on the dimenions specified in the dims parameter will be changed.
|
41
|
+
# @param [Hash, ImageCoordinate] upper a hash or ImageCoordinate mapping dimensions to the upper
|
42
|
+
# bound of the box (exclusive) along the specified dimensions. Can contain extra dimenions not boxed;
|
43
|
+
# only the boxing on the dimenions specified in the dims parameter will be changed.
|
44
|
+
# @param [Enumerable] dims an enumeration of the dimensions to be boxed (these should be the symbol shortcuts
|
45
|
+
# to the dimensions; e.g. :x, :y)
|
46
|
+
#
|
47
|
+
# @return [void]
|
48
|
+
#
|
34
49
|
def box_conservative(lower, upper, dims)
|
35
50
|
|
36
51
|
low_curr = nil
|
@@ -57,10 +72,27 @@ class ReadOnlyImageImpl
|
|
57
72
|
|
58
73
|
end
|
59
74
|
|
75
|
+
|
60
76
|
module RImageAnalysisTools
|
61
77
|
|
78
|
+
|
79
|
+
##
|
80
|
+
# A collection of methods for drawing into an existing image.
|
81
|
+
#
|
62
82
|
class Drawing
|
63
83
|
|
84
|
+
##
|
85
|
+
# A basic drawing method that iterates through an entire image. At each coordinate,
|
86
|
+
# an attached block is evaluated for a boolean response that determines whether that
|
87
|
+
# coordinate is overwritten with a specified value. The attached block will be given
|
88
|
+
# a single parameter, which is the current ImageCoordinate.
|
89
|
+
#
|
90
|
+
# @param [WritableImage] im the image being drawn on
|
91
|
+
# @param [Numeric] draw_value the value to which a pixel will be set if the block
|
92
|
+
# evaluates to a true value at that coordinate
|
93
|
+
#
|
94
|
+
# @return [void]
|
95
|
+
#
|
64
96
|
def draw(im, draw_value = 255.0)
|
65
97
|
|
66
98
|
im.each do |ic|
|
@@ -75,6 +107,19 @@ module RImageAnalysisTools
|
|
75
107
|
|
76
108
|
end
|
77
109
|
|
110
|
+
##
|
111
|
+
# Draws a specified shape into an image.
|
112
|
+
#
|
113
|
+
# @param [WritableImage] im the image into which to draw
|
114
|
+
# @param [Array] location an array containing the coordinates of the shape to draw.
|
115
|
+
# The exact meaning of this parameter depends on which shape is being drawn.
|
116
|
+
# @param [Symbol] shape_name the name of the shape to draw. This should correspond
|
117
|
+
# to one of the methods of this class.
|
118
|
+
# @param shape_parameters the parameters for drawing the specified shape;
|
119
|
+
# the meaning of this parameter depends on the shape.
|
120
|
+
#
|
121
|
+
# @return [void]
|
122
|
+
#
|
78
123
|
def draw_shape(im, location, shape_name=:circle, shape_parameters= 10)
|
79
124
|
|
80
125
|
if self.respond_to?(shape_name) then
|
@@ -85,6 +130,15 @@ module RImageAnalysisTools
|
|
85
130
|
|
86
131
|
end
|
87
132
|
|
133
|
+
##
|
134
|
+
# Draws a circle into an image.
|
135
|
+
#
|
136
|
+
# @param [WritableImage] im the image into which to draw
|
137
|
+
# @param [Array] center an array containing the x,y coordinates of the circle's center
|
138
|
+
# @param [Numeric] radius the radius of the circle in pixels
|
139
|
+
#
|
140
|
+
# @return [void]
|
141
|
+
#
|
88
142
|
def circle(im, center, radius)
|
89
143
|
|
90
144
|
lower = ImageCoordinate[center[0]-radius-1, center[1]-radius-1, 0,0,0]
|
@@ -110,6 +164,18 @@ module RImageAnalysisTools
|
|
110
164
|
|
111
165
|
end
|
112
166
|
|
167
|
+
##
|
168
|
+
# Draws an ellipse into an image.
|
169
|
+
#
|
170
|
+
# @param [WritableImage] im the image into which to draw
|
171
|
+
# @param [Array] foci an array containing two arrays, each of which contains the x,y
|
172
|
+
# coordinates of one focus of the ellipse
|
173
|
+
# @param [Numeric] radius_inc the extra amount of distance (in pixels) beyond the
|
174
|
+
# distance between the foci that the ellipse should be drawn. (2*radius_inc + dist
|
175
|
+
# between foci = major axis length)
|
176
|
+
#
|
177
|
+
# @return [void]
|
178
|
+
#
|
113
179
|
def ellipse(im, foci, radius_inc)
|
114
180
|
|
115
181
|
min_x = foci[0][0]
|
@@ -25,14 +25,22 @@
|
|
25
25
|
#++
|
26
26
|
|
27
27
|
require 'rimageanalysistools/initjava'
|
28
|
+
require 'rimageanalysistools/image/io/url_image_reader'
|
29
|
+
require 'uri'
|
28
30
|
|
29
31
|
java_import Java::edu.stanford.cfuller.imageanalysistools.image.io.ImageReader
|
30
32
|
|
31
33
|
module RImageAnalysisTools
|
32
34
|
|
33
35
|
def self.get_image(filename)
|
34
|
-
|
35
|
-
ir =
|
36
|
+
|
37
|
+
ir = nil
|
38
|
+
|
39
|
+
if filename.is_a? URI then
|
40
|
+
ir = URLImageReader.new
|
41
|
+
else
|
42
|
+
ir = ImageReader.new
|
43
|
+
end
|
36
44
|
|
37
45
|
ir.read(filename)
|
38
46
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2013 Colin J. Fuller
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the Software), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'open-uri'
|
24
|
+
require 'tempfile'
|
25
|
+
require 'rimageanalysistools/get_image'
|
26
|
+
|
27
|
+
module RImageAnalysisTools
|
28
|
+
|
29
|
+
class URLImageReader
|
30
|
+
|
31
|
+
def read(url)
|
32
|
+
|
33
|
+
data = nil
|
34
|
+
im = nil
|
35
|
+
|
36
|
+
open(url) do |f|
|
37
|
+
data = f.read
|
38
|
+
end
|
39
|
+
|
40
|
+
tf = Tempfile.new('url_image_reader')
|
41
|
+
|
42
|
+
begin
|
43
|
+
|
44
|
+
tf.write(data)
|
45
|
+
im = RImageAnalysisTools.get_image(tf.path)
|
46
|
+
|
47
|
+
ensure
|
48
|
+
|
49
|
+
tf.close
|
50
|
+
tf.unlink
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
im
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rimageanalysistools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
5
|
-
prerelease:
|
4
|
+
version: 5.1.4.1
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Colin J. Fuller
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
date: 2013-01-25 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description: Helper code and some extensions for the ImageAnalysisTools package at
|
13
|
+
description: Helper code and some extensions for the ImageAnalysisTools package at
|
14
|
+
http://cjfuller.github.com/imageanalysistools/
|
15
15
|
email: cjfuller@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -27,42 +27,40 @@ files:
|
|
27
27
|
- lib/rimageanalysistools/get_image.rb
|
28
28
|
- lib/rimageanalysistools/skeletonizer.rb
|
29
29
|
- lib/rimageanalysistools/get_filter.rb
|
30
|
-
- lib/rimageanalysistools/centroids.rb
|
31
|
-
- lib/rimageanalysistools/drawing.rb
|
32
|
-
- lib/rimageanalysistools/image_shortcuts.rb
|
33
30
|
- lib/rimageanalysistools/fitting/bisquare_linear_fit.rb
|
34
31
|
- lib/rimageanalysistools/method/centromere_finding_method.rb
|
35
32
|
- lib/rimageanalysistools/method/method.rb
|
33
|
+
- lib/rimageanalysistools/image/io/url_image_reader.rb
|
36
34
|
- lib/rimageanalysistools/image/io/image_writer.rb
|
35
|
+
- lib/rimageanalysistools/centroids.rb
|
36
|
+
- lib/rimageanalysistools/drawing.rb
|
37
|
+
- lib/rimageanalysistools/image_shortcuts.rb
|
37
38
|
- extlib/ImageAnalysisTools.jar
|
38
39
|
homepage: https://github.com/cjfuller/rimageanalysistools/
|
39
40
|
licenses:
|
40
41
|
- MIT
|
41
|
-
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
42
44
|
rdoc_options: []
|
43
45
|
require_paths:
|
44
46
|
- lib
|
45
47
|
- extlib
|
46
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
49
|
requirements:
|
48
|
-
- -
|
50
|
+
- - '>='
|
49
51
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
51
|
-
MA==
|
52
|
-
none: false
|
52
|
+
version: '0'
|
53
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - '>='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
MA==
|
59
|
-
none: false
|
57
|
+
version: '0'
|
60
58
|
requirements:
|
61
59
|
- jruby
|
62
|
-
rubyforge_project:
|
63
|
-
rubygems_version:
|
64
|
-
signing_key:
|
65
|
-
specification_version:
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.0.0
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
66
64
|
summary: JRuby extensions to the ImageAnalysisTools java package
|
67
65
|
test_files: []
|
68
|
-
has_rdoc:
|
66
|
+
has_rdoc:
|