Skip to content

Commit 012dc67

Browse files
authored
Merge pull request #14 from fjprichard/dev
Dev
2 parents 31467f7 + 7f59ee3 commit 012dc67

21 files changed

Lines changed: 263 additions & 102 deletions

PyAFBF.egg-info/PKG-INFO

Lines changed: 117 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,117 @@
1-
Metadata-Version: 1.2
2-
Name: PyAFBF
3-
Version: 0.0.3
4-
Summary: Sample image textures from anisotropic fractional Brownian fields
5-
Home-page: https://github.com/fjprichard/PyAFBF/
6-
Author: Frederic Richard
7-
Author-email: frederic.richard@univ-amu.fr
8-
License: GPLv3
9-
Project-URL: Documentation, https://fjprichard.github.io/PyAFBF/
10-
Project-URL: Source, https://github.com/fjprichard/PyAFBF/
11-
Project-URL: Tracker, https://github.com/fjprichard/PyAFBF/issues
12-
Description: The Package PyAFBF is intended for the simulation of rough anisotropic image textures. Textures are sampled from a mathematical model called the anisotropic fractional Brownian field. More details can be found on the `documentation <https://fjprichard.github.io/PyAFBF/>`_.
13-
14-
Package features
15-
================
16-
17-
- Simulation of rough anisotropic textures,
18-
19-
- Computation of field features (semi-variogram, regularity, anisotropy indices) that can serve as texture attributes,
20-
21-
- Random definition of simulated fields,
22-
23-
- Extensions to related fields (deformed fields, intrinsic fields, heterogeneous fields, binary patterns).
24-
25-
26-
Installation from sources
27-
=========================
28-
29-
The package source can be downloaded from the `repository <https://github.com/fjprichard/PyAFBF>`_.
30-
31-
To install the package, write the following commands in the root directory where the package was downloaded:
32-
33-
python setup.py install
34-
or
35-
pip install -e .
36-
37-
After installation, the package can be tested by running
38-
39-
python tests/TestAll.py
40-
41-
If no output appears, then the package is correctly installed.
42-
43-
Communication to the author
44-
===========================
45-
46-
PyAFBF is developed and maintained by Frédéric Richard. For feed-back, contributions, bug reports, contact directly the `author <https://github.com/fjprichard>`_, or use the `discussion <https://github.com/fjprichard/PyAFBF/discussions>`_ facility.
47-
48-
49-
Licence
50-
=======
51-
52-
PyAFBF is under licence GNU GPL, version 3.
53-
54-
55-
Credits
56-
=======
57-
58-
PyAFBF is written and maintained by Frederic Richard, Professor at Aix-Marseille University, France.
59-
60-
61-
62-
Keywords: simulation,anisotropic fractional Brownian field,image texture
63-
Platform: Linux
64-
Platform: MacOSX
65-
Platform: Windows
66-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
67-
Classifier: Development Status :: 5 - Production/Stable
68-
Classifier: Intended Audience :: Science/Research
69-
Classifier: Intended Audience :: End Users/Desktop
70-
Classifier: Intended Audience :: Developers
71-
Classifier: Natural Language :: English
72-
Classifier: Operating System :: OS Independent
73-
Classifier: Programming Language :: Python :: 3.8
74-
Classifier: Topic :: Scientific/Engineering :: Image Processing
1+
Metadata-Version: 2.1
2+
Name: PyAFBF
3+
Version: 0.2.0
4+
Summary: Sample image textures from anisotropic fractional Brownian fields
5+
Home-page: https://github.com/fjprichard/PyAFBF/
6+
Author: Frederic Richard
7+
Author-email: frederic.richard@univ-amu.fr
8+
License: GPLv3
9+
Project-URL: Documentation, https://fjprichard.github.io/PyAFBF/
10+
Project-URL: Source, https://github.com/fjprichard/PyAFBF/
11+
Project-URL: Tracker, https://github.com/fjprichard/PyAFBF/issues
12+
Description: .. image:: https://zenodo.org/badge/368267301.svg
13+
:target: https://zenodo.org/badge/latestdoi/368267301
14+
15+
The Package PyAFBF is intended for the simulation of rough anisotropic image textures. Textures are sampled from a mathematical model called the anisotropic fractional Brownian field. More details can be found on the `documentation <https://fjprichard.github.io/PyAFBF/>`_.
16+
17+
Package features
18+
================
19+
20+
- Simulation of rough anisotropic textures,
21+
22+
- Computation of field features (semi-variogram, regularity, anisotropy indices) that can serve as texture attributes,
23+
24+
- Random definition of simulated fields,
25+
26+
- Extensions to related fields (deformed fields, intrinsic fields, heterogeneous fields, binary patterns).
27+
28+
29+
Installation from sources
30+
=========================
31+
32+
The package source can be downloaded from the `repository <https://github.com/fjprichard/PyAFBF>`_.
33+
34+
The package can be installed through PYPI with
35+
36+
pip install PyAFBF
37+
38+
To install the package in a Google Collab environment, please type
39+
40+
!pip install imgaug==0.2.6
41+
42+
!pip install PyAFBF
43+
44+
Communication to the author
45+
===========================
46+
47+
PyAFBF is developed and maintained by Frédéric Richard. For feed-back, contributions, bug reports, contact directly the `author <https://github.com/fjprichard>`_, or use the `discussion <https://github.com/fjprichard/PyAFBF/discussions>`_ facility.
48+
49+
50+
Licence
51+
=======
52+
53+
PyAFBF is under licence GNU GPL, version 3.
54+
55+
56+
Citation
57+
========
58+
59+
When using PyAFBF, please cite the original paper
60+
61+
H. Biermé, M. Moisan, and F. Richard. A turning-band method for the simulation of anisotropic fractional Brownian field. J. Comput. Graph. Statist., 24(3):885–904, 2015.
62+
63+
and the JOSS paper:
64+
65+
66+
.. image:: https://joss.theoj.org/papers/10.21105/joss.03821/status.svg
67+
:target: https://doi.org/10.21105/joss.03821
68+
69+
70+
Contents
71+
========
72+
73+
- Quick start guide
74+
- Getting started
75+
- Customed models
76+
- Tuning model parameters
77+
- Model features
78+
- Simulating with turning-band fields
79+
- Example gallery
80+
- Basic examples
81+
- Extended anisotropic fields
82+
- Heterogeneous fields
83+
- Related anisotropic fields
84+
- API: main classes
85+
- AFBF (field)
86+
- Turning band field (tbfield)
87+
- API: auxiliary classes
88+
- Periodic functions (perfunction)
89+
- Coordinates (coordinates)
90+
- Spatial data (sdata)
91+
- Process (process)
92+
- Turning bands (tbparameters)
93+
- ndarray
94+
95+
96+
97+
Credits
98+
=======
99+
100+
PyAFBF is written and maintained by Frederic Richard, Professor at Aix-Marseille University, France.
101+
102+
103+
104+
Keywords: anisotropic fractional Brownian field,image texture,simulation
105+
Platform: Linux
106+
Platform: MacOSX
107+
Platform: Windows
108+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
109+
Classifier: Development Status :: 5 - Production/Stable
110+
Classifier: Intended Audience :: Science/Research
111+
Classifier: Intended Audience :: End Users/Desktop
112+
Classifier: Intended Audience :: Developers
113+
Classifier: Natural Language :: English
114+
Classifier: Operating System :: OS Independent
115+
Classifier: Programming Language :: Python :: 3.8
116+
Classifier: Topic :: Scientific/Engineering :: Image Processing
117+
Provides-Extra: dev

PyAFBF.egg-info/requires.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
numpy>=1.19.2
22
matplotlib>=3.3.2
33
scipy>=1.5.2
4+
5+
[dev]
6+
doctest

afbf/Classes/Field.py

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
"""
4545
from afbf.utilities import pi, linspace, unique, concatenate, power
46-
from afbf.utilities import ceil, amin, amax, mean, reshape, nonzero
46+
from afbf.utilities import ceil, amin, amax, mean, reshape, nonzero, argmin
4747
from afbf.utilities import sum, zeros, array
4848
from afbf.Classes.PeriodicFunction import DiscreteFunctionDescription
4949
from afbf import sdata, coordinates, perfunction
@@ -233,7 +233,8 @@ def NormalizeModel(self):
233233
topo = perfunction(self.hurst.ftype, self.hurst.fparam.size)
234234
self.topo = topo
235235
topo.fname = 'Topothesy function'
236-
topo.finter = self.hurst.finter
236+
topo.finter = zeros(self.hurst.finter.shape)
237+
topo.finter[:] = self.hurst.finter[:]
237238
topo.fparam = zeros(self.hurst.fparam.shape)
238239
if self.hurst.steptrans:
239240
topo.trans = self.hurst.trans
@@ -391,7 +392,7 @@ def ChangeOrder(self, neworder):
391392
def ComputeFeatures(self):
392393
"""Compute several features of the field.
393394
394-
:returns: Attributes H, hurst_argmin_length, hurst_index_aniso,
395+
:returns: Attributes H, Hmax, hurst_argmin_length, hurst_index_aniso,
395396
aniso_indices_topo, aniso_indices_hurst, aniso_sharpness_topo,
396397
aniso_sharpness_hurst, aniso_indices_mixed1, aniso_indices_mixed2,
397398
aniso_sharpness_mixed1, aniso_sharpness_mixed2.
@@ -423,13 +424,6 @@ def ComputeFeatures(self):
423424
self.aniso_sharpness_mixed_1 = sh1
424425
self.aniso_sharpness_mixed_2 = sh2
425426

