Skip to content

Instantly share code, notes, and snippets.

@wyudong
wyudong / rgb2cmyk.cpp
Last active January 23, 2024 14:35
OpenCV: From RGB to CMYK
// RGB to CMYK conversion
void rgb2cmyk(cv::Mat& img, std::vector<cv::Mat>& cmyk) {
// Allocate cmyk to store 4 componets
for (int i = 0; i < 4; i++) {
cmyk.push_back(cv::Mat(img.size(), CV_8UC1));
}
// Get rgb
std::vector<cv::Mat> rgb;
cv::split(img, rgb);
@wyudong
wyudong / split.cpp
Last active August 29, 2015 14:05
Example of cv::split
// Example of cv::split
cv::Mat img = cv::imread("C:\\color wheel.jpg");
std::vector<cv::Mat> rgb;
cv::split(img, rgb);
@wyudong
wyudong / GetDigitalValues
Created January 7, 2015 12:27
MATLAB - Get digital values of a number
num = '123456789';
str = num2str(num);
val = str - '0'; % val = [1,2,3,4,5,6,7,8,9]
@wyudong
wyudong / Base16OceanColorHex.md
Last active November 4, 2016 02:17
Base16 (Ocean) color scheme for Xcode

Base 16 Ocean

.base00 { color: #2b303b; } background
.base01 { color: #343d46; }
.base02 { color: #4f5b66; } selection
.base03 { color: #65737e; } comment, invisible
.base04 { color: #a7adba; } cursor
.base05 { color: #c0c5ce; } plain text
.base06 { color: #dfe1e8; } constants
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@wyudong
wyudong / mac-terminal-cheatsheet.md
Created June 27, 2016 03:16
Useful commands and shortcuts for terminal

Mac Terminal Cheatsheet

Moving cursor

Command Description
control + a Go to the start of the line
control + e Go to the end of the line
control + b Move cursor one character backward
control + f Move cursor one character forward
@wyudong
wyudong / atom-shortcut-cheatsheet.md
Last active July 3, 2016 05:52
Useful commands and shortcuts for Atom editor

Atom Shortcut Cheatsheet

Moving

Command Description
control + a Go to the start of the line
control + e Go to the end of the line
control + b Move cursor one character backward
control + f Move cursor one character forward
@wyudong
wyudong / free-up-xcode.md
Created September 10, 2016 03:48
Free up disk space from Xcode

Free up disk space from Xcode

These items can be deleted safely.

iOS Device Support

In Finder: ~/Library/Developer/Xcode/iOS DeviceSupport/

Derived Data

var values = {
friction: 0.8,
timeStep: 0.01,
amount: 15,
mass: 2,
count: 0
};
values.invMass = 1 / values.mass;
var path, springs;
var size = view.size * [1.2, 1];