Metadata-Version: 2.1
Name: MPImfp
Version: 0.0.1
Summary: Python library to measure the image mean free path (IMFP)
Author-email: Kenjiro Sugio <ksugio@hiroshima-u.ac.jp>
License: MIT License
        
        Copyright (c) 2024 Kenjiro Sugio
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ksugio/MPImfp
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# MPImfp
Python library to measure the image mean free path (IMFP).

# Example

```python
import MPImfp
import cv2
import numpy as np
import matplotlib.pyplot as plt

img = cv2.imread('sample.png', 0)
size = 1000
barrier = 0
freq_single = np.zeros(size, dtype=np.uint32)
freq_double = np.zeros(size, dtype=np.uint32)
dpix = 1.0
nsample = 1000000
seed = 12345
# single mode
MPImfp.measure(img, barrier, freq_single, dpix, nsample, seed, 0)
ave_single = np.sum(np.arange(size)*np.array(freq_single, dtype=np.float64)/np.sum(freq_single))
print('Average Single :', ave_single)
# double mode
MPImfp.measure(img, barrier, freq_double, dpix, nsample, seed, 1)
ave_double = np.sum(np.arange(size)*np.array(freq_double, dtype=np.float64)/np.sum(freq_double))
print('Average Double :', ave_double)
# plot
plt.plot(np.arange(size), freq_single)
plt.plot(np.arange(size), freq_double)
plt.xlabel('Pixel'), plt.ylabel('Frequency')
plt.show()
```

# References
### Methods :
#### measure(img, barrier, f, dpix, nsample, seed, dflag)
measure image mean free path  
return seed
+ img : input image
+ barrier : pixel value of barrier, 0 - 255
+ f : numpy dimension for result, dtype=np.uint32
+ dpix : length of a pixel
+ nsample : number of sample
+ seed : seed for random number
+ dflag : measure mode, 0 : single mode, 1 : double mode
