| 1 |
"""Provide sources for generating images.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from typing import TYPE_CHECKING |
| 6 |
|
| 7 |
from pyvista import _vtk |
| 8 |
from pyvista._deprecate_positional_args import _deprecate_positional_args |
| 9 |
from pyvista.core._vtk_utilities import DisableVtkSnakeCase |
| 10 |
from pyvista.core.utilities.misc import _NoNewAttrMixin |
| 11 |
|
| 12 |
from .helpers import wrap |
| 13 |
|
| 14 |
if TYPE_CHECKING: |
| 15 |
from collections.abc import Sequence |
| 16 |
|
| 17 |
|
| 18 |
class ImageEllipsoidSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageEllipsoidSource): |
| 19 |
"""Create a binary image of an ellipsoid class. |
| 20 |
|
| 21 |
.. versionadded:: 0.44.0 |
| 22 |
|
| 23 |
Parameters |
| 24 |
---------- |
| 25 |
whole_extent : sequence[int] |
| 26 |
The extent of the whole output image. |
| 27 |
|
| 28 |
center : sequence[float] |
| 29 |
The center of the ellipsoid. |
| 30 |
|
| 31 |
radius : tuple |
| 32 |
The radius of the ellipsoid. |
| 33 |
|
| 34 |
Examples |
| 35 |
-------- |
| 36 |
Create an image of an ellipsoid. |
| 37 |
|
| 38 |
>>> import pyvista as pv |
| 39 |
>>> source = pv.ImageEllipsoidSource( |
| 40 |
... whole_extent=(0, 20, 0, 20, 0, 0), |
| 41 |
... center=(10, 10, 0), |
| 42 |
... radius=(3, 4, 5), |
| 43 |
... ) |
| 44 |
>>> source.output.plot(cpos='xy') |
| 45 |
|
| 46 |
""" |
| 47 |
|
| 48 |
def __init__(self, whole_extent=None, center=None, radius=None) -> None: |
| 49 |
super().__init__() |
| 50 |
if whole_extent is not None: |
| 51 |
self.whole_extent = whole_extent |
| 52 |
if center is not None: |
| 53 |
self.center = center |
| 54 |
if radius is not None: |
| 55 |
self.radius = radius |
| 56 |
|
| 57 |
@property |
| 58 |
def whole_extent(self) -> Sequence[int]: |
| 59 |
"""Get extent of the whole output image. |
| 60 |
|
| 61 |
Returns |
| 62 |
------- |
| 63 |
sequence[int] |
| 64 |
The extent of the whole output image. |
| 65 |
|
| 66 |
""" |
| 67 |
return self.GetWholeExtent() |
| 68 |
|
| 69 |
@whole_extent.setter |
| 70 |
def whole_extent(self, whole_extent: Sequence[int]) -> None: |
| 71 |
"""Set extent of the whole output image. |
| 72 |
|
| 73 |
Parameters |
| 74 |
---------- |
| 75 |
whole_extent : sequence[int] |
| 76 |
The extent of the whole output image. |
| 77 |
|
| 78 |
""" |
| 79 |
self.SetWholeExtent(whole_extent) # type: ignore[call-overload] |
| 80 |
|
| 81 |
@property |
| 82 |
def center(self) -> tuple[float, float, float]: |
| 83 |
"""Get the center of the ellipsoid. |
| 84 |
|
| 85 |
Returns |
| 86 |
------- |
| 87 |
tuple[float, float, float] |
| 88 |
The center of the ellipsoid. |
| 89 |
|
| 90 |
""" |
| 91 |
return self.GetCenter() |
| 92 |
|
| 93 |
@center.setter |
| 94 |
def center(self, center: Sequence[float]) -> None: |
| 95 |
"""Set the center of the ellipsoid. |
| 96 |
|
| 97 |
Parameters |
| 98 |
---------- |
| 99 |
center : sequence[float] |
| 100 |
The center of the ellipsoid. |
| 101 |
|
| 102 |
""" |
| 103 |
self.SetCenter(center) |
| 104 |
|
| 105 |
@property |
| 106 |
def radius(self) -> Sequence[float]: |
| 107 |
"""Get the radius of the ellipsoid. |
| 108 |
|
| 109 |
Returns |
| 110 |
------- |
| 111 |
sequence[float] |
| 112 |
The radius of the ellipsoid. |
| 113 |
|
| 114 |
""" |
| 115 |
return self.GetRadius() |
| 116 |
|
| 117 |
@radius.setter |
| 118 |
def radius(self, radius: Sequence[float]) -> None: |
| 119 |
"""Set the radius of the ellipsoid. |
| 120 |
|
| 121 |
Parameters |
| 122 |
---------- |
| 123 |
radius : sequence[float] |
| 124 |
The radius of the ellipsoid. |
| 125 |
|
| 126 |
""" |
| 127 |
self.SetRadius(radius) |
| 128 |
|
| 129 |
@property |
| 130 |
def output(self): |
| 131 |
"""Get the output image as a ImageData. |
| 132 |
|
| 133 |
Returns |
| 134 |
------- |
| 135 |
pyvista.ImageData |
| 136 |
The output image. |
| 137 |
|
| 138 |
""" |
| 139 |
self.Update() |
| 140 |
return wrap(self.GetOutput()) |
| 141 |
|
| 142 |
|
| 143 |
class ImageMandelbrotSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageMandelbrotSource): |
| 144 |
"""Create an image of the Mandelbrot set. |
| 145 |
|
| 146 |
.. versionadded:: 0.44.0 |
| 147 |
|
| 148 |
Parameters |
| 149 |
---------- |
| 150 |
whole_extent : sequence[int] |
| 151 |
The extent of the whole output image. |
| 152 |
|
| 153 |
maxiter : int |
| 154 |
The maximum number of iterations. |
| 155 |
|
| 156 |
Examples |
| 157 |
-------- |
| 158 |
Create an image of the Mandelbrot set. |
| 159 |
|
| 160 |
>>> import pyvista as pv |
| 161 |
>>> source = pv.ImageMandelbrotSource( |
| 162 |
... whole_extent=(0, 200, 0, 200, 0, 0), |
| 163 |
... maxiter=100, |
| 164 |
... ) |
| 165 |
>>> source.output.plot(cpos='xy') |
| 166 |
|
| 167 |
""" |
| 168 |
|
| 169 |
def __init__(self, whole_extent=None, maxiter=None) -> None: |
| 170 |
super().__init__() |
| 171 |
if whole_extent is not None: |
| 172 |
self.whole_extent = whole_extent |
| 173 |
if maxiter is not None: |
| 174 |
self.maxiter = maxiter |
| 175 |
|
| 176 |
@property |
| 177 |
def whole_extent(self) -> Sequence[int]: |
| 178 |
"""Get extent of the whole output image. |
| 179 |
|
| 180 |
Returns |
| 181 |
------- |
| 182 |
sequence[int] |
| 183 |
The extent of the whole output image. |
| 184 |
|
| 185 |
""" |
| 186 |
return self.GetWholeExtent() |
| 187 |
|
| 188 |
@whole_extent.setter |
| 189 |
def whole_extent(self, whole_extent: Sequence[int]) -> None: |
| 190 |
"""Set extent of the whole output image. |
| 191 |
|
| 192 |
Parameters |
| 193 |
---------- |
| 194 |
whole_extent : sequence[int] |
| 195 |
The extent of the whole output image. |
| 196 |
|
| 197 |
""" |
| 198 |
self.SetWholeExtent(whole_extent) # type: ignore[call-overload] |
| 199 |
|
| 200 |
@property |
| 201 |
def maxiter(self) -> int: |
| 202 |
"""Get the maximum number of iterations. |
| 203 |
|
| 204 |
Returns |
| 205 |
------- |
| 206 |
int |
| 207 |
The maximum number of iterations. |
| 208 |
|
| 209 |
""" |
| 210 |
return self.GetMaximumNumberOfIterations() |
| 211 |
|
| 212 |
@maxiter.setter |
| 213 |
def maxiter(self, maxiter: int) -> None: |
| 214 |
"""Set the maximum number of iterations. |
| 215 |
|
| 216 |
Parameters |
| 217 |
---------- |
| 218 |
maxiter : int |
| 219 |
The maximum number of iterations. |
| 220 |
|
| 221 |
""" |
| 222 |
self.SetMaximumNumberOfIterations(maxiter) |
| 223 |
|
| 224 |
@property |
| 225 |
def output(self): |
| 226 |
"""Get the output image as a ImageData. |
| 227 |
|
| 228 |
Returns |
| 229 |
------- |
| 230 |
pyvista.ImageData |
| 231 |
The output image. |
| 232 |
|
| 233 |
""" |
| 234 |
self.Update() |
| 235 |
return wrap(self.GetOutput()) |
| 236 |
|
| 237 |
|
| 238 |
class ImageNoiseSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageNoiseSource): |
| 239 |
"""Create an image filled with uniform noise. |
| 240 |
|
| 241 |
.. versionadded:: 0.44.0 |
| 242 |
|
| 243 |
Parameters |
| 244 |
---------- |
| 245 |
whole_extent : sequence[int] |
| 246 |
The extent of the whole output image. |
| 247 |
|
| 248 |
minimum : float |
| 249 |
The minimum value for the generated noise. |
| 250 |
|
| 251 |
maximum : float |
| 252 |
The maximum value for the generated noise. |
| 253 |
|
| 254 |
seed : int, optional |
| 255 |
Seed the random number generator with a value. |
| 256 |
|
| 257 |
Examples |
| 258 |
-------- |
| 259 |
Create an image of noise. |
| 260 |
|
| 261 |
>>> import pyvista as pv |
| 262 |
>>> source = pv.ImageNoiseSource( |
| 263 |
... whole_extent=(0, 200, 0, 200, 0, 0), |
| 264 |
... minimum=0, |
| 265 |
... maximum=255, |
| 266 |
... seed=0, |
| 267 |
... ) |
| 268 |
>>> source.output.plot(cpos='xy') |
| 269 |
|
| 270 |
""" |
| 271 |
|
| 272 |
@_deprecate_positional_args |
| 273 |
def __init__( # noqa: PLR0917 |
| 274 |
self, |
| 275 |
whole_extent=(0, 255, 0, 255, 0, 0), |
| 276 |
minimum=0.0, |
| 277 |
maximum=1.0, |
| 278 |
seed=None, |
| 279 |
) -> None: |
| 280 |
super().__init__() |
| 281 |
if whole_extent is not None: |
| 282 |
self.whole_extent = whole_extent |
| 283 |
if minimum is not None: |
| 284 |
self.minimum = minimum |
| 285 |
if maximum is not None: |
| 286 |
self.maximum = maximum |
| 287 |
if seed is not None: |
| 288 |
self.seed(seed) |
| 289 |
|
| 290 |
@property |
| 291 |
def whole_extent(self) -> Sequence[int]: |
| 292 |
"""Get extent of the whole output image. |
| 293 |
|
| 294 |
Returns |
| 295 |
------- |
| 296 |
sequence[int] |
| 297 |
The extent of the whole output image. |
| 298 |
|
| 299 |
""" |
| 300 |
return self._whole_extent |
| 301 |
|
| 302 |
@whole_extent.setter |
| 303 |
def whole_extent(self, whole_extent: Sequence[int]) -> None: |
| 304 |
"""Set extent of the whole output image. |
| 305 |
|
| 306 |
Parameters |
| 307 |
---------- |
| 308 |
whole_extent : sequence[int] |
| 309 |
The extent of the whole output image. |
| 310 |
|
| 311 |
""" |
| 312 |
self._whole_extent = whole_extent |
| 313 |
self.SetWholeExtent(whole_extent) |
| 314 |
|
| 315 |
@property |
| 316 |
def minimum(self) -> float: |
| 317 |
"""Get the minimum value for the generated noise. |
| 318 |
|
| 319 |
Returns |
| 320 |
------- |
| 321 |
float |
| 322 |
The minimum value for the generated noise. |
| 323 |
|
| 324 |
""" |
| 325 |
return self.GetMinimum() |
| 326 |
|
| 327 |
@minimum.setter |
| 328 |
def minimum(self, minimum: float) -> None: |
| 329 |
"""Set the minimum value for the generated noise. |
| 330 |
|
| 331 |
Parameters |
| 332 |
---------- |
| 333 |
minimum : float |
| 334 |
The minimum value for the generated noise. |
| 335 |
|
| 336 |
""" |
| 337 |
self.SetMinimum(minimum) |
| 338 |
|
| 339 |
@property |
| 340 |
def maximum(self) -> float: |
| 341 |
"""Get the maximum value for the generated noise. |
| 342 |
|
| 343 |
Returns |
| 344 |
------- |
| 345 |
float |
| 346 |
The maximum value for the generated noise. |
| 347 |
|
| 348 |
""" |
| 349 |
return self.GetMaximum() |
| 350 |
|
| 351 |
@maximum.setter |
| 352 |
def maximum(self, maximum: float) -> None: |
| 353 |
"""Set the maximum value for the generated noise. |
| 354 |
|
| 355 |
Parameters |
| 356 |
---------- |
| 357 |
maximum : float |
| 358 |
The maximum value for the generated noise. |
| 359 |
|
| 360 |
""" |
| 361 |
self.SetMaximum(maximum) |
| 362 |
|
| 363 |
def seed(self, value: int) -> None: |
| 364 |
"""Seed the random number generator with a value. |
| 365 |
|
| 366 |
Parameters |
| 367 |
---------- |
| 368 |
value : int |
| 369 |
The seed value for the random number generator to use. |
| 370 |
|
| 371 |
""" |
| 372 |
_vtk.vtkMath().RandomSeed(value) |
| 373 |
|
| 374 |
@property |
| 375 |
def output(self): |
| 376 |
"""Get the output image as a ImageData. |
| 377 |
|
| 378 |
Returns |
| 379 |
------- |
| 380 |
pyvista.ImageData |
| 381 |
The output image. |
| 382 |
|
| 383 |
""" |
| 384 |
self.Update() |
| 385 |
return wrap(self.GetOutput()) |
| 386 |
|
| 387 |
|
| 388 |
class ImageSinusoidSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageSinusoidSource): |
| 389 |
"""Create an image of a sinusoid. |
| 390 |
|
| 391 |
.. versionadded:: 0.44.0 |
| 392 |
|
| 393 |
Parameters |
| 394 |
---------- |
| 395 |
whole_extent : sequence[int] |
| 396 |
The extent of the whole output image. |
| 397 |
|
| 398 |
direction : tuple |
| 399 |
The direction vector which determines the sinusoidal orientation. |
| 400 |
|
| 401 |
period : float |
| 402 |
The period of the sinusoid in pixel. |
| 403 |
|
| 404 |
phase : tuple |
| 405 |
The phase of the sinusoid in pixel. |
| 406 |
|
| 407 |
amplitude : float |
| 408 |
The magnitude of the sinusoid. |
| 409 |
|
| 410 |
Examples |
| 411 |
-------- |
| 412 |
Create an image of a sinusoid. |
| 413 |
|
| 414 |
>>> import pyvista as pv |
| 415 |
>>> source = pv.ImageSinusoidSource( |
| 416 |
... whole_extent=(0, 200, 0, 200, 0, 0), |
| 417 |
... period=20.0, |
| 418 |
... phase=0.0, |
| 419 |
... amplitude=255, |
| 420 |
... direction=(1.0, 0.0, 0.0), |
| 421 |
... ) |
| 422 |
>>> source.output.plot(cpos='xy') |
| 423 |
|
| 424 |
""" |
| 425 |
|
| 426 |
@_deprecate_positional_args |
| 427 |
def __init__( # noqa: PLR0917 |
| 428 |
self, |
| 429 |
whole_extent=None, |
| 430 |
direction=None, |
| 431 |
period=None, |
| 432 |
phase=None, |
| 433 |
amplitude=None, |
| 434 |
) -> None: |
| 435 |
super().__init__() |
| 436 |
if whole_extent is not None: |
| 437 |
self.whole_extent = whole_extent |
| 438 |
if direction is not None: |
| 439 |
self.direction = direction |
| 440 |
if period is not None: |
| 441 |
self.period = period |
| 442 |
if phase is not None: |
| 443 |
self.phase = phase |
| 444 |
if amplitude is not None: |
| 445 |
self.amplitude = amplitude |
| 446 |
|
| 447 |
@property |
| 448 |
def whole_extent(self) -> Sequence[int]: |
| 449 |
"""Get extent of the whole output image. |
| 450 |
|
| 451 |
Returns |
| 452 |
------- |
| 453 |
sequence[int] |
| 454 |
The extent of the whole output image. |
| 455 |
|
| 456 |
""" |
| 457 |
return self._whole_extent |
| 458 |
|
| 459 |
@whole_extent.setter |
| 460 |
def whole_extent(self, whole_extent: Sequence[int]) -> None: |
| 461 |
"""Set extent of the whole output image. |
| 462 |
|
| 463 |
Parameters |
| 464 |
---------- |
| 465 |
whole_extent : sequence[int] |
| 466 |
The extent of the whole output image. |
| 467 |
|
| 468 |
""" |
| 469 |
self._whole_extent = whole_extent |
| 470 |
self.SetWholeExtent( |
| 471 |
whole_extent[0], |
| 472 |
whole_extent[1], |
| 473 |
whole_extent[2], |
| 474 |
whole_extent[3], |
| 475 |
whole_extent[4], |
| 476 |
whole_extent[5], |
| 477 |
) |
| 478 |
|
| 479 |
@property |
| 480 |
def direction(self) -> Sequence[float]: |
| 481 |
"""Get the direction of the sinusoid. |
| 482 |
|
| 483 |
Returns |
| 484 |
------- |
| 485 |
sequence[float] |
| 486 |
The direction of the sinusoid. |
| 487 |
|
| 488 |
""" |
| 489 |
return self.GetDirection() |
| 490 |
|
| 491 |
@direction.setter |
| 492 |
def direction(self, direction: Sequence[float]) -> None: |
| 493 |
"""Set the direction of the sinusoid. |
| 494 |
|
| 495 |
Parameters |
| 496 |
---------- |
| 497 |
direction : sequence[float] |
| 498 |
The direction of the sinusoid. |
| 499 |
|
| 500 |
""" |
| 501 |
self.SetDirection(direction) # type: ignore[call-overload] |
| 502 |
|
| 503 |
@property |
| 504 |
def period(self) -> float: |
| 505 |
"""Get the period of the sinusoid. |
| 506 |
|
| 507 |
Returns |
| 508 |
------- |
| 509 |
float |
| 510 |
The period of the sinusoid in pixel. |
| 511 |
|
| 512 |
""" |
| 513 |
return self.GetPeriod() |
| 514 |
|
| 515 |
@period.setter |
| 516 |
def period(self, period: float) -> None: |
| 517 |
"""Set the period of the sinusoid. |
| 518 |
|
| 519 |
Parameters |
| 520 |
---------- |
| 521 |
period : float |
| 522 |
The period of the sinusoid in pixel. |
| 523 |
|
| 524 |
""" |
| 525 |
self.SetPeriod(period) |
| 526 |
|
| 527 |
@property |
| 528 |
def phase(self) -> Sequence[float]: |
| 529 |
"""Get the phase of the sinusoid. |
| 530 |
|
| 531 |
Returns |
| 532 |
------- |
| 533 |
sequence[float] |
| 534 |
The phase of the sinusoid in pixel. |
| 535 |
|
| 536 |
""" |
| 537 |
return self.GetPhase() # type: ignore[return-value] |
| 538 |
|
| 539 |
@phase.setter |
| 540 |
def phase(self, phase: Sequence[float]) -> None: |
| 541 |
"""Set the phase of the sinusoid. |
| 542 |
|
| 543 |
Parameters |
| 544 |
---------- |
| 545 |
phase : sequence[float] |
| 546 |
The phase of the sinusoid in pixel. |
| 547 |
|
| 548 |
""" |
| 549 |
self.SetPhase(phase) # type: ignore[arg-type] |
| 550 |
|
| 551 |
@property |
| 552 |
def amplitude(self) -> float: |
| 553 |
"""Get the magnitude of the sinusoid. |
| 554 |
|
| 555 |
Returns |
| 556 |
------- |
| 557 |
float |
| 558 |
The magnitude of the sinusoid. |
| 559 |
|
| 560 |
""" |
| 561 |
return self.GetAmplitude() |
| 562 |
|
| 563 |
@amplitude.setter |
| 564 |
def amplitude(self, amplitude: float) -> None: |
| 565 |
"""Set the magnitude of the sinusoid. |
| 566 |
|
| 567 |
Parameters |
| 568 |
---------- |
| 569 |
amplitude : float |
| 570 |
The magnitude of the sinusoid. |
| 571 |
|
| 572 |
""" |
| 573 |
self.SetAmplitude(amplitude) |
| 574 |
|
| 575 |
@property |
| 576 |
def output(self): |
| 577 |
"""Get the output image as a ImageData. |
| 578 |
|
| 579 |
Returns |
| 580 |
------- |
| 581 |
pyvista.ImageData |
| 582 |
The output image. |
| 583 |
|
| 584 |
""" |
| 585 |
self.Update() |
| 586 |
return wrap(self.GetOutput()) |
| 587 |
|
| 588 |
|
| 589 |
class ImageGaussianSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageGaussianSource): |
| 590 |
"""Create a binary image with Gaussian pixel values. |
| 591 |
|
| 592 |
.. versionadded:: 0.44.0 |
| 593 |
|
| 594 |
Parameters |
| 595 |
---------- |
| 596 |
center : sequence[float] |
| 597 |
The center of the gaussian. |
| 598 |
|
| 599 |
whole_extent : sequence[int] |
| 600 |
The extent of the whole output image. |
| 601 |
|
| 602 |
maximum : float |
| 603 |
The maximum value of the gaussian. |
| 604 |
|
| 605 |
std : sequence[float] |
| 606 |
The standard deviation of the gaussian. |
| 607 |
|
| 608 |
Examples |
| 609 |
-------- |
| 610 |
Create an image of Gaussian pixel values. |
| 611 |
|
| 612 |
>>> import pyvista as pv |
| 613 |
>>> source = pv.ImageGaussianSource( |
| 614 |
... center=(100, 100, 0), |
| 615 |
... whole_extent=(0, 200, 0, 200, 0, 0), |
| 616 |
... maximum=255, |
| 617 |
... std=100.0, |
| 618 |
... ) |
| 619 |
>>> source.output.plot(cpos='xy') |
| 620 |
|
| 621 |
""" |
| 622 |
|
| 623 |
@_deprecate_positional_args |
| 624 |
def __init__( # noqa: PLR0917 |
| 625 |
self, center=None, whole_extent=None, maximum=None, std=None |
| 626 |
) -> None: |
| 627 |
super().__init__() |
| 628 |
if center is not None: |
| 629 |
self.center = center |
| 630 |
if whole_extent is not None: |
| 631 |
self.whole_extent = whole_extent |
| 632 |
if maximum is not None: |
| 633 |
self.maximum = maximum |
| 634 |
if std is not None: |
| 635 |
self.std = std |
| 636 |
|
| 637 |
@property |
| 638 |
def center(self) -> tuple[float, float, float]: |
| 639 |
"""Get the center of the gaussian. |
| 640 |
|
| 641 |
Returns |
| 642 |
------- |
| 643 |
tuple[float, float, float] |
| 644 |
The center of the gaussian. |
| 645 |
|
| 646 |
""" |
| 647 |
return self.GetCenter() |
| 648 |
|
| 649 |
@center.setter |
| 650 |
def center(self, center: Sequence[float]) -> None: |
| 651 |
"""Set the center of the gaussian. |
| 652 |
|
| 653 |
Parameters |
| 654 |
---------- |
| 655 |
center : sequence[float] |
| 656 |
The center of the gaussian. |
| 657 |
|
| 658 |
""" |
| 659 |
self.SetCenter(center) |
| 660 |
|
| 661 |
@property |
| 662 |
def whole_extent(self) -> Sequence[int]: |
| 663 |
"""Get extent of the whole output image. |
| 664 |
|
| 665 |
Returns |
| 666 |
------- |
| 667 |
sequence[int] |
| 668 |
The extent of the whole output image. |
| 669 |
|
| 670 |
""" |
| 671 |
return self._whole_extent |
| 672 |
|
| 673 |
@whole_extent.setter |
| 674 |
def whole_extent(self, whole_extent: Sequence[int]) -> None: |
| 675 |
"""Set extent of the whole output image. |
| 676 |
|
| 677 |
Parameters |
| 678 |
---------- |
| 679 |
whole_extent : sequence[int] |
| 680 |
The extent of the whole output image. |
| 681 |
|
| 682 |
""" |
| 683 |
self._whole_extent = whole_extent |
| 684 |
self.SetWholeExtent( |
| 685 |
whole_extent[0], |
| 686 |
whole_extent[1], |
| 687 |
whole_extent[2], |
| 688 |
whole_extent[3], |
| 689 |
whole_extent[4], |
| 690 |
whole_extent[5], |
| 691 |
) |
| 692 |
|
| 693 |
@property |
| 694 |
def maximum(self) -> float: |
| 695 |
"""Get the maximum value of the gaussian. |
| 696 |
|
| 697 |
Returns |
| 698 |
------- |
| 699 |
float |
| 700 |
The maximum value of the gaussian. |
| 701 |
|
| 702 |
""" |
| 703 |
return self.GetMaximum() |
| 704 |
|
| 705 |
@maximum.setter |
| 706 |
def maximum(self, maximum: float) -> None: |
| 707 |
"""Set the maximum value of the gaussian. |
| 708 |
|
| 709 |
Parameters |
| 710 |
---------- |
| 711 |
maximum : float |
| 712 |
The maximum value of the gaussian. |
| 713 |
|
| 714 |
""" |
| 715 |
self.SetMaximum(maximum) |
| 716 |
|
| 717 |
@property |
| 718 |
def std(self) -> float: |
| 719 |
"""Get the standard deviation of the gaussian. |
| 720 |
|
| 721 |
Returns |
| 722 |
------- |
| 723 |
float |
| 724 |
The standard deviation of the gaussian. |
| 725 |
|
| 726 |
""" |
| 727 |
return self.GetStandardDeviation() |
| 728 |
|
| 729 |
@std.setter |
| 730 |
def std(self, std: float) -> None: |
| 731 |
"""Set the standard deviation of the gaussian. |
| 732 |
|
| 733 |
Parameters |
| 734 |
---------- |
| 735 |
std : float |
| 736 |
The standard deviation of the gaussian. |
| 737 |
|
| 738 |
""" |
| 739 |
self.SetStandardDeviation(std) |
| 740 |
|
| 741 |
@property |
| 742 |
def output(self): |
| 743 |
"""Get the output image as a ImageData. |
| 744 |
|
| 745 |
Returns |
| 746 |
------- |
| 747 |
pyvista.ImageData |
| 748 |
The output image. |
| 749 |
|
| 750 |
""" |
| 751 |
self.Update() |
| 752 |
return wrap(self.GetOutput()) |
| 753 |
|
| 754 |
|
| 755 |
class ImageGridSource(_NoNewAttrMixin, DisableVtkSnakeCase, _vtk.vtkImageGridSource): |
| 756 |
"""Create an image of a grid. |
| 757 |
|
| 758 |
.. versionadded:: 0.44.0 |
| 759 |
|
| 760 |
Parameters |
| 761 |
---------- |
| 762 |
origin : sequence[float] |
| 763 |
The origin of the grid. |
| 764 |
|
| 765 |
extent : sequence[int] |
| 766 |
The extent of the whole output image, Default: (0,255,0,255,0,0). |
| 767 |
|
| 768 |
spacing : tuple |
| 769 |
The pixel spacing. |
| 770 |
|
| 771 |
Examples |
| 772 |
-------- |
| 773 |
Create an image of a grid. |
| 774 |
|
| 775 |
>>> import pyvista as pv |
| 776 |
>>> source = pv.ImageGridSource( |
| 777 |
... extent=(0, 20, 0, 20, 0, 0), |
| 778 |
... spacing=(1, 1, 1), |
| 779 |
... ) |
| 780 |
>>> source.output.plot(cpos='xy') |
| 781 |
|
| 782 |
""" |
| 783 |
|
| 784 |
def __init__(self, origin=None, extent=None, spacing=None) -> None: |
| 785 |
super().__init__() |
| 786 |
if origin is not None: |
| 787 |
self.origin = origin |
| 788 |
if extent is not None: |
| 789 |
self.extent = extent |
| 790 |
if spacing is not None: |
| 791 |
self.spacing = spacing |
| 792 |
|
| 793 |
@property |
| 794 |
def origin(self) -> Sequence[float]: |
| 795 |
"""Get the origin of the data. |
| 796 |
|
| 797 |
Returns |
| 798 |
------- |
| 799 |
sequence[float] |
| 800 |
The origin of the grid. |
| 801 |
|
| 802 |
""" |
| 803 |
return self.GetGridOrigin() |
| 804 |
|
| 805 |
@origin.setter |
| 806 |
def origin(self, origin: Sequence[float]) -> None: |
| 807 |
"""Set the origin of the data. |
| 808 |
|
| 809 |
Parameters |
| 810 |
---------- |
| 811 |
origin : sequence[float] |
| 812 |
The origin of the grid. |
| 813 |
|
| 814 |
""" |
| 815 |
self.SetGridOrigin(origin) # type: ignore[arg-type] |
| 816 |
|
| 817 |
@property |
| 818 |
def extent(self) -> Sequence[int]: |
| 819 |
"""Get extent of the whole output image. |
| 820 |
|
| 821 |
Returns |
| 822 |
------- |
| 823 |
sequence[int] |
| 824 |
The extent of the whole output image. |
| 825 |
|
| 826 |
""" |
| 827 |
return self.GetDataExtent() |
| 828 |
|
| 829 |
@extent.setter |
| 830 |
def extent(self, extent: Sequence[int]) -> None: |
| 831 |
"""Set extent of the whole output image. |
| 832 |
|
| 833 |
Parameters |
| 834 |
---------- |
| 835 |
extent : sequence[int] |
| 836 |
The extent of the whole output image. |
| 837 |
|
| 838 |
""" |
| 839 |
self.SetDataExtent(extent) |
| 840 |
|
| 841 |
@property |
| 842 |
def spacing(self) -> Sequence[float]: |
| 843 |
"""Get the spacing of the grid. |
| 844 |
|
| 845 |
Returns |
| 846 |
------- |
| 847 |
sequence[float] |
| 848 |
The pixel spacing. |
| 849 |
|
| 850 |
""" |
| 851 |
return self.GetDataSpacing() |
| 852 |
|
| 853 |
@spacing.setter |
| 854 |
def spacing(self, spacing: Sequence[float]) -> None: |
| 855 |
"""Set the spacing of the grid. |
| 856 |
|
| 857 |
Parameters |
| 858 |
---------- |
| 859 |
spacing : sequence[float] |
| 860 |
The pixel spacing. |
| 861 |
|
| 862 |
""" |
| 863 |
self.SetDataSpacing(spacing) |
| 864 |
|
| 865 |
@property |
| 866 |
def output(self): |
| 867 |
"""Get the output image as a ImageData. |
| 868 |
|
| 869 |
Returns |
| 870 |
------- |
| 871 |
pyvista.ImageData |
| 872 |
The output image. |
| 873 |
|
| 874 |
""" |
| 875 |
self.Update() |
| 876 |
return wrap(self.GetOutput()) |