-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
145 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
scipy | ||
pywavelets | ||
fpdf2 | ||
pillow | ||
simplejpeg | ||
scikit-image | ||
tifffile | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from numpy import asarray, eye, indices | ||
from numpy.linalg import matrix_power | ||
from numpy.typing import ArrayLike | ||
|
||
|
||
def arnold_transform1(img: ArrayLike, k: int) -> ArrayLike: | ||
T = eye(2, dtype=int) # 2x2 Birim matris | ||
|
||
for _ in range(2 * k): | ||
T[:] = [[T[1, 0], T[1, 1]], [T[1, 1], T[1, 0] + T[1, 1]]] | ||
|
||
T_inv = asarray([[T[1, 1], -T[0, 1]], [-T[1, 0], T[0, 0]]]) | ||
|
||
return coordinate_transform(img, T), T_inv | ||
|
||
|
||
def arnold_transform(image, k, p=1, q=1): | ||
T = matrix_power([[1, p], [q, p * q + 1]], k) | ||
|
||
T_inv = asarray( | ||
[ | ||
[T[1, 1], -T[0, 1]], | ||
[-T[1, 0], T[0, 0]], | ||
] | ||
) | ||
|
||
return coordinate_transform(image, T), T_inv | ||
|
||
|
||
def coordinate_transform(image, T): | ||
i = indices(image.shape) | ||
i = (T @ i.reshape(2, -1)).reshape(i.shape).astype(int) | ||
|
||
return image[i[0] % image.shape[0], i[1] % image.shape[1]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from numpy import log10, sqrt | ||
from skimage.metrics import structural_similarity | ||
|
||
|
||
def MSE(image1, image2): | ||
return ((image1 - image2) ** 2).mean() | ||
|
||
|
||
def PSNR(image1, image2): | ||
return 10 * log10(1 / MSE(image1, image2)) | ||
|
||
|
||
def NCC(image1, image2): | ||
return (image1 * image2).sum() / ( | ||
sqrt((image1**2).sum()) * sqrt((image2**2).sum()) | ||
) | ||
|
||
|
||
def SSIM(image1, image2): | ||
return structural_similarity( | ||
image1, | ||
image2, | ||
channel_axis=-1, | ||
data_range=1.0, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters