Python library to measure the image mean free path (IMFP)
Project description
MPImfp
Python library to measure the image mean free path (IMFP).
Example
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
MPImfp-0.0.1.tar.gz
(5.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file MPImfp-0.0.1.tar.gz.
File metadata
- Download URL: MPImfp-0.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32e5523923a05c262b2213486228effdb71a228993f395c5dead96000da26fce
|
|
| MD5 |
449b214f8545b80fa7e3735d37dd0a50
|
|
| BLAKE2b-256 |
ae9e406ce9359847c259923cbf47c88e0ef285a80da5e6aac5681e9aafdc6c49
|
File details
Details for the file MPImfp-0.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: MPImfp-0.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 10.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c18da91035a6a0dc7ccc1015132185c31c9f4c267643b883033da09df6304248
|
|
| MD5 |
3c6407d39c29d0ce1551af83706e7af1
|
|
| BLAKE2b-256 |
e3db297bfdf3043d9610a7be1ba65979029226f15b684953dfa56b067a591b37
|