MCPcopy Create free account
hub / github.com/Image-Py/imagepy / profile

Method profile

imagepy/tools/Measure/profile_tol.py:130–152  ·  view source on GitHub ↗
(self, body, img)

Source from the content-addressed store, hash-verified

128 self.odx, self.ody = x, y
129
130 def profile(self, body, img):
131 (x1, y1), (x2, y2) = body[0]
132 dx, dy = x2-x1, y2-y1
133 n = max(abs(dx), abs(dy)) + 1
134 xs = np.linspace(x1, x2, n).round().astype(np.int16)
135 ys = np.linspace(y1, y2, n).round().astype(np.int16)
136 msk = (xs>=0) * (xs<img.shape[1])
137 msk*= (ys>=0) * (ys<img.shape[0])
138 ix = np.arange(len(xs))
139
140 frame = IPy.plot('Profile', 'Profile - Line', 'pixels coordinate', 'value of pixcels')
141 frame.clear()
142 if len(img.shape) == 3:
143 vs = np.zeros((3,len(xs)), dtype=np.int16)
144 vs[:,msk] = img[ys[msk], xs[msk]].T
145 frame.add_data(ix, vs[0], (255,0,0), 1)
146 frame.add_data(ix, vs[1], (0,255,0), 1)
147 frame.add_data(ix, vs[2], (0,0,255), 1)
148 else:
149 vs = np.zeros(len(xs), dtype=np.int16)
150 vs[msk] = img[ys[msk], xs[msk]]
151 frame.add_data(ix, vs, (0,0,0), 1)
152 frame.draw()
153
154 def mouse_wheel(self, ips, x, y, d, **key):
155 pass

Callers 1

mouse_upMethod · 0.95

Calls 3

clearMethod · 0.80
add_dataMethod · 0.80
drawMethod · 0.45

Tested by

no test coverage detected