from pathlib import Path
from skimage.metrics import structural_similarity
import cv2
import sys
path = Path(sys.argv[1])
ref = path / "reference standard.jpg"
imref = cv2.imread(ref.as_posix())
grayref = cv2.cvtColor(imref, cv2.COLOR_BGR2GRAY)
info = []
for m in path.iterdir():
if "reference standard.jpg" == m.name:
continue
im = cv2.imread(m.as_posix())
try:
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
score, difference = structural_similarity(grayref, gray, full=True)
info.append((score, m.as_posix()))
except Exception:
print(f"{m} is bad")
for score, path in sorted(info):
print(score, path)
#include <iostream>
#include <vector>
class Data
{
private:
std::vector<int> elements;
std::size_t N;
public:
explicit Data(const std::size_t size)
: N{size}
{
elements.reserve(size);
elements.resize(size);
}
void fill()
{
std::cout << "Enter elements of array:" << std::endl;
auto index = std::size_t{};
for (auto &elem : elements)
std::cin >> elements.at(index++);
}
void process(const int x)
{
if (x == elements.at(0))
{
elements.at(0) = elements.at(N - 1);
elements.at(N - 1) = x;
std::cout << "Array after swapping first and last elements: ";
for (const auto &elem : elements)
std::cout << elem << " ";
}
else
std::cout << "Error";
}
};
int main()
{
auto x = int{};
auto n = std::size_t{};
std::cout << "Enter x: ";
std::cin >> x;
std::cout << "Enter Number of array elements: ";
std::cin >> n;
auto data = Data{n};
data.fill();
data.process(x);
return 0;
}
sage: 256893450689.divisors()
[1, 19, 13520707931, 256893450689]
sage: 252323674611367475532285533.divisors()
[1, 110933, 2267937467, 1002919711403, 251589107026711, 111256892345068999, 2274559189883690836201, 252323674611367475532285533]