426-
# Analysis of the Hurst function.
427-
# Find the support of the topothesy function on (-pi/2, pi/2).
428-
ind = nonzero(self.topo.values != 0)
429-
self.topo.values = self.topo.values[ind]
430-
self.hurst.values = self.hurst.values[ind]
431-
self.hurst.t = self.hurst.t[ind]
432-
433427
# Minimum and maximum of the Hurst function on this support.
434428
self.H = amin(self.hurst.values)
435429
self.Hmax = amax(self.hurst.values)
@@ -457,10 +451,44 @@ def ComputeFeatures(self):
457451
hmean = hmean - pi
458452
self.hurst_argmin_mean = hmean
459453

454+
def ComputeFeatures_Hurst(self):
455+
"""Compute several features of the field related to the Hurst index.
456+
:returns: Attributes H, Hmax, hurst_argmin_lenght, hurst_argmin_center.
457+
"""
458+
459+
if self.CheckValidity() is False:
460+
return(0)
461+
462+
if "step" not in self.hurst.ftype or "step" not in self.topo.ftype:
463+
print("ComputeFeature_Hurst: only apply to step functions.")
464+
return(0)
465+
466+
finter = self.hurst.finter
467+
inter = concatenate((finter[0, -1].reshape((1, 1)) - pi, finter),
468+
axis=1)
469+
centers = inter[:, 0:-1] + (inter[:, 1:] - inter[:, 0:-1]) / 2
470+
self.hurst.Evaluate(centers)
471+
self.H = amin(self.hurst.fparam)
472+
self.Hmax = amax(self.hurst.fparam)
473+
i = argmin(self.hurst.values)
474+
475+
if i > 0:
476+
s = self.hurst.finter[0, i] - self.hurst.finter[0, i - 1]
477+
c = self.hurst.finter[0, i - 1] + s / 2
478+
else:
479+
s = self.hurst.finter[0, i] - self.hurst.finter[0, -1] + pi
480+
c = self.hurst.finter[0, -1] - pi + s / 2
481+
482+
self.hurst_argmin_lenght = inter[0, i + 1] - inter[0, i]
483+
c = centers[0, i]
484+
if c < - pi / 2:
485+
c = c + pi
486+
self.hurst_argmin_center = c
487+
460488

