Created
November 22, 2017 04:32
-
-
Save Kirill888/0861c2508d41766a0145682e330ff8f5 to your computer and use it in GitHub Desktop.
Sub-pixel coordinates in CV2 remap function
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline\n", | |
"import matplotlib.pyplot as plt\n", | |
"import numpy as np\n", | |
"import cv2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAEICAYAAAByNDmmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAB99JREFUeJzt212oZWUBh/HnP46mNqllZk5O0oeW\naeGNCVFkZImJjDeVfekQXqRQVN5EWFlRUEQamBRU9KlmQhBBpERmBEZEYcWkYSozWhra6OBHpb1d\nrDW4PYw5o24P/n1+sGGf/a6z9rv2mee8a699JmMMJHVas9oTkLQ8Bi4VM3CpmIFLxQxcKmbgUjED\n104l+UmSM1Z7Hnp84ufgy5fktcDngaOAB4HNwAfHGL9Z1Ymp3trVnkC7JPsBPwbOAi4D9gJeB/xr\nCc+1dozxwBO9Xz11eYq+fEcAjDEuGWM8OMa4b4xxxRjjWoAka5Kcm+TmJLcn+XaS/eex45NsXdxZ\nkpuSnDDfPy/J5Um+m+RuYFOSPZJ8NMkNSbYn+W2SDfP2L09yZZI7k1yX5G2PNOkkVyU5c76/Kcmv\nkpyfZFuSvyZ5zfz4lnneZyx878lJfpfk7nn8vBX7Pn0+3juSfGzFMa1J8pF5/nckuSz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MwKViBi4VM3CpWMYYqz0HSUviCi4VM3CpmIFLxQxcKmbgUjEDl4oZuFTMwKViBi4V\nM3CpmIFLxQxcKmbgUjEDl4oZuFTMwKViBi4VM3CpmIFLxQxcKmbgUjEDl4oZuFTsfyoZlLMcUgtL\nAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x11bd23908>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"src = np.zeros((5,5), dtype='float32')\n", | |
"src[2,2] = 1.0\n", | |
"\n", | |
"plt.imshow(src)\n", | |
"plt.title('Source image')\n", | |
"plt.gca().set_axis_off()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 0., 1., 2., 3., 4.],\n", | |
" [ 0., 1., 2., 3., 4.],\n", | |
" [ 0., 1., 2., 3., 4.],\n", | |
" [ 0., 1., 2., 3., 4.],\n", | |
" [ 0., 1., 2., 3., 4.]], dtype=float32)" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 0., 0., 0., 0., 0.],\n", | |
" [ 1., 1., 1., 1., 1.],\n", | |
" [ 2., 2., 2., 2., 2.],\n", | |
" [ 3., 3., 3., 3., 3.],\n", | |
" [ 4., 4., 4., 4., 4.]], dtype=float32)" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"x,y = [a.astype('float32') for a in np.meshgrid(np.arange(5),np.arange(5))]\n", | |
"display(x,y)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArIAAAFeCAYAAAB5F/zkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACx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S9K09cttF3tJkiSpJUdkJY1RtLseoSRNWsPctpGV\nNE6zO8RI0uQ1y20bWUlDFFDNjuwlaco65rZzZCWNUTU7sl/ksYEke5PclOTmJBev8/6Dk/zH+fvX\nJHn8gG8qSath0dzewIjMtpGV1FKSXcAlwHOAs4GLkpx9xGYvBb5QVd8I/ALwf21vlZIkGJfZNrKS\nhqlDtdBjA+cBN1fVp6rqHuAy4MIjtrkQePP858uBZyXJln5JSVoh3TLbRlbSOGOnFpwB3LLm+YH5\na+tuU1X3AV8E/uYWfTtJWj3NMtvFXpKGuJMvXPV7dfnpC37M7iTXrXm+v6r2z39e7yj9yCGBzWwj\nSWJLcnvbM9tGVtIQVbV38C4OAGeueb4HuPUo2xxI8nXAI4DPD65LkloanNtDMtupBZK6uhY4K8kT\nkpwMvBC44ohtrgB+aP7z9wJ/UNXs/ouStBqGZLYjspJaqqr7krwMuArYBbypqm5I8hrguqq6Angj\n8JYkNzM7qn/h8iqWpOkaldlxcEKSJEkdObVAkiRJLdnISpIkqSUbWUmSJLVkIytJkqSWbGQlSZLU\nko2sJEmSWrKRlSRJUks2spIkSWrp/weTa6VGtBtZSAAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10a5fd908>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 0., 0., 0., 0., 0.],\n", | |
" [ 0., 0., 0., 0., 0.],\n", | |
" [ 0., 0., 1., 0., 0.],\n", | |
" [ 0., 0., 0., 0., 0.],\n", | |
" [ 0., 0., 0., 0., 0.]], dtype=float32)" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 0. , 0. , 0. , 0. , 0. ],\n", | |
" [ 0. , 0.25, 0.25, 0. , 0. ],\n", | |
" [ 0. , 0.25, 0.25, 0. , 0. ],\n", | |
" [ 0. , 0. , 0. , 0. , 0. ],\n", | |
" [ 0. , 0. , 0. , 0. , 0. ]], dtype=float32)" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"dst = cv2.remap(src, x, y, cv2.INTER_AREA)\n", | |
"dst_ = cv2.remap(src, x+0.5, y+0.5, cv2.INTER_AREA)\n", | |
"\n", | |
"plt.figure(figsize=(12,6))\n", | |
"plt.subplot(121)\n", | |
"plt.title('Hypothesis: 0,0')\n", | |
"plt.imshow(dst, extent=[-0.5, 4.5, 4.5, -0.5], vmin=0, vmax=1)\n", | |
"plt.colorbar()\n", | |
"plt.scatter(2,2, color='r', marker='+');\n", | |
"\n", | |
"\n", | |
"plt.subplot(122)\n", | |
"plt.title('Hypothesis: 1/2, 1/2')\n", | |
"plt.imshow(dst_, extent=[0, 5, 5, 0], vmin=0, vmax=1)\n", | |
"plt.colorbar()\n", | |
"plt.scatter(2.5,2.5, color='r', marker='+');\n", | |
"plt.show()\n", | |
"\n", | |
"\n", | |
"display(dst, dst_)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"According to results above it seems that `cv2.remap` uses coordinate system with pixel centers aligned to their integer indexes. That means that top-left pixel center coordinate is `0,0`, top left pixel spans from `-0.5,-0.5` to `+0.5,+0.5`. And whole image spans from `-0.5,-0.5` to `W-0.5, H-0.5`" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment