Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thank you Abid, I like your blog. I am going through you Python CV post one by one. It's a great help on learning Python opencv. You did a very nice work. </p> <p>Here is what I ended up with: </p> <pre><code>lut3 = np.column_stack((lut, lut, lut)) lutIdxDot = np.array( [0, 1, 2], dtype=int) lutIdx0 = np.zeros( image1.shape[0] * image1.shape[1], dtype=int) lutIdx1 = np.ones( image1.shape[0] * image1.shape[1], dtype=int) lutIdx2 = lutIdx1 * 2 lutIdx = np.column_stack((lutIdx0, lutIdx1, lutIdx2)) lutIdx.shape = image1.shape image1Rev = lut3[image1, lutIdx] # numpy indexing will generate the expected LUT result. </code></pre> <p>I used the numpy indexing to get the result. I didn't use the cv LUT function. The performance is unknown to me. </p> <p>The last line of code was strange to me at first. The indexing is a very interesting feature of numpy. When the code run to the last line, the lut3 is: </p> <pre><code>ipdb&gt; p lut3 array([[255, 255, 255], [254, 254, 254], [253, 253, 253], [252, 252, 252], ... [ 2, 2, 2], [ 1, 1, 1], [ 0, 0, 0]], dtype=uint8) ipdb&gt; p lutIdx array([[[0, 1, 2], [0, 1, 2], [0, 1, 2], ..., ..., [0, 1, 2], [0, 1, 2], [0, 1, 2]]]) </code></pre> <p>lutIdx has the same shape of the image1. The lut3[image1, lutIdx] is asking for an array as the result that its shape is same with image1, and lutIdx. Its values are from lut3. For each item of image1, use lut[image1's Value of that spot, lutIdx's Value of that spot] to find that output value. (I wish I can draw a diagram.)</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. This table or related slice is empty.
    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