Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm using python and using numpy so can do:</p> <pre><code>&gt;&gt;&gt; import cv &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; im = cv.LoadImageM("aaa.jpg") &gt;&gt;&gt; np.sin(im) array([[[ 0.36319944, 0.46771851, 0.99646664], [ 0.98024565, -0.49104786, 0.46771851], [ 0.69605851, -0.9983471 , -0.49104786], ..., [-0.58777064, -0.79041475, 0.60906792], [-0.79041475, -0.94252455, 0.36319944], [ 0.08839871, -0.58777064, -0.94252455]], etc... </code></pre> <p>Otherwise, it should be easy to adapt the below python code to create and use a look up table, <a href="http://opencv.willowgarage.com/documentation/python/core_operations_on_arrays.html#lut" rel="nofollow">cv.LUT</a>:</p> <pre><code>import cv import math im = cv.LoadImageM("aaa.jpg") dst = cv.CreateMat(im.height,im.width, cv.CV_32FC3) lut_sin = cv.CreateMat(256, 1, cv.CV_32FC3) for i in xrange(256): s = math.sin(i) cv.Set1D(lut_sin, i, (s,s,s,s)) cv.LUT(im,dst,lut_sin) print cv.Get2D(dst,0,0) #output, matches above: (0.36319944262504578, 0.46771851181983948, 0.99646663665771484, 0.0) </code></pre> <p>For floating point data, you can use <a href="http://opencv.willowgarage.com/documentation/python/core_operations_on_arrays.html?highlight=polartocart#PolarToCart" rel="nofollow">cv.PolarToCart</a>:</p> <pre><code>&gt;&gt;&gt; import cv &gt;&gt;&gt; im = cv.LoadImageM("aaa.jpg") &gt;&gt;&gt; im2 = cv.CreateMat(im.height, im.width, cv.CV_32FC3) &gt;&gt;&gt; cv.Convert(im,im2) &gt;&gt;&gt; sin_of_angle = cv.CreateMat(im.height, im.width, cv.CV_32FC3) &gt;&gt;&gt; cv.PolarToCart(None,im2,None,sin_of_angle,0) &gt;&gt;&gt; cv.Get1D(sin_of_angle,0) (0.36319947242736816, 0.46771851181983948, 0.99646669626235962, 0.0) &gt;&gt;&gt; cv.Get1D(sin_of_angle,1) (0.98024564981460571, -0.49104788899421692, 0.46771851181983948, 0.0) </code></pre> <p>You can use this to easily get the cos values as well. You can switch the last parameter to <code>True</code> for Radians.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload