Skip to content

Instantly share code, notes, and snippets.

View meton-robean's full-sized avatar
😀
Focusing

meton-robean meton-robean

😀
Focusing
View GitHub Profile
@meton-robean
meton-robean / list_insertion_sort.py
Created October 9, 2019 02:22
专题:在链表中实现各类排序算法
#
# @lc app=leetcode id=147 lang=python
#
# [147] Insertion Sort List
# Category Difficulty Likes Dislikes
# algorithms Medium (38.38%) 417 473
# Tags
# Companies
# Sort a linked list using insertion sort.
@meton-robean
meton-robean / calc_psnr_ssim.py
Last active November 22, 2019 12:00
机器学习中代码段
import skimage
import cv2
from skimage.measure import compare_psnr, compare_ssim
#YUV style to calc SSIM and PSNR
def calc_psnr(im1, im2):
im1_y = cv2.cvtColor(im1, cv2.COLOR_BGR2YCR_CB)[:, :, 0]
im2_y = cv2.cvtColor(im2, cv2.COLOR_BGR2YCR_CB)[:, :, 0]
return compare_psnr(im1_y, im2_y)
@meton-robean
meton-robean / evaluate.py
Created September 16, 2018 02:32
machine learning metric function
import collections
import math
def purity(result, label):
# 纯度
total_num = len(label)
cluster_counter = collections.Counter(result)
original_counter = collections.Counter(label)
@meton-robean
meton-robean / arma2opencv.hpp
Created May 7, 2017 11:56 — forked from psycharo-zz/arma2opencv.hpp
convertions between armadillo and opencv
// convert an OpenCV multi-channel matrix to Armadillo cube. A copy is made
template <typename T, int NC>
Cube<T> to_arma(const cv::Mat_<cv::Vec<T, NC>> &src)
{
vector<cv::Mat_<T>> channels;
Cube<T> dst(src.cols, src.rows, NC);
for (int c = 0; c < NC; ++c)
channels.push_back({src.rows, src.cols, dst.slice(c).memptr()});
cv::split(src, channels);
return dst;