461489
def BETA_H(coord, alp1, alp2, H):
462490
r"""Approximation of an integral useful for the computation of
463-
semi-variogram.
491+
semi-variogram.
464492
465493
The approximated integral is defined as:
466494

afbf/Classes/PeriodicFunction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ def __init__(self, ftype='step-smooth', param=0, fname='noname'):
207207
self.ftype = 'undefined'
208208
self.fparam = None
209209
self.finter = None
210+
self.steptrans = None
211+
self.trans = None
210212
self.translate = 0
211213
self.rescale = 1
212214

@@ -217,7 +219,6 @@ def __init__(self, ftype='step-smooth', param=0, fname='noname'):
217219
else:
218220
print("PeriodicFunction.__init__: invalid representation.")
219221
print("PeriodicFunction.__init__: function not defined.")
220-
221222
self.t = None
222223
self.values = None
223224
self.basis = None
@@ -532,6 +533,7 @@ def SampleStepIntervals(self):
532533
k = mod(k + 1, ninter)
533534
else:
534535
k = 1
536+
535537
# Set interval bounds between -pi/2 and pi/2.
536538
finter = finter - pi / 2
537539
if self.steptrans:

afbf/Classes/RandomProcess.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"""
4646

4747
from afbf.utilities import pi, randn, rand, absolute, concatenate, fft, arange
48-
from afbf.utilities import amin, reshape, mean, zeros, diff
48+
from afbf.utilities import amin, reshape, mean, zeros
4949
from afbf.utilities import real, cumsum, power, sqrt, plt, log, nonzero
5050
from afbf import perfunction
5151

@@ -141,8 +141,7 @@ def ComputeAutocovarianceSpectrum(self):
141141
def ComputeSemiVariogram(self, lags, logvario=0):
142142
"""Compute the semi-variogram of the process at lags given in lags.
143143
144-
:param :ref:`ndarray` lags: Lags where to compute the variogram.
145-
144+
:param `ndarray`_ lags: Lags where to compute the variogram.
146145
:param logvario:
147146
if logvario>0, a log semi-variogram is computed.
148147
The default is 0.
@@ -175,7 +174,7 @@ def ComputeFBMAutocovariance(self, T):
175174
def ComputeFBMSemiVariogram(self, lags, logvario=0):
176175
"""Compute the semi-variogram of the fbm at lags given in lags.
177176
178-
:param :ref:`ndarray` lags: Lags where to compute the variogram.
177+
:param `ndarray`_ lags: Lags where to compute the variogram.
179178
:param logvario: if logvario>0, a log semi-variogram is computed.
180179
The default is 0.
181180
:type logvario: int, optional

afbf/Classes/SpatialData.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
from afbf.utilities import reshape, arange, repmat, concatenate, array, zeros
4545
from afbf.utilities import amin, amax, mean, matmul, floor, linspace, sign
46-
from afbf.utilities import power, plt, sqrt, unique
46+
from afbf.utilities import power, plt, sqrt
4747
from afbf.utilities import make_axes_locatable, ndarray
4848
from afbf.utilities import imread
4949

@@ -285,6 +285,7 @@ def Display(self, nfig=1):
285285
plt.figure(nfig)
286286
plt.plot(self.xy[:, 0] / self.N, self.xy[:, 1] / self.N, "rx")
287287
plt.axis("equal")
288+
plt.show()
288289

289290

290291
class sdata:
805 Bytes
Binary file not shown.
90 Bytes
Binary file not shown.
-16 Bytes
Binary file not shown.
1.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)